Class: AgileNotifier::Configuration
- Inherits:
-
Object
- Object
- AgileNotifier::Configuration
- Defined in:
- lib/agile_notifier/configuration.rb
Class Method Summary collapse
Instance Method Summary collapse
- #alert_on_fail ⇒ Object
- #alert_on_fix ⇒ Object
- #alert_on_unstable ⇒ Object
- #alert_on_wip ⇒ Object
- #ci_get(ci_type) ⇒ Object
- #ci_job(job) ⇒ Object
- #ci_url(url) ⇒ Object
-
#initialize(&blk) ⇒ Configuration
constructor
A new instance of Configuration.
- #its_auth(username, password) ⇒ Object
- #its_get(its_type) ⇒ Object
- #its_set_wip(project, query, limit) ⇒ Object
- #its_url(url) ⇒ Object
- #play(voice) ⇒ Object
- #scm_auth(auth) ⇒ Object
- #scm_get(scm_type, args = {}) ⇒ Object
- #scm_repo(repo) ⇒ Object
- #scm_url(url) ⇒ Object
- #speak(language) ⇒ Object
Constructor Details
#initialize(&blk) ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 9 10 11 |
# File 'lib/agile_notifier/configuration.rb', line 5 def initialize(&blk) @current_module = Object.const_get(self.class.to_s.split('::').first) @its_args = Hash.new = Commander.order(ARGV) @build_number = [:build_number] instance_eval(&blk) end |
Class Method Details
.set(&blk) ⇒ Object
14 15 16 |
# File 'lib/agile_notifier/configuration.rb', line 14 def set(&blk) new(&blk) end |
Instance Method Details
#alert_on_fail ⇒ Object
87 88 89 |
# File 'lib/agile_notifier/configuration.rb', line 87 def alert_on_fail alert(:blame, :fail) end |
#alert_on_fix ⇒ Object
95 96 97 |
# File 'lib/agile_notifier/configuration.rb', line 95 def alert_on_fix alert(:praise, :fix) end |
#alert_on_unstable ⇒ Object
91 92 93 |
# File 'lib/agile_notifier/configuration.rb', line 91 def alert_on_unstable alert(:warn, :unstable) end |
#alert_on_wip ⇒ Object
109 110 111 |
# File 'lib/agile_notifier/configuration.rb', line 109 def alert_on_wip Judger.on_limit(@its, organize_args) end |
#ci_get(ci_type) ⇒ Object
27 28 29 |
# File 'lib/agile_notifier/configuration.rb', line 27 def ci_get(ci_type) @ci = @current_module.const_get(ci_type).new(@ci_url, @ci_job, @build_number) end |
#ci_job(job) ⇒ Object
23 24 25 |
# File 'lib/agile_notifier/configuration.rb', line 23 def ci_job(job) @ci_job = job end |
#ci_url(url) ⇒ Object
19 20 21 |
# File 'lib/agile_notifier/configuration.rb', line 19 def ci_url(url) @ci_url = url end |
#its_auth(username, password) ⇒ Object
67 68 69 |
# File 'lib/agile_notifier/configuration.rb', line 67 def its_auth(username, password) @its_args.merge!(:username => username, :password => password) end |
#its_get(its_type) ⇒ Object
71 72 73 |
# File 'lib/agile_notifier/configuration.rb', line 71 def its_get(its_type) @its = @current_module.const_get(its_type).new(@its_args) end |
#its_set_wip(project, query, limit) ⇒ Object
75 76 77 |
# File 'lib/agile_notifier/configuration.rb', line 75 def its_set_wip(project, query, limit) @its.set_limit(project, query, limit) end |
#its_url(url) ⇒ Object
63 64 65 |
# File 'lib/agile_notifier/configuration.rb', line 63 def its_url(url) @its_args[:url] = url end |
#play(voice) ⇒ Object
83 84 85 |
# File 'lib/agile_notifier/configuration.rb', line 83 def play(voice) @voice = voice end |
#scm_auth(auth) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/agile_notifier/configuration.rb', line 40 def scm_auth(auth) username = auth.fetch(:username, nil) password = auth.fetch(:password, nil) token = auth.fetch(:token, nil) @scm_authentication = username && password ? {:basic_auth => {:username => username, :password => password}} : nil @scm_authentication = {:Authorization => "token #{token}"} if token end |
#scm_get(scm_type, args = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/agile_notifier/configuration.rb', line 48 def scm_get(scm_type, args = {}) enterprise = args.fetch(:enterprise, false) params = [@scm_url] params.push(@scm_authentication) if @scm_authentication if enterprise @scm = @current_module.const_get(scm_type).new_enterprise_version(*params) else @scm = @current_module.const_get(scm_type).new(*params) end @scm_repos.each do |repo| @scm.add_repository(repo) end return @scm end |
#scm_repo(repo) ⇒ Object
35 36 37 38 |
# File 'lib/agile_notifier/configuration.rb', line 35 def scm_repo(repo) @scm_repos ||= [] @scm_repos.push(repo) end |
#scm_url(url) ⇒ Object
31 32 33 |
# File 'lib/agile_notifier/configuration.rb', line 31 def scm_url(url) @scm_url = url end |
#speak(language) ⇒ Object
79 80 81 |
# File 'lib/agile_notifier/configuration.rb', line 79 def speak(language) @language = language.to_s.downcase.intern end |