dynport_tools 0.2.18 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.18
1
+ 0.2.19
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dynport_tools}
8
- s.version = "0.2.18"
8
+ s.version = "0.2.19"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tobias Schwab"]
12
- s.date = %q{2011-09-05}
12
+ s.date = %q{2011-09-14}
13
13
  s.description = %q{Collection of various tools}
14
14
  s.email = %q{tobias.schwab@dynport.de}
15
15
  s.executables = ["xmldiff", "redis_dumper"]
@@ -40,6 +40,8 @@ Gem::Specification.new do |s|
40
40
  "lib/dynport_tools/eta.rb",
41
41
  "lib/dynport_tools/have_attributes.rb",
42
42
  "lib/dynport_tools/jenkins.rb",
43
+ "lib/dynport_tools/job_dsl.rb",
44
+ "lib/dynport_tools/log_tracer.rb",
43
45
  "lib/dynport_tools/redis_dumper.rb",
44
46
  "lib/dynport_tools/redis_q.rb",
45
47
  "lib/dynport_tools/xml_file.rb",
@@ -50,6 +52,8 @@ Gem::Specification.new do |s|
50
52
  "spec/dynport_tools/eta_spec.rb",
51
53
  "spec/dynport_tools/have_attributes_spec.rb",
52
54
  "spec/dynport_tools/jenkins_spec.rb",
55
+ "spec/dynport_tools/job_dsl_spec.rb",
56
+ "spec/dynport_tools/log_tracer_spec.rb",
53
57
  "spec/dynport_tools/redis_dumper_spec.rb",
54
58
  "spec/dynport_tools/redis_q_spec.rb",
55
59
  "spec/dynport_tools/xml_file_spec.rb",
@@ -8,4 +8,4 @@ require "cgi"
8
8
  require "term/ansicolor"
9
9
  require "diff/lcs"
10
10
 
11
- %w(deep_merger differ jenkins redis_dumper xml_file have_attributes redis_q eta ascii_table embedded_redis).map { |m| require "dynport_tools/#{m}" }
11
+ %w(deep_merger differ jenkins redis_dumper xml_file have_attributes redis_q eta ascii_table embedded_redis job_dsl log_tracer).map { |m| require "dynport_tools/#{m}" }
@@ -145,8 +145,10 @@ class DynportTools::Jenkins
145
145
  end
146
146
 
147
147
  class Project
148
- attr_accessor :name, :commands, :crontab_pattern, :days_to_keep, :num_to_keep, :node, :child_projects, :locks, :disabled, :description, :email_addresses
149
- DEFAUL_SCM = "hudson.scm.NullSCM"
148
+ attr_accessor :name, :commands, :crontab_pattern, :days_to_keep, :num_to_keep, :node, :child_projects, :locks, :disabled, :description,
149
+ :email_addresses, :git_repository
150
+ DEFAULT_SCM = "hudson.scm.NullSCM"
151
+ GIT_SCM = "hudson.plugins.git.GitSCM"
150
152
 
151
153
  def initialize(name = nil)
152
154
  self.name = name
@@ -160,22 +162,77 @@ class DynportTools::Jenkins
160
162
  Digest::MD5.hexdigest(to_xml)
161
163
  end
162
164
 
165
+ def log_rotate_xml(node)
166
+ node.logRotator do
167
+ node.daysToKeep days_to_keep || -1
168
+ node.numToKeep num_to_keep || -1
169
+ node.artifactDaysToKeep -1
170
+ node.artifactNumToKeep -1
171
+ end
172
+ end
173
+
174
+ def git_repository_xml(xml)
175
+ xml.send("org.spearce.jgit.transport.RemoteConfig") do
176
+ xml.string "origin"
177
+ xml.int 5
178
+ xml.string "fetch"
179
+ xml.string "+refs/heads/*:refs/remotes/origin/*"
180
+ xml.string "receivepack"
181
+ xml.string "git-upload-pack"
182
+ xml.string "uploadpack"
183
+ xml.string "git-upload-pack"
184
+ xml.string "url"
185
+ xml.string git_repository
186
+ xml.string "tagopt"
187
+ xml.string
188
+ end
189
+ end
190
+
191
+ def git_options_xml(xml)
192
+ xml.mergeOptions
193
+ xml.recursiveSubmodules false
194
+ xml.doGenerateSubmoduleConfigurations false
195
+ xml.authorOrCommitter false
196
+ xml.clean false
197
+ xml.wipeOutWorkspace false
198
+ xml.pruneBranches false
199
+ xml.buildChooser(:class => "hudson.plugins.git.util.DefaultBuildChooser")
200
+ xml.gitTool "Default"
201
+ xml.submoduleCfg(:class => "list")
202
+ xml.relativeTargetDir
203
+ xml.excludedRegion
204
+ xml.excludedUsers
205
+ xml.skipTag false
206
+ end
207
+
208
+ def git_xml(xml)
209
+ xml.scm(:class => GIT_SCM) do
210
+ xml.config_version 1
211
+ xml.remoteRepositories do
212
+ git_repository_xml(xml)
213
+ end
214
+ xml.branches do
215
+ xml.send("hudson.plugins.git.BranchSpec") do
216
+ xml.name "master"
217
+ end
218
+ end
219
+ git_options_xml(xml)
220
+ end
221
+ end
222
+
163
223
  def to_xml
164
224
  Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml|
165
225
  xml.project do
166
226
  xml.actions
167
227
  xml.description *[description].compact
168
- if days_to_keep || num_to_keep
169
- xml.logRotator do
170
- xml.daysToKeep days_to_keep || -1
171
- xml.numToKeep num_to_keep || -1
172
- xml.artifactDaysToKeep -1
173
- xml.artifactNumToKeep -1
174
- end
175
- end
228
+ log_rotate_xml(xml) if days_to_keep || num_to_keep
176
229
  xml.keepDependencies false
177
230
  xml.properties
178
- xml.scm(:class => DEFAUL_SCM)
231
+ if git_repository
232
+ git_xml(xml)
233
+ else
234
+ xml.scm(:class => DEFAULT_SCM)
235
+ end
179
236
  if node
180
237
  xml.assignedNode node
181
238
  xml.canRoam false
@@ -0,0 +1,114 @@
1
+ class Jenkins
2
+ class JobDSL
3
+ class << self
4
+ attr_accessor :jobs
5
+
6
+ def setup(namespace = :default, &block)
7
+ dsl = self.new
8
+ dsl.instance_eval(&block) if block_given?
9
+ self.jobs ||= {}
10
+ self.jobs[namespace] ||= Array.new
11
+ self.jobs[namespace] += dsl.jobs
12
+ self.jobs[namespace]
13
+ end
14
+ end
15
+
16
+ attr_accessor :name, :jobs, :current_scope, :current_prefix
17
+
18
+ def initialize(options = {})
19
+ options.each do |key, value|
20
+ self.send(:"#{key}=", value) if self.respond_to?(:"#{key}=")
21
+ end
22
+ self.jobs = []
23
+ self.current_scope = {}
24
+ end
25
+
26
+ MULTIPLE = [:notify, :cron_patterns, :locks, :commands]
27
+
28
+ [
29
+ :node, :disabled, :days_to_keep, :num_to_keep, :notify, :cron_patterns, :locks, :commands, :ordered, :rails_root,
30
+ :rails_env
31
+ ].each do |method|
32
+ attr_writer method
33
+
34
+ define_method(method) do |*values, &block|
35
+ self.setter_or_getter(method, *values, &block)
36
+ end
37
+ end
38
+
39
+ alias_method :cron_pattern, :cron_patterns
40
+ alias_method :lock, :locks
41
+ alias_method :command, :commands
42
+ alias_method :prefix, :ordered
43
+
44
+ def disabled!(&block)
45
+ disabled(true, &block)
46
+ end
47
+
48
+ def use_rails3!
49
+ @rails3 = true
50
+ end
51
+
52
+ def use_bundle_exec!
53
+ @bundle_exec = true
54
+ end
55
+
56
+ def rails_command(cmd, options = {})
57
+ rails_command_or_script(%("#{cmd.gsub('"', '\\"')}"), options)
58
+ end
59
+
60
+ def rails_script(*args)
61
+ rails_command_or_script(*args)
62
+ end
63
+
64
+ def rake_task(task, options = {})
65
+ options[:env] = (options[:env] || {}).merge("RAILS_ENV" => options[:rails_env]) if options[:rails_env]
66
+ command "cd #{rails_root} && " + command_with_env("rake #{task}", options[:env])
67
+ end
68
+
69
+ def rails_command_or_script(cmd_or_script, options = {})
70
+ raise "rails_root must be set" if rails_root.nil?
71
+ command %(cd #{rails_root} && #{command_with_env(runner_command(options[:rails_env]), options[:env])} #{cmd_or_script})
72
+ end
73
+
74
+ def runner_command(env = nil)
75
+ env ||= rails_env
76
+ [@rails3 ? "rails runner" : "./script/runner", env ? "-e #{env}" : nil].compact.join(" ")
77
+ end
78
+
79
+ def command_with_env(cmd, env = {})
80
+ ((env || {}).sort.map { |key, value| "#{key}=#{value}" } + [@bundle_exec ? "bundle exec" : nil, cmd].compact).join(" ")
81
+ end
82
+
83
+ def with(options, &block)
84
+ old_scope = self.current_scope
85
+ self.current_scope = self.current_scope.merge(options)
86
+ self.instance_eval(&block)
87
+ self.current_scope = old_scope
88
+ end
89
+
90
+ def current_prefix
91
+ self.current_scope[:ordered] || self.current_scope[:prefix]
92
+ end
93
+
94
+ def setter_or_getter(key, *values, &block)
95
+ value = MULTIPLE.include?(key) ? values : values.first
96
+ if block_given?
97
+ with(key => value, &block)
98
+ elsif ![[], nil].include?(value)
99
+ self.send(:"#{key}=", value)
100
+ end
101
+ self.instance_variable_get("@#{key}")
102
+ end
103
+
104
+ def job(name, &block)
105
+ if current_prefix
106
+ @prefix_indexes ||= Hash.new(0)
107
+ name = "#{current_prefix}%03d %s" % [@prefix_indexes[current_prefix] += 1, name]
108
+ end
109
+ job = JobDSL.new(self.current_scope.merge(:name => name))
110
+ job.instance_eval(&block) if block_given?
111
+ self.jobs << job
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,42 @@
1
+ class DynportTools::LogTracer
2
+ REMOVE_COLOR = /\e.*?\dm/
3
+ FILTER_BACKTRACE = /\/(gems|ruby)\//
4
+ LOGGER_METHODS = %w(unknown fatal error warn info debug)
5
+
6
+ def self.setup(logger)
7
+ return if logger.respond_to?(:log_trace)
8
+ logger.class.class_eval do
9
+ LOGGER_METHODS.each do |meth|
10
+ alias_method :"#{meth}_without_log_tracer", meth
11
+
12
+ def register_tracer(re_or_messahge, &block)
13
+ tracers[re_or_messahge] = block
14
+ end
15
+
16
+ def tracers
17
+ @tracers ||= Hash.new
18
+ end
19
+
20
+ def log_trace(message)
21
+ self.tracers.each do |re_or_string, block|
22
+ filtered_backtrace = filter_backtrace(caller)
23
+ if filtered_backtrace.any? && (re_or_string.is_a?(String) ? message.include?(re_or_string) : message.match(re_or_string))
24
+ block.call(message.gsub(REMOVE_COLOR, "").strip, filtered_backtrace)
25
+ end
26
+ end
27
+ end
28
+
29
+ def filter_backtrace(trace)
30
+ trace.reject { |t| t.match(FILTER_BACKTRACE) }
31
+ end
32
+
33
+ eval <<-EOM, nil, __FILE__, __LINE__ + 1
34
+ def #{meth}(message = nil)
35
+ log_trace(message)
36
+ #{meth}_without_log_tracer(message)
37
+ end
38
+ EOM
39
+ end
40
+ end
41
+ end
42
+ end
@@ -135,6 +135,11 @@ describe "DynportTools::Jenkins" do
135
135
  end
136
136
  end
137
137
 
138
+ it "adds a git entry when git is set" do
139
+ job.git_repository = "git@github.com:dynport/dynport_tools.git"
140
+ job.to_xml.should include(%(scm class="hudson.plugins.git.GitSCM">))
141
+ end
142
+
138
143
  it "sets the correct email_addresses when present" do
139
144
  job.email_addresses = %w(test@test.xx test2@test.xx)
140
145
  doc.xpath("/project/publishers/hudson.tasks.Mailer/recipients").map(&:inner_text).should == ["test@test.xx,test2@test.xx"]
@@ -0,0 +1,301 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jenkins::JobDSL do
4
+ let(:job) { Jenkins::JobDSL.new }
5
+
6
+ after(:each) do
7
+ Jenkins::JobDSL.jobs = nil
8
+ end
9
+
10
+ describe "Job" do
11
+ it "can be initialized with a scope" do
12
+ Jenkins::JobDSL.new(:node => "Some Node").node.should == "Some Node"
13
+ end
14
+
15
+ it "sets the current scope to an empty hash" do
16
+ Jenkins::JobDSL.new.current_scope.should == {}
17
+ end
18
+ end
19
+
20
+
21
+ describe "#runner_command" do
22
+ it "returns ./script/runner when no env given" do
23
+ job.runner_command.should == "./script/runner"
24
+ end
25
+
26
+ it "returns rails runner when rails3 is set" do
27
+ job.use_rails3!
28
+ job.runner_command.should == "rails runner"
29
+ end
30
+
31
+ it "adds the rails env when given" do
32
+ job.runner_command("staging").should == "./script/runner -e staging"
33
+ end
34
+
35
+ it "adds the default rails_env" do
36
+ job.rails_env = "staging"
37
+ job.runner_command.should == "./script/runner -e staging"
38
+ end
39
+
40
+ it "uses given rails env when both given" do
41
+ job.rails_env = "staging"
42
+ job.runner_command("staging2").should == "./script/runner -e staging2"
43
+ end
44
+ end
45
+
46
+ describe "#rails_script" do
47
+ it "calls rails_command_or_script with script" do
48
+ job.should_receive(:rails_command_or_script).with("./jobs/do_something.rb", :rails_env => "staging")
49
+ job.rails_script("./jobs/do_something.rb", :rails_env => "staging")
50
+ end
51
+ end
52
+
53
+ describe "#rake_task" do
54
+ before(:each) do
55
+ job.rails_root "/rails/root"
56
+ end
57
+
58
+ it "sets the correct rails command" do
59
+ job.rake_task "db:check"
60
+ job.commands.should == ["cd /rails/root && rake db:check"]
61
+ end
62
+
63
+ it "hands in env variables" do
64
+ job.should_receive(:command_with_env).with("rake db:check", { "A" => "true" }).and_return "some command"
65
+ job.rake_task "db:check", :env => { "A" => "true"}
66
+ job.commands.should == ["cd /rails/root && some command"]
67
+ end
68
+
69
+ it "correctly merges the rails env when given" do
70
+ job.should_receive(:command_with_env).with("rake db:check", { "A" => "true", "RAILS_ENV" => "staging" }).and_return "some other command"
71
+ job.rake_task "db:check", :env => { "A" => "true"}, :rails_env => "staging"
72
+ job.commands.should == ["cd /rails/root && some other command"]
73
+ end
74
+ end
75
+
76
+ describe "#rails_command" do
77
+ it "calls rails_command_or_script with script" do
78
+ job.should_receive(:rails_command_or_script).with(%("puts 1"), :rails_env => "staging")
79
+ job.rails_command("puts 1", :rails_env => "staging")
80
+ end
81
+
82
+ it "correctly escapes the command" do
83
+ job.should_receive(:rails_command_or_script).with(%("puts \\\"hello\\\""), :rails_env => "staging")
84
+ job.rails_command(%(puts "hello"), :rails_env => "staging")
85
+ end
86
+ end
87
+
88
+ describe "#command_with_env" do
89
+ it "puts all env variables in front of command" do
90
+ job.command_with_env("some command", "A" => "true").should == "A=true some command"
91
+ end
92
+
93
+ it "returns the command without env when env is nil" do
94
+ job.command_with_env("some command").should == "some command"
95
+ end
96
+
97
+ it "adds bundle exec between env and command" do
98
+ job.use_bundle_exec!
99
+ job.command_with_env("some command", "A" => "true").should == "A=true bundle exec some command"
100
+ end
101
+ end
102
+
103
+ describe "#rails_command_or_script" do
104
+ before(:each) do
105
+ job.rails_root = "/path/to/rails"
106
+ job.stub!(:runner_command).and_return "./script/runner"
107
+ end
108
+
109
+ it "calls command with correct args" do
110
+ job.rails_command_or_script "./some/script.rb"
111
+ job.commands.should == [%(cd /path/to/rails && ./script/runner ./some/script.rb)]
112
+ end
113
+
114
+ it "calls runner_command with correct env" do
115
+ job.should_receive(:runner_command).with("staging")
116
+ job.rails_command_or_script "puts 1", :rails_env => "staging"
117
+ job.commands
118
+ end
119
+
120
+ it "can set various env flags" do
121
+ job.rails_command_or_script "./script.rb", :env => { "A" => "a", "B" => "b"}
122
+ job.commands.should == [%(cd /path/to/rails && A=a B=b ./script/runner ./script.rb)]
123
+ end
124
+
125
+ it "raises an error when rails_root is nil" do
126
+ job.rails_root = nil
127
+ lambda {
128
+ job.rails_command_or_script "some"
129
+ }.should raise_error("rails_root must be set")
130
+ end
131
+ end
132
+
133
+ describe "setters and getters" do
134
+ {
135
+ :node => "Some Node", :disabled => true, :days_to_keep => 10, :num_to_keep => 1, :ordered => "A",
136
+ :rails_root => "/some/path"
137
+ }.each do |key, value|
138
+ it "sets #{key} to #{value}" do
139
+ job.send(key, value)
140
+ job.send(key).should == value
141
+ end
142
+ end
143
+
144
+ it "allows setting multiple email addresses" do
145
+ job.notify "email1@test.xx", "email2@test.xx"
146
+ job.notify.should == %w(email1@test.xx email2@test.xx)
147
+ end
148
+
149
+ %w(cron_pattern lock command command).each do |singular|
150
+ it "allows setting #{singular}s with #{singular}" do
151
+ job.send(singular, "#{singular}1")
152
+ job.send("#{singular}").should == ["#{singular}1"]
153
+ end
154
+
155
+ it "allows setting #{singular}s with #{singular}s" do
156
+ job.send("#{singular}s", "#{singular}1", "#{singular}2")
157
+ job.send("#{singular}").should == ["#{singular}1", "#{singular}2"]
158
+ end
159
+ end
160
+
161
+ it "provides a simple setter_or_getter" do
162
+ lambda {
163
+ job.disabled!
164
+ }.should change(job, :disabled).to(true)
165
+ end
166
+ end
167
+
168
+ describe "#node" do
169
+ before(:each) do
170
+ job.current_scope = { :ttl => 1 }
171
+ end
172
+
173
+ it "can set the node" do
174
+ job.node "Some Node"
175
+ job.node.should == "Some Node"
176
+ end
177
+
178
+ it "does not set the node when block given" do
179
+ job.node "Some Node" do
180
+ end
181
+ job.node.should be_nil
182
+ end
183
+
184
+ it "resets the correct scope" do
185
+ job.node "Some Node" do
186
+ end
187
+ job.current_scope.should == { :ttl => 1 }
188
+ end
189
+
190
+ it "merges the current scope with the node" do
191
+ scope = nil
192
+ job.node "Some Node" do
193
+ scope = self.current_scope
194
+ end
195
+ scope.should have_attributes(:ttl => 1, :node => "Some Node")
196
+ end
197
+ end
198
+
199
+ describe "#setup" do
200
+ it "returns a new instance of Jenkins" do
201
+ Jenkins::JobDSL.setup.should be_kind_of(Array)
202
+ end
203
+
204
+ it "sets the new jobs to the default key when no namespace given" do
205
+ Jenkins::JobDSL.setup do
206
+ job "Default Job"
207
+ end
208
+ Jenkins::JobDSL.jobs[:default].count.should == 1
209
+ Jenkins::JobDSL.jobs[:default].first.name.should == "Default Job"
210
+ end
211
+
212
+ it "does not overwrite jobs" do
213
+ Jenkins::JobDSL.setup do
214
+ job "First Job"
215
+ end
216
+ Jenkins::JobDSL.setup do
217
+ job "Second Job"
218
+ end
219
+ Jenkins::JobDSL.jobs[:default].count.should == 2
220
+ end
221
+
222
+ it "dass the jobs to a custom key" do
223
+ Jenkins::JobDSL.setup :custom do
224
+ job "Default Job"
225
+ end
226
+ Jenkins::JobDSL.jobs[:custom].count.should == 1
227
+ Jenkins::JobDSL.jobs[:custom].first.name.should == "Default Job"
228
+ end
229
+ end
230
+
231
+ describe "#job" do
232
+ it "adds a new job to the children" do
233
+ job.job "Some Name"
234
+ job.jobs.count.should == 1
235
+ job.jobs.first.name.should == "Some Name"
236
+ end
237
+
238
+ it "initializes the job with current_scope" do
239
+ job.current_scope = { :node => "Test" }
240
+ job.job "Some Name"
241
+ job.jobs.first.node.should == "Test"
242
+ end
243
+
244
+ it "adds a prefix to the name when current_prefix is set" do
245
+ job.current_scope = { :ordered => "A" }
246
+ job.job "Some Name"
247
+ job.jobs.first.name.should == "A001 Some Name"
248
+ end
249
+ end
250
+
251
+ describe "integration" do
252
+ it "adds a new job to the dsl object" do
253
+ Jenkins::JobDSL.setup do
254
+ job "some name" do
255
+ node "Import"
256
+ end
257
+
258
+ job "some other name" do
259
+ command "ls"
260
+
261
+ job "child job"
262
+ end
263
+
264
+ node "Backup" do
265
+ job "Backup Task"
266
+ end
267
+
268
+ with :locks => %w(Lock1 Lock2), :node => "Other Node" do
269
+ job "Other Job"
270
+ end
271
+
272
+ ordered "A" do
273
+ job "First" do
274
+ with :prefix => "B" do
275
+ job "Third"
276
+ job "Fourth"
277
+ end
278
+ end
279
+
280
+ job "Second"
281
+ end
282
+ end
283
+ jobs = Jenkins::JobDSL.jobs[:default]
284
+ jobs.count.should == 6
285
+ jobs.first.name.should == "some name"
286
+ jobs.first.node.should == "Import"
287
+ jobs.at(1).commands.should == %w(ls)
288
+ jobs.at(1).jobs.count.should == 1
289
+ jobs.at(1).jobs.first.name.should == "child job"
290
+ jobs.at(2).name.should == "Backup Task"
291
+ jobs.at(2).node.should == "Backup"
292
+
293
+ jobs.at(3).node.should == "Other Node"
294
+ jobs.at(3).locks.should == %w(Lock1 Lock2)
295
+ jobs.at(3).name.should == "Other Job"
296
+ jobs.at(4).name.should == "A001 First"
297
+ jobs.at(5).name.should == "A002 Second"
298
+ jobs.at(4).jobs.map { |j| j.name }.should == ["B001 Third", "B002 Fourth"]
299
+ end
300
+ end
301
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+ require "logger"
3
+
4
+ describe "DynportTools::LogTracer" do
5
+ let(:clazz) { Class.new(Logger) }
6
+ let(:logger) { clazz.new("/dev/null") }
7
+
8
+ it "adds filters to all methods" do
9
+ DynportTools::LogTracer.setup(logger)
10
+ logger.should respond_to(:log_trace)
11
+ end
12
+
13
+ it "calls class_eval once" do
14
+ clazz.should_receive(:class_eval)
15
+ DynportTools::LogTracer.setup(logger)
16
+ end
17
+
18
+ it "does not call class_eval when already responding to log_trace" do
19
+ logger.should_receive(:respond_to?).with(:log_trace).and_return true
20
+ clazz.should_not_receive(:class_eval)
21
+ DynportTools::LogTracer.setup(logger)
22
+ end
23
+
24
+ it "catches all messages with a specific pattern" do
25
+ DynportTools::LogTracer.setup(logger)
26
+ messages = []
27
+ logger.register_tracer(/rgne/) do |message, trace|
28
+ messages << message
29
+ end
30
+ logger.info("hello")
31
+ logger.info("rgne1")
32
+ logger.info("world")
33
+ logger.info("rgne2")
34
+ messages.should == %w(rgne1 rgne2)
35
+ end
36
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynport_tools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 18
10
- version: 0.2.18
9
+ - 19
10
+ version: 0.2.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tobias Schwab
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-05 00:00:00 +02:00
18
+ date: 2011-09-14 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -255,6 +255,8 @@ files:
255
255
  - lib/dynport_tools/eta.rb
256
256
  - lib/dynport_tools/have_attributes.rb
257
257
  - lib/dynport_tools/jenkins.rb
258
+ - lib/dynport_tools/job_dsl.rb
259
+ - lib/dynport_tools/log_tracer.rb
258
260
  - lib/dynport_tools/redis_dumper.rb
259
261
  - lib/dynport_tools/redis_q.rb
260
262
  - lib/dynport_tools/xml_file.rb
@@ -265,6 +267,8 @@ files:
265
267
  - spec/dynport_tools/eta_spec.rb
266
268
  - spec/dynport_tools/have_attributes_spec.rb
267
269
  - spec/dynport_tools/jenkins_spec.rb
270
+ - spec/dynport_tools/job_dsl_spec.rb
271
+ - spec/dynport_tools/log_tracer_spec.rb
268
272
  - spec/dynport_tools/redis_dumper_spec.rb
269
273
  - spec/dynport_tools/redis_q_spec.rb
270
274
  - spec/dynport_tools/xml_file_spec.rb