smoke 0.5.10 → 0.5.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.yml +1 -1
- data/lib/smoke/source/join.rb +23 -0
- data/spec/smoke/source/join_spec.rb +44 -3
- metadata +3 -3
data/VERSION.yml
CHANGED
data/lib/smoke/source/join.rb
CHANGED
@@ -14,6 +14,28 @@ module Smoke
|
|
14
14
|
super((names << "joined").join("_").to_sym, &block)
|
15
15
|
end
|
16
16
|
|
17
|
+
# Rename sources immediately after they've been joined together
|
18
|
+
# Usage:
|
19
|
+
# Smoke.join(:delicious, :twitter, :flickr) do
|
20
|
+
# name :web_stream
|
21
|
+
# end
|
22
|
+
def name(rename = nil)
|
23
|
+
return @name if rename.nil?
|
24
|
+
Smoke.rename(@name => rename)
|
25
|
+
end
|
26
|
+
|
27
|
+
def method_missing(symbol, *args, &block)
|
28
|
+
ivar = "@#{symbol}"
|
29
|
+
|
30
|
+
unless args.empty?
|
31
|
+
sources.each do |source|
|
32
|
+
source.last.instance_variable_set(ivar, args.pop)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
return self
|
37
|
+
end
|
38
|
+
|
17
39
|
protected
|
18
40
|
def sources
|
19
41
|
Smoke.active_sources.find_all{|k, v| @names.include?(k) }
|
@@ -22,6 +44,7 @@ module Smoke
|
|
22
44
|
def dispatch
|
23
45
|
# Recall dispatch
|
24
46
|
sources.each do |source|
|
47
|
+
source.last.send(:prepare!)
|
25
48
|
source.last.send(:dispatch) if source.last.respond_to?(:dispatch)
|
26
49
|
end
|
27
50
|
|
@@ -11,9 +11,7 @@ describe "Join" do
|
|
11
11
|
before do
|
12
12
|
@source = Smoke.join(:a, :b)
|
13
13
|
end
|
14
|
-
|
15
|
-
# it_should_behave_like "all sources"
|
16
|
-
|
14
|
+
|
17
15
|
it "should be named in a_b_joined" do
|
18
16
|
Smoke[:a_b_joined].should be_an_instance_of(Smoke::Source::Join)
|
19
17
|
end
|
@@ -34,6 +32,20 @@ describe "Join" do
|
|
34
32
|
Smoke[:a_b_joined].should respond_to(:output)
|
35
33
|
end
|
36
34
|
|
35
|
+
describe "renaming, within a block" do
|
36
|
+
it "should respond to name" do
|
37
|
+
Smoke[:a_b_joined].should respond_to(:name)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should rename the source" do
|
41
|
+
Smoke.join(:b, :c) do
|
42
|
+
name :bee_and_cee
|
43
|
+
end
|
44
|
+
|
45
|
+
Smoke[:bee_and_cee].should_not be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
37
49
|
describe "dispatching" do
|
38
50
|
before :all do
|
39
51
|
FakeWeb.register_uri("http://photos.tld", :response => File.join(SPEC_DIR, 'supports', 'flickr-photo.json'))
|
@@ -48,6 +60,35 @@ describe "Join" do
|
|
48
60
|
Smoke[:should_dispatch].should_receive(:dispatch)
|
49
61
|
Smoke.join(:a, :should_dispatch).output
|
50
62
|
end
|
63
|
+
|
64
|
+
it "should call prepare blocks before dispatching" do
|
65
|
+
Smoke.data(:prepare_dispatch) do
|
66
|
+
prepare do
|
67
|
+
url "http://photos.tld"
|
68
|
+
end
|
69
|
+
|
70
|
+
path :photos, :photo
|
71
|
+
end
|
72
|
+
|
73
|
+
Smoke.join(:prepare_dispatch) do
|
74
|
+
name :always_be_prepared
|
75
|
+
end
|
76
|
+
|
77
|
+
lambda { Smoke.always_be_prepared.output }.should_not raise_error(ArgumentError)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "variable injection" do
|
82
|
+
before :all do
|
83
|
+
TestSource.source :variable
|
84
|
+
TestSource.source :injection
|
85
|
+
Smoke.join(:variable, :injection)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should inject variables to its source items" do
|
89
|
+
Smoke.variable_injection_joined.some_ivar("value")
|
90
|
+
Smoke.variable.some_ivar.should == "value"
|
91
|
+
end
|
51
92
|
end
|
52
93
|
end
|
53
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smoke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Schwarz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-18 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
requirements: []
|
161
161
|
|
162
162
|
rubyforge_project:
|
163
|
-
rubygems_version: 1.3.
|
163
|
+
rubygems_version: 1.3.2
|
164
164
|
signing_key:
|
165
165
|
specification_version: 3
|
166
166
|
summary: smoke is a Ruby based DSL that allows you to query web services such as YQL, RSS / Atom and JSON or XML in an elegant manner.
|