benschwarz-smoke 0.3.11 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/lib/smoke/origin.rb +3 -4
- data/spec/smoke/origin_spec.rb +4 -4
- data/spec/smoke/source/yql_spec.rb +1 -1
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/smoke/origin.rb
CHANGED
@@ -22,15 +22,14 @@ module Smoke
|
|
22
22
|
def output(type = :ruby)
|
23
23
|
prepare!
|
24
24
|
dispatch if respond_to? :dispatch
|
25
|
-
output = (@items.length == 1) ? @items.first : @items
|
26
25
|
|
27
26
|
case type
|
28
27
|
when :json
|
29
|
-
return ::JSON.generate(
|
28
|
+
return ::JSON.generate(@items)
|
30
29
|
when :yaml
|
31
|
-
return YAML.dump(
|
30
|
+
return YAML.dump(@items)
|
32
31
|
else
|
33
|
-
return
|
32
|
+
return @items
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
data/spec/smoke/origin_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe Smoke::Origin do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should output a single hash rather than a hash in an array when there is one item" do
|
27
|
-
Smoke[:test].truncate(1).output.should == {:title => "Kangaroo", :name => "Kelly"}
|
27
|
+
Smoke[:test].truncate(1).output.should == [{:title => "Kangaroo", :name => "Kelly"}]
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -42,7 +42,7 @@ describe Smoke::Origin do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should truncate results given a length" do
|
45
|
-
Smoke[:test].truncate(1).output.should
|
45
|
+
Smoke[:test].truncate(1).output.size.should == 1
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "filtering" do
|
@@ -69,7 +69,7 @@ describe Smoke::Origin do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should only contain items that match" do
|
72
|
-
Smoke[:keep].keep(:head, /^K/).output.should == {:head => "Kangaroo", :name => "Kelly"}
|
72
|
+
Smoke[:keep].keep(:head, /^K/).output.should == [{:head => "Kangaroo", :name => "Kelly"}]
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should discard items" do
|
@@ -77,7 +77,7 @@ describe Smoke::Origin do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should not contain items that match" do
|
80
|
-
Smoke[:discard].discard(:head, /^K/).output.should == {:head => "Platypus", :name => "Peter"}
|
80
|
+
Smoke[:discard].discard(:head, /^K/).output.should == [{:head => "Platypus", :name => "Peter"}]
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|