xmlmapper 0.7.2 → 0.7.3

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: b2751c0d13928157eb7e417f96fd379e3bb38a20
4
- data.tar.gz: 6fcbf0cf9ffb20975b4d01b8d6e84e73eddf58b1
3
+ metadata.gz: 8715dbba0c19b07cfea4744aa080a2df0dcc402d
4
+ data.tar.gz: a0d5a5c30764891dc5a4b6d794be191ded65bded
5
5
  SHA512:
6
- metadata.gz: f9acda69db552cdd80c9ec8adce3149f255ba9d8fc5a0c858e44423c7e3c36e099f21fab71960427dd52bbda8eafa9494a4d30744d56302b0cb5abeeffedf71b
7
- data.tar.gz: 8ce8d94c5d2d26e9b0cc4f77ee74250e8cabfa19225ec724b0cb1853d8927181ffda43766c79549ff8f6f19acbb67e3451ecb312ad8154b99878c5bc116f6978
6
+ metadata.gz: 9e1b7bde79d987845bfa44a7e474305206bf724b3a265ce3e11cb24145a5ec426d8039fbbab3121a1fa8509574917f3d1535898b6c5db1a157a5184751b8be71
7
+ data.tar.gz: 98deca942d679ec338f1ee3ac794b8af9c3e6915e82df01c17e1b5847774f5112b333ab39766cb100752e0fa4cdb734782715e5b4b4218ce01886f7ded2707f8
@@ -2,7 +2,11 @@ module XmlMapper
2
2
  class TextNode < Item
3
3
 
4
4
  def find(node, namespace, xpath_options)
5
- yield(node.children.detect{|c| c.text?})
5
+ if node.children.any? {|c| c.text?}
6
+ yield(node)
7
+ else
8
+ yield(nil)
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -1,3 +1,3 @@
1
1
  module XmlMapper
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <textnode>With <!----> Comment</textnode>
@@ -554,7 +554,6 @@ end
554
554
  class DefaultNamespaceCombi
555
555
  include XmlMapper
556
556
 
557
-
558
557
  register_namespace 'bk', "urn:loc.gov:books"
559
558
  register_namespace 'isbn', "urn:ISBN:0-395-36341-6"
560
559
  register_namespace 'p', "urn:loc.gov:people"
@@ -567,6 +566,14 @@ class DefaultNamespaceCombi
567
566
  element :author, String, :namespace => 'p', :tag => "author"
568
567
  end
569
568
 
569
+ class TextNodeWithComment
570
+ include XmlMapper
571
+
572
+ tag 'textnode'
573
+
574
+ content :value, String
575
+ end
576
+
570
577
  describe XmlMapper do
571
578
 
572
579
  describe "being included into another class" do
@@ -1134,4 +1141,13 @@ describe XmlMapper do
1134
1141
  end
1135
1142
  end
1136
1143
 
1144
+ context 'text_node with comments' do
1145
+ it 'returns the full text in the node' do
1146
+ xml = fixture_file('text_node_with_comment.xml')
1147
+ text_node = TextNodeWithComment.parse(xml, single: true)
1148
+
1149
+ expect(text_node.value).to eq "With Comment"
1150
+ end
1151
+ end
1152
+
1137
1153
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmlmapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Le Berrigaud
@@ -90,6 +90,7 @@ files:
90
90
  - spec/fixtures/set_config_options.xml
91
91
  - spec/fixtures/statuses.xml
92
92
  - spec/fixtures/subclass_namespace.xml
93
+ - spec/fixtures/text_node_with_comment.xml
93
94
  - spec/fixtures/unformatted_address.xml
94
95
  - spec/fixtures/wrapper.xml
95
96
  - spec/has_many_empty_array_spec.rb
@@ -162,6 +163,7 @@ test_files:
162
163
  - spec/fixtures/set_config_options.xml
163
164
  - spec/fixtures/statuses.xml
164
165
  - spec/fixtures/subclass_namespace.xml
166
+ - spec/fixtures/text_node_with_comment.xml
165
167
  - spec/fixtures/unformatted_address.xml
166
168
  - spec/fixtures/wrapper.xml
167
169
  - spec/has_many_empty_array_spec.rb