deputy 0.1.23 → 0.1.24
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 +3 -2
- data/spec/deputy_spec.rb +23 -3
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.24
|
data/deputy.gemspec
CHANGED
data/lib/deputy.rb
CHANGED
@@ -6,7 +6,8 @@ def eval_and_fetch_constants(x)
|
|
6
6
|
old = Module.constants.map{|c| c.to_s}
|
7
7
|
eval(x)
|
8
8
|
new = (Module.constants.map{|c| c.to_s} - old)
|
9
|
-
new.
|
9
|
+
new = new.select{|c| c.to_s =~ /^TEMP/ } # do not fetch required libs, just user-defined
|
10
|
+
new.map{|c| const_get(c) }
|
10
11
|
end
|
11
12
|
|
12
13
|
class Scout
|
@@ -75,7 +76,7 @@ class Scout
|
|
75
76
|
end
|
76
77
|
|
77
78
|
def self.plugin_in_container(container)
|
78
|
-
constants = container.constants.map{|constant_name|
|
79
|
+
constants = container.constants.map{|constant_name|container.const_get(constant_name)}
|
79
80
|
constants.detect{|c| c.instance_methods.map{|m| m.to_s}.include?('build_report') }
|
80
81
|
end
|
81
82
|
end
|
data/spec/deputy_spec.rb
CHANGED
@@ -37,7 +37,20 @@ describe Deputy do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def klass(name, options={})
|
40
|
-
|
40
|
+
<<-CODE
|
41
|
+
module TEMP_#{options[:rand]||rand(11111)}
|
42
|
+
def self.interval
|
43
|
+
60
|
44
|
+
end
|
45
|
+
|
46
|
+
class #{name} < Scout::Plugin
|
47
|
+
#{options[:class_eval]}
|
48
|
+
def build_report
|
49
|
+
#{options[:code]}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
CODE
|
41
54
|
end
|
42
55
|
|
43
56
|
describe Scout do
|
@@ -46,9 +59,9 @@ describe Deputy do
|
|
46
59
|
Scout.plugins(klass('A', :rand => 1111)).inspect.should == '[[60, TEMP_1111::A]]'
|
47
60
|
end
|
48
61
|
|
49
|
-
it "
|
62
|
+
it "reports non-plugins" do
|
50
63
|
Deputy.should_receive(:send_report)
|
51
|
-
Scout.plugins("class Foo;def self.interval;11;end;end").inspect.should == '[]'
|
64
|
+
Scout.plugins("module TEMP_XXX;def self.interval;60;end;class Foo;def self.interval;11;end;end;end").inspect.should == '[]'
|
52
65
|
end
|
53
66
|
end
|
54
67
|
|
@@ -116,6 +129,13 @@ describe Deputy do
|
|
116
129
|
FooPlugin.new.send(:memory, :asdsa).should == nil
|
117
130
|
end
|
118
131
|
end
|
132
|
+
|
133
|
+
describe :needs do
|
134
|
+
it "can create plugins with needs" do
|
135
|
+
Scout.plugins(klass('D', :class_eval => "needs 'fastercsv'", :rand => 1112)).inspect.should == '[[60, TEMP_1112::D]]'
|
136
|
+
defined?(FasterCSV).should == "constant"
|
137
|
+
end
|
138
|
+
end
|
119
139
|
end
|
120
140
|
|
121
141
|
describe :run_plugins do
|