deputy 0.1.23 → 0.1.24

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.23
1
+ 0.1.24
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deputy}
8
- s.version = "0.1.23"
8
+ s.version = "0.1.24"
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"]
@@ -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.map{|const| const_get(const) }
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| container.const_get(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
@@ -37,7 +37,20 @@ describe Deputy do
37
37
  end
38
38
 
39
39
  def klass(name, options={})
40
- "class TEMP_#{options[:rand]||rand(11111)};def self.interval;60;end;class #{name} < Scout::Plugin; def build_report; #{options[:code]}; end; end; end"
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 "reprots non-plugins" do
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 23
9
- version: 0.1.23
8
+ - 24
9
+ version: 0.1.24
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser