deputy 0.1.10 → 0.1.11
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 +1 -1
- data/lib/deputy.rb +4 -2
- data/spec/deputy_spec.rb +40 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.11
|
data/deputy.gemspec
CHANGED
data/lib/deputy.rb
CHANGED
@@ -11,6 +11,8 @@ end
|
|
11
11
|
|
12
12
|
class Scout
|
13
13
|
class Plugin
|
14
|
+
OPTIONS = {}.to_yaml
|
15
|
+
|
14
16
|
def report(metrics)
|
15
17
|
metrics.each do |key, value|
|
16
18
|
Deputy.send_report "#{self.class.to_s.split('::')[1..-1]}.#{key}", value
|
@@ -18,8 +20,8 @@ class Scout
|
|
18
20
|
end
|
19
21
|
|
20
22
|
# stub options for now...
|
21
|
-
def option(
|
22
|
-
|
23
|
+
def option(key)
|
24
|
+
(YAML.load(self.class::OPTIONS)[key.to_s]||{})['default']
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
data/spec/deputy_spec.rb
CHANGED
@@ -6,6 +6,28 @@ class ErrorPlugin < Scout::Plugin
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
+
class FooPlugin < Scout::Plugin
|
10
|
+
OPTIONS=<<-EOS
|
11
|
+
username:
|
12
|
+
name: Username
|
13
|
+
notes: The MySQL username to use
|
14
|
+
default: other
|
15
|
+
EOS
|
16
|
+
end
|
17
|
+
|
18
|
+
class OptionsPlugin < Scout::Plugin
|
19
|
+
OPTIONS=<<-EOS
|
20
|
+
host:
|
21
|
+
name: Host
|
22
|
+
notes: The slave host to monitor
|
23
|
+
default: 127.0.0.1
|
24
|
+
username:
|
25
|
+
name: Username
|
26
|
+
notes: The MySQL username to use
|
27
|
+
default: root
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
|
9
31
|
describe Deputy do
|
10
32
|
it "has a VERSION" do
|
11
33
|
Deputy::VERSION.should =~ /^\d+\.\d+\.\d+$/
|
@@ -26,6 +48,24 @@ describe Deputy do
|
|
26
48
|
Scout.plugins("class Foo;def self.interval;11;end;end").inspect.should == '[]'
|
27
49
|
end
|
28
50
|
end
|
51
|
+
|
52
|
+
describe :option do
|
53
|
+
it "get default" do
|
54
|
+
OptionsPlugin.new.option(:username).should == 'root'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "get nil when no default is there" do
|
58
|
+
OptionsPlugin.new.option(:foo).should == nil
|
59
|
+
end
|
60
|
+
|
61
|
+
it "get nil when no OPTIONS are there" do
|
62
|
+
ErrorPlugin.new.option(:foo).should == nil
|
63
|
+
end
|
64
|
+
|
65
|
+
it "does not overwrite others" do
|
66
|
+
FooPlugin.new.option(:username).should == 'other'
|
67
|
+
end
|
68
|
+
end
|
29
69
|
end
|
30
70
|
|
31
71
|
describe :run_plugins do
|