deputy 0.1.6 → 0.1.7
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 +1 -1
- data/deputy.gemspec +2 -2
- data/lib/deputy.rb +9 -5
- data/spec/deputy_spec.rb +14 -5
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
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.
|
8
|
+
s.version = "0.1.7"
|
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-06-
|
12
|
+
s.date = %q{2010-06-03}
|
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
@@ -21,16 +21,16 @@ class Scout
|
|
21
21
|
def self.plugins(code)
|
22
22
|
eval_and_fetch_constants(code).map do |container|
|
23
23
|
interval = container.interval
|
24
|
-
|
24
|
+
unless plugin = plugin_in_container(container)
|
25
|
+
Deputy.send_report "Deputies.Plugin not found", code
|
26
|
+
next
|
27
|
+
end
|
25
28
|
[interval, plugin]
|
26
29
|
end.compact
|
27
30
|
end
|
28
31
|
|
29
32
|
def self.plugin_in_container(container)
|
30
|
-
|
31
|
-
constants.detect do |constant|
|
32
|
-
constant.instance_methods.map{|m| m.to_sym }.include?(:build_report)
|
33
|
-
end
|
33
|
+
container.constants.map{|constant_name| container.const_get(constant_name)}.first
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -44,10 +44,14 @@ module Deputy
|
|
44
44
|
|
45
45
|
def self.run_plugins
|
46
46
|
content = get("/plugins.rb")
|
47
|
+
|
47
48
|
Scout.plugins(content).each do |interval, plugin|
|
48
49
|
run_every_n_minutes = interval/60
|
49
50
|
plugin.new.build_report if START_MINUTE % run_every_n_minutes == 0
|
50
51
|
end
|
52
|
+
rescue Exception => e
|
53
|
+
send_report "Deputies.Error", e.message
|
54
|
+
raise e
|
51
55
|
end
|
52
56
|
|
53
57
|
def self.send_report(metric, value)
|
data/spec/deputy_spec.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
require 'spec/spec_helper'
|
2
2
|
|
3
|
+
class ErrorPlugin < Scout::Plugin
|
4
|
+
def build_report
|
5
|
+
raise 'FOO'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
describe Deputy do
|
4
10
|
it "has a VERSION" do
|
5
11
|
Deputy::VERSION.should =~ /^\d+\.\d+\.\d+$/
|
@@ -10,12 +16,15 @@ describe Deputy do
|
|
10
16
|
end
|
11
17
|
|
12
18
|
describe Scout do
|
13
|
-
|
14
|
-
|
15
|
-
|
19
|
+
describe :plugins do
|
20
|
+
it "finds plugins" do
|
21
|
+
Scout.plugins(klass('A', :rand => 1111)).inspect.should == '[[60, TEMP_1111::A]]'
|
22
|
+
end
|
16
23
|
|
17
|
-
|
18
|
-
|
24
|
+
it "reprots non-plugins" do
|
25
|
+
Deputy.should_receive(:send_report)
|
26
|
+
Scout.plugins("class Foo;def self.interval;11;end;end").inspect.should == '[]'
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 7
|
9
|
+
version: 0.1.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Michael Grosser
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-03 00:00:00 +02:00
|
18
18
|
default_executable: deputy
|
19
19
|
dependencies: []
|
20
20
|
|