saxerator 0.9.3 → 0.9.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3275996c0843e22e1ef7148b6fc14c58aff415d
4
- data.tar.gz: bd4ea2b9abb8c9ad8cea065c7d2c41fd472df4e7
3
+ metadata.gz: a0cafde22b9761403aa299dcc6600e6905340929
4
+ data.tar.gz: 045107a2d6e516c20b179d868cc1c32d1e01a664
5
5
  SHA512:
6
- metadata.gz: 5891cd6b524b6880717f21c59552dd909f73ec3135439aaafc79e90dcf76a4a30d774c1b12ad14ebf7b395d7cff6a1c2e3a049bb958ab03d0b681d06092d1b15
7
- data.tar.gz: 82f8257eeaedf4b4942979aa961dcd4574f7c4320fd821697fbea25bc1926064bad3f5fd5cbc176382443d81fb69a79d9c323fd1fc87263c713b6b35a44e8e34
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
@@ -17,6 +17,8 @@ module Saxerator
17
17
  array.concat super
18
18
  array
19
19
  end
20
+
21
+ def to_h; self end
20
22
  end
21
23
  end
22
24
  end
@@ -1,3 +1,3 @@
1
1
  module Saxerator
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -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
 
@@ -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.3
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-04-01 00:00:00.000000000 Z
11
+ date: 2014-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri