Class: Buildbox::Configuration
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Buildbox::Configuration
- Defined in:
- lib/buildbox/configuration.rb
Instance Method Summary collapse
- #agent_access_tokens ⇒ Object
- #api_endpoint ⇒ Object
- #reload ⇒ Object
- #save ⇒ Object
- #update(attributes) ⇒ Object
Instance Method Details
#agent_access_tokens ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/buildbox/configuration.rb', line 6 def agent_access_tokens env_agents = ENV['BUILDBOX_AGENTS'] if env_agents.nil? self[:agent_access_tokens] || [] else env_agents.to_s.split(",") end end |
#api_endpoint ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/buildbox/configuration.rb', line 16 def api_endpoint endpoint = ENV['BUILDBOX_API_ENDPOINT'] || self[:api_endpoint] || "https://agent.buildbox.io/v1" # hack to update legacy endpoints if endpoint == "https://api.buildbox.io/v1" self.api_endpoint = "https://agent.buildbox.io/v1" save api_endpoint else endpoint end end |
#reload ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/buildbox/configuration.rb', line 38 def reload if path.exist? read_and_load else save && read_and_load end end |
#save ⇒ Object
34 35 36 |
# File 'lib/buildbox/configuration.rb', line 34 def save File.open(path, 'w+') { |file| file.write(pretty_json) } end |
#update(attributes) ⇒ Object
29 30 31 32 |
# File 'lib/buildbox/configuration.rb', line 29 def update(attributes) attributes.each_pair { |key, value| self[key] = value } save end |