lib/jenkins/builder/config.rb in jenkins-builder-0.2.1 vs lib/jenkins/builder/config.rb in jenkins-builder-0.2.2

- old
+ new

@@ -2,14 +2,15 @@ module Jenkins module Builder class Config - attr_accessor :file, :config + attr_accessor :file, :config, :service - def initialize + def initialize(service = nil) + @service = service @file = File.expand_path('~/.jenkins-builder.yaml') if File.exist?(@file) @config = load(@file) else @@ -24,23 +25,23 @@ def []=(k, v) @config[k] = v end def username - @config['username'] + @config['services'][@service]['username'] end def username=(name) - @config['username'] = name + @config['services'][@service]['username'] = name end def password - @config['password'] + @config['services'][@service]['password'] end def password=(passwd) - @config['password'] = passwd + @config['services'][@service]['password'] = passwd end def aliases @config['aliases'] end @@ -48,15 +49,15 @@ def aliases=(aliases) @config['aliases'] = aliases end def url - @config['url'] + @config['services'][@service]['url'] end def url=(url) - @config['url'] = url + @config['services'][@service]['url'] = url end def branches @config['branches'] end @@ -64,10 +65,10 @@ def branches=(branches) @config['branches'] = branches end def hooks_of(job) - hooks = @config['hooks'] && @config['hooks'][job] + hooks = @config['services'][@service]['hooks'] && @config['services'][@service]['hooks'][job] hooks = [hooks] if hooks.is_a?(String) hooks end def init