fiveruns-dash-ruby 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fiveruns/dash/configuration.rb +18 -3
- data/lib/fiveruns/dash/recipe.rb +10 -2
- data/test/recipe_test.rb +14 -0
- data/version.yml +1 -1
- metadata +2 -2
@@ -66,12 +66,13 @@ module Fiveruns::Dash
|
|
66
66
|
# add_recipe :ruby
|
67
67
|
def add_recipe(name, options = {}, &block)
|
68
68
|
Fiveruns::Dash.register_recipe(name, options, &block) if block_given?
|
69
|
-
|
70
69
|
if Fiveruns::Dash.recipes[name]
|
71
70
|
Fiveruns::Dash.recipes[name].each do |recipe|
|
72
71
|
if !recipes.include?(recipe) && recipe.matches?(options)
|
73
72
|
recipes << recipe
|
74
|
-
|
73
|
+
with_recipe_settings(options.reject { |k, _| k == :url }) do
|
74
|
+
recipe.add_to(self)
|
75
|
+
end
|
75
76
|
end
|
76
77
|
end
|
77
78
|
else
|
@@ -90,13 +91,27 @@ module Fiveruns::Dash
|
|
90
91
|
|
91
92
|
# Optionally fired by recipes when included
|
92
93
|
def added
|
93
|
-
yield
|
94
|
+
yield current_recipe_settings
|
94
95
|
end
|
95
96
|
|
96
97
|
#######
|
97
98
|
private
|
98
99
|
#######
|
99
100
|
|
101
|
+
def with_recipe_settings(settings = {})
|
102
|
+
recipe_settings_stack << settings
|
103
|
+
yield
|
104
|
+
recipe_settings_stack.pop
|
105
|
+
end
|
106
|
+
|
107
|
+
def current_recipe_settings
|
108
|
+
recipe_settings_stack.last
|
109
|
+
end
|
110
|
+
|
111
|
+
def recipe_settings_stack
|
112
|
+
@recipe_settings_stack ||= []
|
113
|
+
end
|
114
|
+
|
100
115
|
def normalize_version_comparator(comparator)
|
101
116
|
comparator.to_s == '=' ? '==' : comparator
|
102
117
|
end
|
data/lib/fiveruns/dash/recipe.rb
CHANGED
@@ -28,13 +28,21 @@ module Fiveruns::Dash
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def add_to(configuration)
|
31
|
-
self.class.in_scope
|
31
|
+
self.class.in_scope(self) do
|
32
32
|
@block.call(configuration)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
# Currently :url is the only criteria; all other parts
|
37
|
+
# of the hash are settings to be passed on to the recipe
|
36
38
|
def matches?(criteria)
|
37
|
-
criteria.all?
|
39
|
+
criteria.all? do |k, v|
|
40
|
+
if [:url].include?(k)
|
41
|
+
options[k] == v
|
42
|
+
else
|
43
|
+
true
|
44
|
+
end
|
45
|
+
end
|
38
46
|
end
|
39
47
|
|
40
48
|
def ==(other)
|
data/test/recipe_test.rb
CHANGED
@@ -79,6 +79,20 @@ class RecipeTest < Test::Unit::TestCase
|
|
79
79
|
assert_metrics(*%w(test2))
|
80
80
|
end
|
81
81
|
end
|
82
|
+
context "and passing settings" do
|
83
|
+
setup do
|
84
|
+
recipe :settings1, :url => 'http://example.com' do |r|
|
85
|
+
r.added do |settings|
|
86
|
+
r.counter(settings[:metric]) { }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
config.add_recipe :settings1, :metric => :bar
|
90
|
+
end
|
91
|
+
should "pass them to the `added' block" do
|
92
|
+
assert_equal 1, config.metrics.size
|
93
|
+
assert_equal 'bar', config.metrics.first.name
|
94
|
+
end
|
95
|
+
end
|
82
96
|
end
|
83
97
|
|
84
98
|
context "when added" do
|
data/version.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiveruns-dash-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FiveRuns Development Team
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-18 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|