Class: Orch::Config
- Inherits:
-
Object
- Object
- Orch::Config
- Defined in:
- lib/config.rb
Instance Method Summary collapse
- #bamboo_url(spec, app) ⇒ Object
- #chronos_url(spec, app) ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #key_search(key, spec, app) ⇒ Object
- #marathon_url(spec, app) ⇒ Object
- #setup_config(settings) ⇒ Object
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/config.rb', line 8 def initialize() @options = @config_path = "#{Dir.home}/.orch/config.yml" if File.file?(@config_path) @APP_CONFIG = YAML.load_file(@config_path) else @APP_CONFIG = nil end end |
Instance Method Details
#bamboo_url(spec, app) ⇒ Object
27 28 29 |
# File 'lib/config.rb', line 27 def bamboo_url(spec, app) return key_search("bamboo_url", spec, app) end |
#chronos_url(spec, app) ⇒ Object
19 20 21 |
# File 'lib/config.rb', line 19 def chronos_url(spec, app) return key_search("chronos_url", spec, app) end |
#key_search(key, spec, app) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/config.rb', line 31 def key_search(key, spec, app) # First look if key was passed in as option if @options.has_key?(key) url = @options[key] return url end # Second look in the application level spec if !app[key].nil? return app[key] end # Third look in the config portion of the spec if !spec.config.nil? if !spec.config[key].nil? return spec.config[key] end end # Forth look in the config file if !@APP_CONFIG.nil? if !@APP_CONFIG[key].nil? return @APP_CONFIG[key] end end return nil end |
#marathon_url(spec, app) ⇒ Object
23 24 25 |
# File 'lib/config.rb', line 23 def marathon_url(spec, app) return key_search("marathon_url", spec, app) end |
#setup_config(settings) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/config.rb', line 60 def setup_config(settings) if @APP_CONFIG.nil? @APP_CONFIG = {} end settings.each do |key, value| if settings[key] != "" @APP_CONFIG[key] = value end end if ! File.directory?("#{Dir.home}/.orch") Dir.mkdir("#{Dir.home}/.orch") end File.open(@config_path, 'w') {|f| f.write @APP_CONFIG.to_yaml} end |