pump 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/pump/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pump
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/pump/xml/tag.rb CHANGED
@@ -44,7 +44,7 @@ module Pump
44
44
  end
45
45
 
46
46
  def value_and_close_tag_with_blank_check
47
- "#{blank_check} ? #{close_blank_tag} : \"#{value_and_close_tag('v')}\""
47
+ "v.nil? ? \"/>\n\" : \"#{value_and_close_tag('v')}\""
48
48
  end
49
49
 
50
50
  def attributes_string
@@ -58,18 +58,6 @@ module Pump
58
58
  "\#{\" nil=\\\"true\\\"\" if v.nil?}" if options[:nil_check]
59
59
  end
60
60
 
61
- def blank_check
62
- if respond_to?(:blank?)
63
- "v.blank?"
64
- else
65
- "v.nil? || v == ''"
66
- end
67
- end
68
-
69
- def close_blank_tag
70
- "\"/>\n\""
71
- end
72
-
73
61
  def condition_start
74
62
  "\#{\"" if conditional?
75
63
  end
@@ -21,7 +21,7 @@ module Pump
21
21
  end
22
22
 
23
23
  def loop_and_close_tag
24
- "\#{ #{objects_path}.empty? ? \" />\n\" : \">\n#{tag_loop}#{tabs}</#{name}>\n\" }"
24
+ "\#{ #{objects_path}.empty? ? \"/>\n\" : \">\n#{tag_loop}#{tabs}</#{name}>\n\" }"
25
25
  end
26
26
 
27
27
  def objects_path
@@ -7,70 +7,4 @@ describe Pump::Xml::Tag do
7
7
  lambda{ Pump::Xml::Tag.new(0) }.should_not raise_error
8
8
  end
9
9
  end
10
-
11
- describe ".to_s" do
12
- context "with value node(s)" do
13
- let(:attributes) { {} }
14
- let(:options) { {} }
15
- subject{ Pump::Xml::Tag.new("tag", attributes, Pump::Xml::Value.new('method'), options).to_s }
16
-
17
- it {should eql(
18
- "<tag\#{v = object.method;''}\#{v.nil? || v == '' ? \"/>\n\" : \">\#{v.to_s.encode(:xml => :text)}</tag>\n\"}"
19
- )}
20
-
21
- context "with :nil_check => true" do
22
- let(:options) { {:nil_check => true} }
23
-
24
- it {should eql(
25
- "<tag\#{v = object.method;''}\#{\" nil=\\\"true\\\"\" if v.nil?}\#{v.nil? || v == '' ? \"/>\n\" : \">\#{v.to_s.encode(:xml => :text)}</tag>\n\"}"
26
- )}
27
- end
28
-
29
- context "with :never_blank => true" do
30
- let(:options) { {:never_blank => true} }
31
-
32
- it {should eql(
33
- "<tag>\#{object.method.to_s.encode(:xml => :text)}</tag>\n"
34
- )}
35
-
36
- context "with attributes" do
37
- let(:attributes) { {:foo => "bar"} }
38
-
39
- it {should eql(
40
- "<tag foo=\\\"bar\\\">\#{object.method.to_s.encode(:xml => :text)}</tag>\n"
41
- )}
42
- end
43
- end
44
-
45
- context "with :skip_encoding => true" do
46
- let(:options) { {:skip_encoding => true} }
47
-
48
- it {should eql(
49
- "<tag\#{v = object.method;''}\#{v.nil? || v == '' ? \"/>\n\" : \">\#{v}</tag>\n\"}"
50
- )}
51
- end
52
-
53
- context "with attributes" do
54
- let(:attributes) { {:foo => "bar"} }
55
-
56
- it {should eql(
57
- "<tag foo=\\\"bar\\\"\#{v = object.method;''}\#{v.nil? || v == '' ? \"/>\n\" : \">\#{v.to_s.encode(:xml => :text)}</tag>\n\"}"
58
- )}
59
- end
60
- end
61
-
62
- context "with other tag child nodes" do
63
- let(:attributes1) { {} }
64
- let(:options1) { {} }
65
- let(:attributes2) { {} }
66
- let(:options2) { {:never_blank => true, :skip_encoding => true} }
67
- let(:tag2) { Pump::Xml::Tag.new("child", attributes2, Pump::Xml::Value.new('method'), options2) }
68
- let(:tag1) { Pump::Xml::Tag.new("root", attributes1, [tag2], options1) }
69
- subject{ tag1.to_s }
70
-
71
- it {should eql(
72
- "<root>\n <child>\#{object.method}</child>\n</root>\n"
73
- )}
74
- end
75
- end
76
10
  end
@@ -44,7 +44,7 @@ describe Pump::Xml do
44
44
  let(:people) { [] }
45
45
 
46
46
  it "returns xml string" do
47
- xml.encode(people).should eql("#{XML_INSTRUCT}<people type=\"array\" />\n")
47
+ xml.encode(people).should eql("#{XML_INSTRUCT}<people type=\"array\"/>\n")
48
48
  end
49
49
  end
50
50
 
@@ -53,7 +53,7 @@ describe Pump::Xml do
53
53
  let(:people) { [] }
54
54
 
55
55
  it "returns xml string" do
56
- xml.encode(people).should eql("<people type=\"array\" />\n")
56
+ xml.encode(people).should eql("<people type=\"array\"/>\n")
57
57
  end
58
58
  end
59
59
 
@@ -109,7 +109,7 @@ describe Pump::Xml do
109
109
  let(:person) { Struct.new(:name, :age).new('', 9) }
110
110
 
111
111
  it do
112
- xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name/>\n</person>\n")
112
+ xml.encode(person).should eql("#{XML_INSTRUCT}<person>\n <name></name>\n</person>\n")
113
113
  end
114
114
  end
115
115
 
data/spec/spec_helper.rb CHANGED
@@ -7,4 +7,6 @@ RSpec.configure do |config|
7
7
  config.run_all_when_everything_filtered = true
8
8
  config.filter_run :focus
9
9
  config.order = 'random'
10
+
11
+ config.backtrace_clean_patterns = [/rspec\/(core|expectations)/]
10
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000 Z
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport