Class: AgileNotifier::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/agile_notifier/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

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
  options = Commander.order(ARGV)
  @build_number = options[: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_failObject



87
88
89
# File 'lib/agile_notifier/configuration.rb', line 87

def alert_on_fail
  alert(:blame, :fail)
end

#alert_on_fixObject



95
96
97
# File 'lib/agile_notifier/configuration.rb', line 95

def alert_on_fix
  alert(:praise, :fix)
end

#alert_on_unstableObject



91
92
93
# File 'lib/agile_notifier/configuration.rb', line 91

def alert_on_unstable
  alert(:warn, :unstable)
end

#alert_on_wipObject



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