nokogiri-happymapper 0.10.0 → 0.10.1
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/happymapper/anonymous_mapper.rb +1 -0
- data/lib/happymapper/class_methods.rb +7 -26
- data/lib/happymapper/version.rb +1 -1
- data/lib/happymapper.rb +7 -2
- metadata +12 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c2ddd36e3f39dfd51fdfdb4118c2cd3fe029dd145815384806759446e2c87ed
|
|
4
|
+
data.tar.gz: f48845f6496492351a180e93622ed99036ce2a30238a44cef1bb335a7f64a879
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bed47897fd2164b210b57e4a501c48424350db82de9b33992fa48f65377d4cddf51b77dcb353af129ed769dcb0cac506e704fd439a0a283c42b002621dbe910c
|
|
7
|
+
data.tar.gz: e531831bab32cd36eb3aa8471d4d85ae8213a9ecf78ef27cd41ca18087cc3d5782bf0092b6c94f0b03d989f1d7a4ae097e10639107de66bd3447e0e845cd2e91
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.1 / 2025-10-25
|
|
4
|
+
|
|
5
|
+
* Fix namespace prefix collisions ([#231] by [petersen])
|
|
6
|
+
|
|
7
|
+
[petersen]: https://github.com/petersen
|
|
8
|
+
[#231]: https://github.com/mvz/happymapper/pull/231
|
|
9
|
+
|
|
3
10
|
## 0.10.0 / 2024-01-05
|
|
4
11
|
|
|
5
12
|
* Fix typo in README code sample ([#198] by [Spone])
|
|
@@ -289,7 +289,7 @@ module HappyMapper
|
|
|
289
289
|
node = xml.root
|
|
290
290
|
|
|
291
291
|
# merge any namespaces found on the xml node into the namespace hash
|
|
292
|
-
namespaces = namespaces.merge(xml.collect_namespaces)
|
|
292
|
+
namespaces = namespaces.merge(xml.collect_namespaces).merge(node.namespaces)
|
|
293
293
|
|
|
294
294
|
# if the node name is equal to the tag name then the we are parsing the
|
|
295
295
|
# root element and that is important to record so that we can apply
|
|
@@ -372,8 +372,6 @@ module HappyMapper
|
|
|
372
372
|
# when at the root use the xpath '/' otherwise use a more gready './/'
|
|
373
373
|
# unless an xpath has been specified, which should overwrite default
|
|
374
374
|
# and finally attach the current namespace if one has been defined
|
|
375
|
-
#
|
|
376
|
-
|
|
377
375
|
xpath = if options[:xpath]
|
|
378
376
|
options[:xpath].to_s.sub(%r{([^/])$}, '\1/')
|
|
379
377
|
elsif root
|
|
@@ -389,31 +387,14 @@ module HappyMapper
|
|
|
389
387
|
xpath += "#{namespace}:"
|
|
390
388
|
end
|
|
391
389
|
|
|
392
|
-
nodes
|
|
393
|
-
|
|
394
|
-
#
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
# 3. tag_name (derived from class name by default)
|
|
398
|
-
|
|
399
|
-
# If a tag has been provided we need to search for it.
|
|
400
|
-
|
|
401
|
-
if options.key?(:tag)
|
|
402
|
-
nodes = node.xpath(xpath + options[:tag].to_s, namespaces)
|
|
390
|
+
# Find the nodes by the :tag option if given, or by tag_name (derived
|
|
391
|
+
# from the class name by default). If the :tag option is given, the
|
|
392
|
+
# tag_name will not be used.
|
|
393
|
+
if (xpath_ext = options[:tag] || tag_name)
|
|
394
|
+
node.xpath(xpath + xpath_ext.to_s, namespaces)
|
|
403
395
|
else
|
|
404
|
-
|
|
405
|
-
# This is the default case when no tag value is provided.
|
|
406
|
-
# First we use the name of the element `items` in `has_many items`
|
|
407
|
-
# Second we use the tag name which is the name of the class cleaned up
|
|
408
|
-
|
|
409
|
-
[options[:name], tag_name].compact.each do |xpath_ext|
|
|
410
|
-
nodes = node.xpath(xpath + xpath_ext.to_s, namespaces)
|
|
411
|
-
break if nodes && !nodes.empty?
|
|
412
|
-
end
|
|
413
|
-
|
|
396
|
+
[]
|
|
414
397
|
end
|
|
415
|
-
|
|
416
|
-
nodes
|
|
417
398
|
end
|
|
418
399
|
|
|
419
400
|
def parse_node(node, options, namespace, namespaces)
|
data/lib/happymapper/version.rb
CHANGED
data/lib/happymapper.rb
CHANGED
|
@@ -73,7 +73,6 @@ module HappyMapper
|
|
|
73
73
|
#
|
|
74
74
|
def to_xml(builder = nil, default_namespace = nil, namespace_override = nil,
|
|
75
75
|
tag_from_parent = nil)
|
|
76
|
-
|
|
77
76
|
#
|
|
78
77
|
# If to_xml has been called without a passed in builder instance that
|
|
79
78
|
# means we are going to return xml output. When it has been called with
|
|
@@ -152,6 +151,7 @@ module HappyMapper
|
|
|
152
151
|
def self.get(name, &blk)
|
|
153
152
|
Class.new do
|
|
154
153
|
include HappyMapper
|
|
154
|
+
|
|
155
155
|
tag name
|
|
156
156
|
instance_eval(&blk)
|
|
157
157
|
end
|
|
@@ -208,7 +208,12 @@ module HappyMapper
|
|
|
208
208
|
next if value.nil? && !attribute.options[:state_when_nil]
|
|
209
209
|
|
|
210
210
|
attribute_namespace = attribute.options[:namespace]
|
|
211
|
-
|
|
211
|
+
attribute_name = if attribute_namespace
|
|
212
|
+
"#{attribute_namespace}:#{attribute.tag}"
|
|
213
|
+
else
|
|
214
|
+
attribute.tag.to_s
|
|
215
|
+
end
|
|
216
|
+
[attribute_name, value]
|
|
212
217
|
end
|
|
213
218
|
|
|
214
219
|
attributes.to_h
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nokogiri-happymapper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.10.
|
|
4
|
+
version: 0.10.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Damien Le Berrigaud
|
|
@@ -11,10 +11,9 @@ authors:
|
|
|
11
11
|
- Etienne Vallette d'Osia
|
|
12
12
|
- Franklin Webber
|
|
13
13
|
- Matijs van Zuijlen
|
|
14
|
-
autorequire:
|
|
15
14
|
bindir: bin
|
|
16
15
|
cert_chain: []
|
|
17
|
-
date:
|
|
16
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
18
17
|
dependencies:
|
|
19
18
|
- !ruby/object:Gem::Dependency
|
|
20
19
|
name: nokogiri
|
|
@@ -30,20 +29,6 @@ dependencies:
|
|
|
30
29
|
- - "~>"
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
31
|
version: '1.5'
|
|
33
|
-
- !ruby/object:Gem::Dependency
|
|
34
|
-
name: pry
|
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.14.0
|
|
40
|
-
type: :development
|
|
41
|
-
prerelease: false
|
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.14.0
|
|
47
32
|
- !ruby/object:Gem::Dependency
|
|
48
33
|
name: rake
|
|
49
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -92,56 +77,56 @@ dependencies:
|
|
|
92
77
|
requirements:
|
|
93
78
|
- - "~>"
|
|
94
79
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '1.
|
|
80
|
+
version: '1.80'
|
|
96
81
|
type: :development
|
|
97
82
|
prerelease: false
|
|
98
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
84
|
requirements:
|
|
100
85
|
- - "~>"
|
|
101
86
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '1.
|
|
87
|
+
version: '1.80'
|
|
103
88
|
- !ruby/object:Gem::Dependency
|
|
104
89
|
name: rubocop-packaging
|
|
105
90
|
requirement: !ruby/object:Gem::Requirement
|
|
106
91
|
requirements:
|
|
107
92
|
- - "~>"
|
|
108
93
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: 0.
|
|
94
|
+
version: 0.6.0
|
|
110
95
|
type: :development
|
|
111
96
|
prerelease: false
|
|
112
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
98
|
requirements:
|
|
114
99
|
- - "~>"
|
|
115
100
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: 0.
|
|
101
|
+
version: 0.6.0
|
|
117
102
|
- !ruby/object:Gem::Dependency
|
|
118
103
|
name: rubocop-performance
|
|
119
104
|
requirement: !ruby/object:Gem::Requirement
|
|
120
105
|
requirements:
|
|
121
106
|
- - "~>"
|
|
122
107
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: '1.
|
|
108
|
+
version: '1.25'
|
|
124
109
|
type: :development
|
|
125
110
|
prerelease: false
|
|
126
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
112
|
requirements:
|
|
128
113
|
- - "~>"
|
|
129
114
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: '1.
|
|
115
|
+
version: '1.25'
|
|
131
116
|
- !ruby/object:Gem::Dependency
|
|
132
117
|
name: rubocop-rspec
|
|
133
118
|
requirement: !ruby/object:Gem::Requirement
|
|
134
119
|
requirements:
|
|
135
120
|
- - "~>"
|
|
136
121
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '
|
|
122
|
+
version: '3.7'
|
|
138
123
|
type: :development
|
|
139
124
|
prerelease: false
|
|
140
125
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
126
|
requirements:
|
|
142
127
|
- - "~>"
|
|
143
128
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '
|
|
129
|
+
version: '3.7'
|
|
145
130
|
- !ruby/object:Gem::Dependency
|
|
146
131
|
name: simplecov
|
|
147
132
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -162,9 +147,9 @@ email: matijs@matijs.net
|
|
|
162
147
|
executables: []
|
|
163
148
|
extensions: []
|
|
164
149
|
extra_rdoc_files:
|
|
165
|
-
- README.md
|
|
166
150
|
- CHANGELOG.md
|
|
167
151
|
- License
|
|
152
|
+
- README.md
|
|
168
153
|
files:
|
|
169
154
|
- CHANGELOG.md
|
|
170
155
|
- License
|
|
@@ -185,7 +170,6 @@ licenses:
|
|
|
185
170
|
- MIT
|
|
186
171
|
metadata:
|
|
187
172
|
rubygems_mfa_required: 'true'
|
|
188
|
-
post_install_message:
|
|
189
173
|
rdoc_options: []
|
|
190
174
|
require_paths:
|
|
191
175
|
- lib
|
|
@@ -200,8 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
200
184
|
- !ruby/object:Gem::Version
|
|
201
185
|
version: '0'
|
|
202
186
|
requirements: []
|
|
203
|
-
rubygems_version: 3.
|
|
204
|
-
signing_key:
|
|
187
|
+
rubygems_version: 3.7.2
|
|
205
188
|
specification_version: 4
|
|
206
189
|
summary: Provides a simple way to map XML to Ruby Objects and back again.
|
|
207
190
|
test_files: []
|