saxerator 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0cafde22b9761403aa299dcc6600e6905340929
|
4
|
+
data.tar.gz: 045107a2d6e516c20b179d868cc1c32d1e01a664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e700487f042456f67b269e98c872aa4e91a9116f66abb11fe1d28b7569ddefeef14498b74131b05c799ca17a8bf4068704b229798e106a634453ead7052df93c
|
7
|
+
data.tar.gz: 0f6ba9c8758489f4315027e0878ba0d27f19a0985bb0ad8a24d3a6178f62b72be0c7e88553b86934585732000bee213343d4b4b71a3042f3dad3053493986520
|
@@ -35,7 +35,6 @@ module Saxerator
|
|
35
35
|
end
|
36
36
|
|
37
37
|
if @config.put_attributes_in_hash?
|
38
|
-
|
39
38
|
@attributes.each do |attribute|
|
40
39
|
attribute.each_slice(2) do |name, element|
|
41
40
|
add_to_hash_element(hash, name, element)
|
@@ -61,7 +60,7 @@ module Saxerator
|
|
61
60
|
|
62
61
|
def block_variable
|
63
62
|
return to_s if @text
|
64
|
-
return to_hash if @children.count > 0
|
63
|
+
return to_hash if @children.count > 0 || (@attributes.count > 0 && @config.put_attributes_in_hash?)
|
65
64
|
to_empty_element
|
66
65
|
end
|
67
66
|
end
|
data/lib/saxerator/version.rb
CHANGED
@@ -26,6 +26,18 @@ describe "Saxerator (default) hash format" do
|
|
26
26
|
# name on a string
|
27
27
|
specify { entry['title'].name.should == 'title' }
|
28
28
|
|
29
|
+
describe "#to_s" do
|
30
|
+
it "preserves the element name" do
|
31
|
+
entry['title'].to_a.name.should == 'title'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#to_h" do
|
36
|
+
it "preserves the element name" do
|
37
|
+
entry.to_h.name.should == 'entry'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
29
41
|
describe "#to_a" do
|
30
42
|
it "preserves the element name on a parsed hash" do
|
31
43
|
entry.to_a.name.should == 'entry'
|
@@ -50,7 +62,6 @@ describe "Saxerator (default) hash format" do
|
|
50
62
|
# character entity decoding
|
51
63
|
specify { entry['content'].should == "<p>Airplanes are very large — this can present difficulty in digestion.</p>" }
|
52
64
|
|
53
|
-
# empty element
|
54
65
|
context "parsing an empty element" do
|
55
66
|
subject(:element) { entry['media:thumbnail'] }
|
56
67
|
|
data/spec/lib/dsl/all_spec.rb
CHANGED
@@ -10,22 +10,22 @@ describe "Saxerator::FullDocument#all" do
|
|
10
10
|
<blurb>two</blurb>
|
11
11
|
<blurb>three</blurb>
|
12
12
|
<notablurb>four</notablurb>
|
13
|
+
<empty with="attribute"/>
|
13
14
|
</blurbs>
|
14
15
|
eos
|
15
16
|
end
|
16
17
|
|
17
18
|
it "should allow you to parse an entire document" do
|
18
|
-
parser.all.should == {'blurb' => ['one', 'two', 'three'], 'notablurb' => 'four'}
|
19
|
+
parser.all.should == {'blurb' => ['one', 'two', 'three'], 'notablurb' => 'four', 'empty' => {} }
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
context "with_put_attributes_in_hash" do
|
22
23
|
subject(:parser) do
|
23
24
|
Saxerator.parser(xml) { |config| config.put_attributes_in_hash! }
|
24
25
|
end
|
25
|
-
|
26
|
+
|
26
27
|
it "should allow you to parse an entire document" do
|
27
|
-
parser.all.should == {'blurb' => ['one', 'two', 'three'], 'notablurb' => 'four'}
|
28
|
+
parser.all.should == {'blurb' => ['one', 'two', 'three'], 'notablurb' => 'four', 'empty' => { "with" => "attribute"}}
|
28
29
|
end
|
29
30
|
end
|
30
|
-
|
31
|
-
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saxerator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bradley Schaefer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|