deputy 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.11
data/deputy.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deputy}
8
- s.version = "0.1.10"
8
+ s.version = "0.1.11"
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"]
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(*args)
22
- nil
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 10
9
- version: 0.1.10
8
+ - 11
9
+ version: 0.1.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser