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
- #api_key ⇒ Object
- #check ⇒ 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
20 21 22 |
# File 'lib/buildbox/configuration.rb', line 20 def api_endpoint ENV['BUILDBOX_API_ENDPOINT'] || self[:api_endpoint] || "https://api.buildbox.io/v1" end |
#api_key ⇒ Object
16 17 18 |
# File 'lib/buildbox/configuration.rb', line 16 def api_key ENV['BUILDBOX_API_KEY'] || self[:api_key] end |
#check ⇒ Object
24 25 26 27 28 29 |
# File 'lib/buildbox/configuration.rb', line 24 def check unless api_key puts "No api_key set. You can set it with\nbuildbox auth:login [api_key]" exit 1 end end |
#reload ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/buildbox/configuration.rb', line 40 def reload if path.exist? read_and_load else save && read_and_load end end |
#save ⇒ Object
36 37 38 |
# File 'lib/buildbox/configuration.rb', line 36 def save File.open(path, 'w+') { |file| file.write(pretty_json) } end |
#update(attributes) ⇒ Object
31 32 33 34 |
# File 'lib/buildbox/configuration.rb', line 31 def update(attributes) attributes.each_pair { |key, value| self[key] = value } save end |