deputy 0.1.47 → 0.1.48

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -21,3 +21,6 @@ Usage
21
21
  deputy Cronjob.ran
22
22
  deputy Cronjob.users_found 123
23
23
  Cron: xxx 2>&1 ; deputy Cron.success $?
24
+
25
+ ### Run plugins by hand for debugging
26
+ deputy --run-plugins --no-wait
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.47
1
+ 0.1.48
data/bin/deputy CHANGED
@@ -20,20 +20,23 @@ BANNER
20
20
  opts.on("-h", "--help","Show this.") { puts opts; exit }
21
21
  opts.on('-v', '--version','Show Version'){ puts Deputy::VERSION; exit}
22
22
  opts.on('--install-cron','Install crontask'){ Deputy.install_cron; exit}
23
+ opts.on('--no-wait','Do not wait before executing plugins'){ options[:no_wait] = true }
23
24
  opts.on('--run-plugins','Run all plugins for this minute (belongs into crontask)') do
24
- puts Time.now.strftime("%Y-%m-%d %H:%M:%S")
25
- Deputy.run_plugins
26
- exit
25
+ options[:run_plugins] = true
27
26
  end
28
27
  opts.on('--host x', 'Use this host, when reporting') do |host|
29
28
  options[:host] = host
30
29
  end
31
30
  end.parse!
32
-
33
- metric, value = ARGV[0..1]
34
- if metric.to_s.empty?
35
- puts "Usage instructions: deputy --help"
36
- exit
37
- end
38
31
 
39
- Deputy.send_report metric, (value || Deputy::DEFAULT_VALUE), options
32
+ if options[:run_plugins]
33
+ puts Time.now.strftime("%Y-%m-%d %H:%M:%S")
34
+ Deputy.run_plugins options
35
+ else
36
+ metric, value = ARGV[0..1]
37
+ if metric.to_s.empty?
38
+ puts "Usage instructions: deputy --help"
39
+ exit
40
+ end
41
+ Deputy.send_report metric, (value || Deputy::DEFAULT_VALUE), options
42
+ end
data/deputy.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deputy}
8
- s.version = "0.1.47"
8
+ s.version = "0.1.48"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-02-10}
12
+ s.date = %q{2011-04-11}
13
13
  s.default_executable = %q{deputy}
14
14
  s.email = %q{mirko@dawanda.com}
15
15
  s.executables = ["deputy"]
data/lib/deputy.rb CHANGED
@@ -99,8 +99,8 @@ module Deputy
99
99
  end
100
100
  end
101
101
 
102
- def self.run_plugins
103
- sleep_random_interval
102
+ def self.run_plugins(options={})
103
+ sleep_random_interval unless options[:no_wait]
104
104
 
105
105
  content = get("/plugins.rb")
106
106
 
@@ -202,4 +202,4 @@ module Deputy
202
202
  auth = [$1, $2].compact
203
203
  auth.empty? ? nil : auth
204
204
  end
205
- end
205
+ end
data/spec/deputy_spec.rb CHANGED
@@ -33,6 +33,7 @@ end
33
33
 
34
34
  describe Deputy do
35
35
  before do
36
+ srand(Time.now.to_f * 100000) # fixes rand in klass() not being random
36
37
  Socket.stub!(:gethostname).and_return 'my_host'
37
38
  end
38
39
 
@@ -161,7 +162,6 @@ describe Deputy do
161
162
  end
162
163
 
163
164
  it "sleeps a random interval if given in config" do
164
- pending "somehow makes the next test fail wtf!"
165
165
  Socket.stub!(:gethostname).and_return 'foo'
166
166
  Deputy.stub!(:config).and_return('max_random_start_delay' => 30)
167
167
  Deputy.stub!(:send_report)
@@ -171,6 +171,15 @@ describe Deputy do
171
171
  }.should raise_error("OK")
172
172
  end
173
173
 
174
+ it "does not sleeps no_wait given" do
175
+ FakeWeb.register_uri(:get, "http://sheri.ff/plugins.rb", :body => '')
176
+ FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Deputies.finished&value=OK&hostname=my_host", :body => 'OK')
177
+ Socket.stub!(:gethostname).and_return 'foo'
178
+ Deputy.stub!(:send_report)
179
+ Deputy.should_not_receive(:sleep)
180
+ Deputy.run_plugins
181
+ end
182
+
174
183
  it "fails with nice backtrace" do
175
184
  FakeWeb.register_uri(:get, "http://sheri.ff/plugins.rb", :body => klass('FooBar', :code => 'raise'))
176
185
  FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Deputies.finished&value=Error&hostname=my_host", :body => 'OK')
@@ -234,4 +243,4 @@ describe Deputy do
234
243
  url.should == 'http://foo'
235
244
  end
236
245
  end
237
- end
246
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deputy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 69
4
+ hash: 123
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 47
10
- version: 0.1.47
9
+ - 48
10
+ version: 0.1.48
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-10 00:00:00 +01:00
18
+ date: 2011-04-11 00:00:00 +02:00
19
19
  default_executable: deputy
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency