lib/agile_notifier/configuration.rb in agile_notifier-1.1.1 vs lib/agile_notifier/configuration.rb in agile_notifier-2.0

- old
+ new

@@ -2,10 +2,11 @@ module AgileNotifier class Configuration def initialize(&blk) @current_module = Object.const_get(self.class.to_s.split('::').first) + @its_args = Hash.new instance_eval(&blk) end class << self def set(&blk) @@ -46,10 +47,26 @@ @scm.add_repository(repo) end return @scm end + def its_url(url) + @its_args[:url] = url + end + + def its_auth(username, password) + @its_args.merge!(:username => username, :password => password) + end + + def its_get(its_type) + @its = @current_module.const_get(its_type).new(@its_args) + end + + def its_set_wip(project, query, limit) + @its.set_limit(project, query, limit) + end + def speak(language) @language = language.to_s.downcase.intern end def play(voice) @@ -67,20 +84,28 @@ def alert_on_fix alert(:praise, :fix) end def alert(composer_type, judger_type) - args = Hash.new - args[:language] = @language - args[:voice] = @voice if @voice composer_type = composer_type.to_s.downcase judger_type = judger_type.to_s.downcase composer_method = "#{composer_type}_committer_of_a_commit".intern judger_method = "on_#{judger_type}".intern text = Composer.send(composer_method, repo: @scm.repository, revision: @ci.job.last_build.revision, language: @language) - Judger.send(judger_method, @ci.job.last_build, text, args) + Judger.send(judger_method, @ci.job.last_build, text, organize_args) end + def alert_on_wip + Judger.on_limit(@its, organize_args) + end + + def organize_args + args = Hash.new + args[:language] = @language + args[:voice] = @voice if @voice + args + end + private_class_method :new - private :alert + private :alert, :organize_args end end \ No newline at end of file