deputy 0.1.46 → 0.1.47

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :rubygems
2
+
3
+ group :dev do
4
+ gem 'jeweler'
5
+ gem 'fakeweb'
6
+ gem 'rake'
7
+ gem 'rspec', '~>2'
8
+ gem 'fastercsv'
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ fakeweb (1.2.8)
6
+ fastercsv (1.5.3)
7
+ git (1.2.5)
8
+ jeweler (1.5.2)
9
+ bundler (~> 1.0.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ rake (0.8.7)
13
+ rspec (2.4.0)
14
+ rspec-core (~> 2.4.0)
15
+ rspec-expectations (~> 2.4.0)
16
+ rspec-mocks (~> 2.4.0)
17
+ rspec-core (2.4.0)
18
+ rspec-expectations (2.4.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.4.0)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ fakeweb
27
+ fastercsv
28
+ jeweler
29
+ rake
30
+ rspec (~> 2)
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  task :default => :spec
2
- require 'spec/rake/spectask'
3
- Spec::Rake::SpecTask.new {|t| t.spec_opts = ['--color -b']}
2
+ require "rspec/core/rake_task"
3
+ RSpec::Core::RakeTask.new(:spec) do |t|
4
+ t.rspec_opts = '--backtrace --color'
5
+ end
4
6
 
5
7
  begin
6
8
  require 'jeweler'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.46
1
+ 0.1.47
data/deputy.gemspec CHANGED
@@ -1,40 +1,40 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deputy}
8
- s.version = "0.1.46"
8
+ s.version = "0.1.47"
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{2010-09-06}
12
+ s.date = %q{2011-02-10}
13
13
  s.default_executable = %q{deputy}
14
14
  s.email = %q{mirko@dawanda.com}
15
15
  s.executables = ["deputy"]
16
16
  s.files = [
17
+ "Gemfile",
18
+ "Gemfile.lock",
17
19
  "Rakefile",
18
- "Readme.md",
19
- "VERSION",
20
- "bin/deputy",
21
- "deputy.gemspec",
22
- "lib/deputy.rb",
23
- "spec/deputy_spec.rb",
24
- "spec/spec_helper.rb"
20
+ "Readme.md",
21
+ "VERSION",
22
+ "bin/deputy",
23
+ "deputy.gemspec",
24
+ "lib/deputy.rb",
25
+ "spec/deputy_spec.rb",
26
+ "spec/spec_helper.rb"
25
27
  ]
26
28
  s.homepage = %q{http://github.com/dawanda/deputy}
27
- s.rdoc_options = ["--charset=UTF-8"]
28
29
  s.require_paths = ["lib"]
29
- s.rubygems_version = %q{1.3.7}
30
+ s.rubygems_version = %q{1.4.2}
30
31
  s.summary = %q{Report to the sheriff}
31
32
  s.test_files = [
32
33
  "spec/deputy_spec.rb",
33
- "spec/spec_helper.rb"
34
+ "spec/spec_helper.rb"
34
35
  ]
35
36
 
36
37
  if s.respond_to? :specification_version then
37
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
38
  s.specification_version = 3
39
39
 
40
40
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
data/lib/deputy.rb CHANGED
@@ -104,18 +104,27 @@ module Deputy
104
104
 
105
105
  content = get("/plugins.rb")
106
106
 
107
+ exceptions = []
107
108
  Scout.plugins(content).each do |interval, plugin|
108
109
  run_every_n_minutes = interval/60
109
110
  minutes_to_wait = run_every_n_minutes - (START_MINUTE % run_every_n_minutes)
110
111
  if minutes_to_wait == run_every_n_minutes
111
112
  puts "#{plugin.clean_class_name}: running"
112
- plugin.new.build_report
113
+ begin
114
+ plugin.new.build_report
115
+ rescue Object => e # catch and report plugin-specific errors
116
+ e.message[0..0] = plugin.to_s.split('::')[1..-1].join
117
+ puts e
118
+ exceptions << e
119
+ end
113
120
  else
114
121
  puts "#{plugin.clean_class_name}: waiting another #{minutes_to_wait} minutes"
115
122
  end
116
123
  end
117
- send_report 'Deputies.finished', DEFAULT_VALUE
118
- rescue Exception => e
124
+ send_report 'Deputies.finished', (exceptions.empty? ? DEFAULT_VALUE : 'Error')
125
+
126
+ raise exceptions.first unless exceptions.empty?
127
+ rescue Object => e # catch and report neta errors
119
128
  send_report "Deputies.Error", e.message
120
129
  raise e
121
130
  end
data/spec/deputy_spec.rb CHANGED
@@ -161,6 +161,7 @@ describe Deputy do
161
161
  end
162
162
 
163
163
  it "sleeps a random interval if given in config" do
164
+ pending "somehow makes the next test fail wtf!"
164
165
  Socket.stub!(:gethostname).and_return 'foo'
165
166
  Deputy.stub!(:config).and_return('max_random_start_delay' => 30)
166
167
  Deputy.stub!(:send_report)
@@ -169,13 +170,33 @@ describe Deputy do
169
170
  Deputy.run_plugins
170
171
  }.should raise_error("OK")
171
172
  end
173
+
174
+ it "fails with nice backtrace" do
175
+ FakeWeb.register_uri(:get, "http://sheri.ff/plugins.rb", :body => klass('FooBar', :code => 'raise'))
176
+ FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Deputies.finished&value=Error&hostname=my_host", :body => 'OK')
177
+ FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Deputies.Error&value=FooBar&hostname=my_host", :body => 'OK')
178
+ lambda{
179
+ Deputy.run_plugins
180
+ }.should raise_error('FooBar')
181
+ end
182
+
183
+ it "continues to run plugins when one fails" do
184
+ $notify = 0
185
+ FakeWeb.register_uri(:get, "http://sheri.ff/plugins.rb", :body => klass('FooBar', :code => 'raise') + klass('C', :code => '$notify = 1'))
186
+ FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Deputies.finished&value=Error&hostname=my_host", :body => 'OK')
187
+ FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Deputies.Error&value=&hostname=my_host", :body => 'OK')
188
+ lambda{
189
+ Deputy.run_plugins
190
+ }.should raise_error
191
+ $notify.should == 1
192
+ end
172
193
  end
173
194
 
174
195
  describe :send_report do
175
196
  before do
176
197
  Deputy.stub!(:config).and_return "sheriff_url" => 'http://sheri.ff'
177
198
  end
178
-
199
+
179
200
  it "sends a report" do
180
201
  FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Xxx.yyy&value=123&hostname=my_host", :body => 'OK')
181
202
  Deputy.send_report('Xxx.yyy', '123').should == 'OK'
@@ -185,7 +206,7 @@ describe Deputy do
185
206
  FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Xxx.yy%3Fy&value=123&hostname=my_host", :body => 'OK')
186
207
  Deputy.send_report('Xxx.yy?y', '123').should == 'OK'
187
208
  end
188
-
209
+
189
210
  it "overrides host, if specified in options" do
190
211
  FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Xxx.yy%3Fy&value=123&hostname=general&forced_host=true", :body => 'OK')
191
212
  Deputy.send_report('Xxx.yy?y', '123', {:host => 'general'}).should == 'OK'
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: 71
5
- prerelease: false
4
+ hash: 69
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 46
10
- version: 0.1.46
9
+ - 47
10
+ version: 0.1.47
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,12 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-06 00:00:00 +02:00
18
+ date: 2011-02-10 00:00:00 +01:00
19
19
  default_executable: deputy
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: SystemTimer
23
- prerelease: false
24
22
  requirement: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
24
  requirements:
@@ -30,8 +28,10 @@ dependencies:
30
28
  segments:
31
29
  - 0
32
30
  version: "0"
33
- type: :runtime
31
+ prerelease: false
34
32
  version_requirements: *id001
33
+ type: :runtime
34
+ name: SystemTimer
35
35
  description:
36
36
  email: mirko@dawanda.com
37
37
  executables:
@@ -41,6 +41,8 @@ extensions: []
41
41
  extra_rdoc_files: []
42
42
 
43
43
  files:
44
+ - Gemfile
45
+ - Gemfile.lock
44
46
  - Rakefile
45
47
  - Readme.md
46
48
  - VERSION
@@ -54,8 +56,8 @@ homepage: http://github.com/dawanda/deputy
54
56
  licenses: []
55
57
 
56
58
  post_install_message:
57
- rdoc_options:
58
- - --charset=UTF-8
59
+ rdoc_options: []
60
+
59
61
  require_paths:
60
62
  - lib
61
63
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -79,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
81
  requirements: []
80
82
 
81
83
  rubyforge_project:
82
- rubygems_version: 1.3.7
84
+ rubygems_version: 1.4.2
83
85
  signing_key:
84
86
  specification_version: 3
85
87
  summary: Report to the sheriff