nori 2.7.1 → 2.8.0

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.
@@ -1,19 +0,0 @@
1
- // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
- // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
- {
4
- "name": "Ruby",
5
- // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
- "image": "mcr.microsoft.com/devcontainers/ruby:0-3-bullseye"
7
-
8
- // Features to add to the dev container. More info: https://containers.dev/features.
9
- // "features": {},
10
-
11
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
12
- // "forwardPorts": [],
13
-
14
- // Configure tool-specific properties.
15
- // "customizations": {},
16
-
17
- // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
18
- // "remoteUser": "root"
19
- }
@@ -1,12 +0,0 @@
1
- # To get started with Dependabot version updates, you'll need to specify which
2
- # package ecosystems to update and where the package manifests are located.
3
- # Please see the documentation for more information:
4
- # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
- # https://containers.dev/guide/dependabot
6
-
7
- version: 2
8
- updates:
9
- - package-ecosystem: "devcontainers"
10
- directory: "/"
11
- schedule:
12
- interval: weekly
@@ -1,26 +0,0 @@
1
- name: CI
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
-
9
- strategy:
10
- matrix:
11
- ruby-version:
12
- - '3.0'
13
- - '3.1'
14
- - '3.2'
15
- - '3.3'
16
- - 'head'
17
- - jruby-9.4.5.0
18
- steps:
19
- - uses: actions/checkout@v4
20
- - name: Set up Ruby ${{ matrix.ruby-version }}
21
- uses: ruby/setup-ruby@v1
22
- with:
23
- ruby-version: ${{ matrix.ruby-version }}
24
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
- - name: Run tests
26
- run: bundle exec rake
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- .DS_Store
2
- doc
3
- coverage
4
- *~
5
- *.gem
6
- .bundle
7
- Gemfile.lock
8
- /.idea
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --colour
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- if RUBY_VERSION >= "3"
5
- gem "rexml", "~> 3.2"
6
- end
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
3
- desc "Benchmark Nori parsers"
4
- task :benchmark do
5
- require "benchmark/benchmark"
6
- end
7
-
8
- require "rspec/core/rake_task"
9
- RSpec::Core::RakeTask.new
10
-
11
- task :default => :spec
12
- task :test => :spec
@@ -1,19 +0,0 @@
1
- $:.push File.expand_path("../../lib", __FILE__)
2
- require "nori"
3
-
4
- require "benchmark"
5
-
6
- Benchmark.bm 30 do |x|
7
-
8
- num = 500
9
- xml = File.read File.expand_path("../soap_response.xml", __FILE__)
10
-
11
- x.report "rexml parser" do
12
- num.times { Nori.new(parser: :rexml).parse xml }
13
- end
14
-
15
- x.report "nokogiri parser" do
16
- num.times { Nori.new(parser: :nokogiri).parse xml }
17
- end
18
-
19
- end
@@ -1,266 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
- <soap:Body>
4
- <GetICB_9_2_4_DestInfoWithDestIdResponse xmlns="http://airline.com/">
5
- <GetICB_9_2_4_DestInfoWithDestIdResult>
6
- <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
7
- <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="CL_9_2_4_DestInfo" msdata:UseCurrentLocale="true">
8
- <xs:complexType>
9
- <xs:choice minOccurs="0" maxOccurs="unbounded">
10
- <xs:element name="CL_9_2_4_DestInfo">
11
- <xs:complexType>
12
- <xs:sequence>
13
- <xs:element name="DESTINATION" minOccurs="0">
14
- <xs:simpleType>
15
- <xs:restriction base="xs:string">
16
- <xs:maxLength value="64" />
17
- </xs:restriction>
18
- </xs:simpleType>
19
- </xs:element>
20
- <xs:element name="COUNTRY" minOccurs="0">
21
- <xs:simpleType>
22
- <xs:restriction base="xs:string">
23
- <xs:maxLength value="50" />
24
- </xs:restriction>
25
- </xs:simpleType>
26
- </xs:element>
27
- <xs:element name="AIRPORTNAME" minOccurs="0">
28
- <xs:simpleType>
29
- <xs:restriction base="xs:string">
30
- <xs:maxLength value="70" />
31
- </xs:restriction>
32
- </xs:simpleType>
33
- </xs:element>
34
- <xs:element name="DISTANCE_APT_CTY" minOccurs="0">
35
- <xs:simpleType>
36
- <xs:restriction base="xs:string">
37
- <xs:maxLength value="50" />
38
- </xs:restriction>
39
- </xs:simpleType>
40
- </xs:element>
41
- <xs:element name="TRANSPORT_APT_CTY" minOccurs="0">
42
- <xs:simpleType>
43
- <xs:restriction base="xs:string">
44
- <xs:maxLength value="50" />
45
- </xs:restriction>
46
- </xs:simpleType>
47
- </xs:element>
48
- <xs:element name="REVCABIN" minOccurs="0">
49
- <xs:simpleType>
50
- <xs:restriction base="xs:string">
51
- <xs:maxLength value="50" />
52
- </xs:restriction>
53
- </xs:simpleType>
54
- </xs:element>
55
- <xs:element name="REVCOCKPIT" minOccurs="0">
56
- <xs:simpleType>
57
- <xs:restriction base="xs:string">
58
- <xs:maxLength value="50" />
59
- </xs:restriction>
60
- </xs:simpleType>
61
- </xs:element>
62
- <xs:element name="GROUPTEXT" minOccurs="0">
63
- <xs:simpleType>
64
- <xs:restriction base="xs:string">
65
- <xs:maxLength value="50" />
66
- </xs:restriction>
67
- </xs:simpleType>
68
- </xs:element>
69
- <xs:element name="SORT" type="xs:decimal" minOccurs="0" />
70
- <xs:element name="HEADING" minOccurs="0">
71
- <xs:simpleType>
72
- <xs:restriction base="xs:string">
73
- <xs:maxLength value="30" />
74
- </xs:restriction>
75
- </xs:simpleType>
76
- </xs:element>
77
- <xs:element name="VISIBLE" type="xs:decimal" minOccurs="0" />
78
- <xs:element name="SORT1" type="xs:decimal" minOccurs="0" />
79
- <xs:element name="ITEMSORT" type="xs:decimal" minOccurs="0" />
80
- <xs:element name="AUSWAHLTEXT" minOccurs="0">
81
- <xs:simpleType>
82
- <xs:restriction base="xs:string">
83
- <xs:maxLength value="255" />
84
- </xs:restriction>
85
- </xs:simpleType>
86
- </xs:element>
87
- <xs:element name="REVDATE" type="xs:dateTime" minOccurs="0" />
88
- <xs:element name="CABIN" type="xs:decimal" minOccurs="0" />
89
- <xs:element name="COCKPIT" type="xs:decimal" minOccurs="0" />
90
- <xs:element name="APIATA" minOccurs="0">
91
- <xs:simpleType>
92
- <xs:restriction base="xs:string">
93
- <xs:maxLength value="3" />
94
- </xs:restriction>
95
- </xs:simpleType>
96
- </xs:element>
97
- </xs:sequence>
98
- </xs:complexType>
99
- </xs:element>
100
- </xs:choice>
101
- </xs:complexType>
102
- </xs:element>
103
- </xs:schema>
104
- <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
105
- <DocumentElement xmlns="">
106
- <CL_9_2_4_DestInfo diffgr:id="CL_9_2_4_DestInfo1" msdata:rowOrder="0">
107
- <DESTINATION>PALMA DE MALLORCA</DESTINATION>
108
- <COUNTRY>Spain Schengen</COUNTRY>
109
- <AIRPORTNAME>Son San Juan</AIRPORTNAME>
110
- <DISTANCE_APT_CTY>11 km</DISTANCE_APT_CTY>
111
- <REVCABIN>08.02.10</REVCABIN>
112
- <REVCOCKPIT>08.02.10</REVCOCKPIT>
113
- <GROUPTEXT>Passengers</GROUPTEXT>
114
- <SORT>1</SORT>
115
- <HEADING>Disembarking:</HEADING>
116
- <VISIBLE>-1</VISIBLE>
117
- <SORT1>2</SORT1>
118
- <ITEMSORT>0</ITEMSORT>
119
- <AUSWAHLTEXT>Baby buggies are delivered at aircraft door or stairs.</AUSWAHLTEXT>
120
- <REVDATE>2008-09-01T00:00:00+02:00</REVDATE>
121
- <CABIN>-1</CABIN>
122
- <COCKPIT>0</COCKPIT>
123
- <APIATA>PMI</APIATA>
124
- </CL_9_2_4_DestInfo>
125
- <CL_9_2_4_DestInfo diffgr:id="CL_9_2_4_DestInfo2" msdata:rowOrder="1">
126
- <DESTINATION>PALMA DE MALLORCA</DESTINATION>
127
- <COUNTRY>Spain Schengen</COUNTRY>
128
- <AIRPORTNAME>Son San Juan</AIRPORTNAME>
129
- <DISTANCE_APT_CTY>11 km</DISTANCE_APT_CTY>
130
- <REVCABIN>08.02.10</REVCABIN>
131
- <REVCOCKPIT>08.02.10</REVCOCKPIT>
132
- <GROUPTEXT>Aircraft</GROUPTEXT>
133
- <SORT>2</SORT>
134
- <HEADING>Turnaround:</HEADING>
135
- <VISIBLE>-1</VISIBLE>
136
- <SORT1>5.30</SORT1>
137
- <ITEMSORT>0</ITEMSORT>
138
- <AUSWAHLTEXT>Station applies EST process.</AUSWAHLTEXT>
139
- <REVDATE>2009-05-05T00:00:00+02:00</REVDATE>
140
- <CABIN>-1</CABIN>
141
- <COCKPIT>-1</COCKPIT>
142
- <APIATA>PMI</APIATA>
143
- </CL_9_2_4_DestInfo>
144
- <CL_9_2_4_DestInfo diffgr:id="CL_9_2_4_DestInfo3" msdata:rowOrder="2">
145
- <DESTINATION>PALMA DE MALLORCA</DESTINATION>
146
- <COUNTRY>Spain Schengen</COUNTRY>
147
- <AIRPORTNAME>Son San Juan</AIRPORTNAME>
148
- <DISTANCE_APT_CTY>11 km</DISTANCE_APT_CTY>
149
- <REVCABIN>08.02.10</REVCABIN>
150
- <REVCOCKPIT>08.02.10</REVCOCKPIT>
151
- <GROUPTEXT>General</GROUPTEXT>
152
- <SORT>4</SORT>
153
- <HEADING>Addresses:</HEADING>
154
- <VISIBLE>-1</VISIBLE>
155
- <SORT1>8.50</SORT1>
156
- <ITEMSORT>1</ITEMSORT>
157
- <AUSWAHLTEXT>
158
- Station Manager:
159
- YYYYYYYY XXXXXXX
160
- PMIKXXX
161
- Tel.:+34 971 xxx xxx
162
- Mobile:+ 34 600 46 xx xx
163
- </AUSWAHLTEXT>
164
- <REVDATE>2010-02-08T00:00:00+01:00</REVDATE>
165
- <CABIN>-1</CABIN>
166
- <COCKPIT>-1</COCKPIT>
167
- <APIATA>PMI</APIATA>
168
- </CL_9_2_4_DestInfo>
169
- <CL_9_2_4_DestInfo diffgr:id="CL_9_2_4_DestInfo4" msdata:rowOrder="3">
170
- <DESTINATION>PALMA DE MALLORCA</DESTINATION>
171
- <COUNTRY>Spain Schengen</COUNTRY>
172
- <AIRPORTNAME>Son San Juan</AIRPORTNAME>
173
- <DISTANCE_APT_CTY>11 km</DISTANCE_APT_CTY>
174
- <REVCABIN>08.02.10</REVCABIN>
175
- <REVCOCKPIT>08.02.10</REVCOCKPIT>
176
- <GROUPTEXT>General</GROUPTEXT>
177
- <SORT>4</SORT>
178
- <HEADING>Addresses:</HEADING>
179
- <VISIBLE>-1</VISIBLE>
180
- <SORT1>8.50</SORT1>
181
- <ITEMSORT>2</ITEMSORT>
182
- <AUSWAHLTEXT>
183
- Handling Agent:
184
- xxxxxxx Airport Services
185
- Operations
186
- PMIIxxx
187
- Tel +34 971 xxx xxx
188
- Passenger Services
189
- PMIPXXX
190
- Tel : +34 971 xxx xxx
191
- </AUSWAHLTEXT>
192
- <REVDATE>2010-02-08T00:00:00+01:00</REVDATE>
193
- <CABIN>-1</CABIN>
194
- <COCKPIT>-1</COCKPIT>
195
- <APIATA>PMI</APIATA>
196
- </CL_9_2_4_DestInfo>
197
- <CL_9_2_4_DestInfo diffgr:id="CL_9_2_4_DestInfo5" msdata:rowOrder="4">
198
- <DESTINATION>PALMA DE MALLORCA</DESTINATION>
199
- <COUNTRY>Spain Schengen</COUNTRY>
200
- <AIRPORTNAME>Son San Juan</AIRPORTNAME>
201
- <DISTANCE_APT_CTY>11 km</DISTANCE_APT_CTY>
202
- <REVCABIN>08.02.10</REVCABIN>
203
- <REVCOCKPIT>08.02.10</REVCOCKPIT>
204
- <GROUPTEXT>General</GROUPTEXT>
205
- <SORT>4</SORT>
206
- <HEADING>Announcements:</HEADING>
207
- <VISIBLE>-1</VISIBLE>
208
- <SORT1>11</SORT1>
209
- <ITEMSORT>1</ITEMSORT>
210
- <AUSWAHLTEXT>Prerecorded Spanish announcements available.</AUSWAHLTEXT>
211
- <REVDATE>2009-12-30T00:00:00+01:00</REVDATE>
212
- <CABIN>-1</CABIN>
213
- <COCKPIT>0</COCKPIT>
214
- <APIATA>PMI</APIATA>
215
- </CL_9_2_4_DestInfo>
216
- <CL_9_2_4_DestInfo diffgr:id="CL_9_2_4_DestInfo6" msdata:rowOrder="5">
217
- <DESTINATION>PALMA DE MALLORCA</DESTINATION>
218
- <COUNTRY>Spain Schengen</COUNTRY>
219
- <AIRPORTNAME>Son San Juan</AIRPORTNAME>
220
- <DISTANCE_APT_CTY>11 km</DISTANCE_APT_CTY>
221
- <REVCABIN>08.02.10</REVCABIN>
222
- <REVCOCKPIT>08.02.10</REVCOCKPIT>
223
- <GROUPTEXT>General</GROUPTEXT>
224
- <SORT>4</SORT>
225
- <HEADING>Life jackets / DEMO:</HEADING>
226
- <VISIBLE>-1</VISIBLE>
227
- <SORT1>12</SORT1>
228
- <ITEMSORT>0</ITEMSORT>
229
- <AUSWAHLTEXT>
230
- Infant life jackets to be distributed.
231
- DEMO with life jackets.
232
- </AUSWAHLTEXT>
233
- <REVDATE>2002-07-24T00:00:00+02:00</REVDATE>
234
- <CABIN>-1</CABIN>
235
- <COCKPIT>0</COCKPIT>
236
- <APIATA>PMI</APIATA>
237
- </CL_9_2_4_DestInfo>
238
- <CL_9_2_4_DestInfo diffgr:id="CL_9_2_4_DestInfo7" msdata:rowOrder="6">
239
- <DESTINATION>PALMA DE MALLORCA</DESTINATION>
240
- <COUNTRY>Spain Schengen</COUNTRY>
241
- <AIRPORTNAME>Son San Juan</AIRPORTNAME>
242
- <DISTANCE_APT_CTY>11 km</DISTANCE_APT_CTY>
243
- <REVCABIN>08.02.10</REVCABIN>
244
- <REVCOCKPIT>08.02.10</REVCOCKPIT>
245
- <GROUPTEXT>Catering</GROUPTEXT>
246
- <SORT>5</SORT>
247
- <HEADING>General:</HEADING>
248
- <VISIBLE>0</VISIBLE>
249
- <SORT1>1</SORT1>
250
- <ITEMSORT>1</ITEMSORT>
251
- <AUSWAHLTEXT>
252
- LSG XXX XXXX
253
- Tel.: +34 971 xxx xxx or xxx xxx
254
- Sita: PMIAXXX
255
- </AUSWAHLTEXT>
256
- <REVDATE>2005-06-01T00:00:00+02:00</REVDATE>
257
- <CABIN>-1</CABIN>
258
- <COCKPIT>0</COCKPIT>
259
- <APIATA>PMI</APIATA>
260
- </CL_9_2_4_DestInfo>
261
- </DocumentElement>
262
- </diffgr:diffgram>
263
- </GetICB_9_2_4_DestInfoWithDestIdResult>
264
- </GetICB_9_2_4_DestInfoWithDestIdResponse>
265
- </soap:Body>
266
- </soap:Envelope>
data/nori.gemspec DELETED
@@ -1,29 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "nori/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "nori"
7
- s.version = Nori::VERSION
8
- s.authors = ["Daniel Harrington", "John Nunemaker", "Wynn Netherland"]
9
- s.email = "me@rubiii.com"
10
- s.homepage = "https://github.com/savonrb/nori"
11
- s.summary = "XML to Hash translator"
12
- s.description = s.summary
13
- s.required_ruby_version = '>= 3.0'
14
-
15
- s.license = "MIT"
16
-
17
- s.add_dependency "bigdecimal"
18
-
19
- s.add_development_dependency "rake", "~> 12.3.3"
20
- s.add_development_dependency "nokogiri", ">= 1.4.0"
21
- s.add_development_dependency "rspec", "~> 3.11.0"
22
-
23
- s.metadata["rubygems_mfa_required"] = "true"
24
-
25
- s.files = `git ls-files`.split("\n")
26
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
- s.require_paths = ["lib"]
29
- end
@@ -1,177 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Nori do
4
-
5
- describe "PARSERS" do
6
- it "should return a Hash of parser details" do
7
- expect(Nori::PARSERS).to eq({ :rexml => "REXML", :nokogiri => "Nokogiri" })
8
- end
9
- end
10
-
11
- context ".new" do
12
- it "defaults to not strip any namespace identifiers" do
13
- xml = <<-XML
14
- <history xmlns:ns10="http://ns10.example.com">
15
- <ns10:case>a_case</ns10:case>
16
- </history>
17
- XML
18
-
19
- expect(nori.parse(xml)["history"]["ns10:case"]).to eq("a_case")
20
- end
21
-
22
- it "defaults to not change XML tags" do
23
- xml = '<userResponse id="1"><accountStatus>active</accountStatus></userResponse>'
24
- expect(nori.parse(xml)).to eq({ "userResponse" => { "@id" => "1", "accountStatus" => "active" } })
25
- end
26
-
27
- it "raises when passed unknown global options" do
28
- expect { Nori.new(:invalid => true) }.
29
- to raise_error(ArgumentError, /Spurious options: \[:invalid\]/)
30
- end
31
- end
32
-
33
- context ".new with :strip_namespaces" do
34
- it "strips the namespace identifiers when set to true" do
35
- xml = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"></soap:Envelope>'
36
- expect(nori(:strip_namespaces => true).parse(xml)).to have_key("Envelope")
37
- end
38
-
39
- it "still converts namespaced entries to array elements" do
40
- xml = <<-XML
41
- <history
42
- xmlns:ns10="http://ns10.example.com"
43
- xmlns:ns11="http://ns10.example.com">
44
- <ns10:case><ns10:name>a_name</ns10:name></ns10:case>
45
- <ns11:case><ns11:name>another_name</ns11:name></ns11:case>
46
- </history>
47
- XML
48
-
49
- expected = [{ "name" => "a_name" }, { "name" => "another_name" }]
50
- expect(nori(:strip_namespaces => true).parse(xml)["history"]["case"]).to eq(expected)
51
- end
52
- end
53
-
54
- context ".new with :convert_tags_to" do
55
- it "converts all tags by a given formula" do
56
- xml = '<userResponse id="1"><accountStatus>active</accountStatus></userResponse>'
57
-
58
- snakecase_symbols = lambda { |tag| Nori::StringUtils.snakecase(tag).to_sym }
59
- nori = nori(:convert_tags_to => snakecase_symbols)
60
-
61
- expect(nori.parse(xml)).to eq({ :user_response => { :@id => "1", :account_status => "active" } })
62
- end
63
- end
64
-
65
- context '#find' do
66
- before do
67
- upcase = lambda { |tag| tag.upcase }
68
- @nori = nori(:convert_tags_to => upcase)
69
-
70
- xml = '<userResponse id="1"><accountStatus>active</accountStatus></userResponse>'
71
- @hash = @nori.parse(xml)
72
- end
73
-
74
- it 'returns the Hash when the path is empty' do
75
- result = @nori.find(@hash)
76
- expect(result).to eq("USERRESPONSE" => { "ACCOUNTSTATUS" => "active", "@ID" => "1" })
77
- end
78
-
79
- it 'returns the result for a single key' do
80
- result = @nori.find(@hash, 'userResponse')
81
- expect(result).to eq("ACCOUNTSTATUS" => "active", "@ID" => "1")
82
- end
83
-
84
- it 'returns the result for nested keys' do
85
- result = @nori.find(@hash, 'userResponse', 'accountStatus')
86
- expect(result).to eq("active")
87
- end
88
-
89
- it 'strips the namespaces from Hash keys' do
90
- xml = '<v1:userResponse xmlns:v1="http://example.com"><v1:accountStatus>active</v1:accountStatus></v1:userResponse>'
91
- hash = @nori.parse(xml)
92
-
93
- result = @nori.find(hash, 'userResponse', 'accountStatus')
94
- expect(result).to eq("active")
95
- end
96
- end
97
-
98
- context "#parse" do
99
- it "defaults to use advanced typecasting" do
100
- hash = nori.parse("<value>true</value>")
101
- expect(hash["value"]).to eq(true)
102
- end
103
-
104
- it "defaults to use the Nokogiri parser" do
105
- # parsers are loaded lazily by default
106
- require "nori/parser/nokogiri"
107
-
108
- expect(Nori::Parser::Nokogiri).to receive(:parse).and_return({})
109
- nori.parse("<any>thing</any>")
110
- end
111
- end
112
-
113
- context "#parse without :advanced_typecasting" do
114
- it "can be changed to not typecast too much" do
115
- hash = nori(:advanced_typecasting => false).parse("<value>true</value>")
116
- expect(hash["value"]).to eq("true")
117
- end
118
- end
119
-
120
- context "#parse with :parser" do
121
- it "can be configured to use the REXML parser" do
122
- # parsers are loaded lazily by default
123
- require "nori/parser/rexml"
124
-
125
- expect(Nori::Parser::REXML).to receive(:parse).and_return({})
126
- nori(:parser => :rexml).parse("<any>thing</any>")
127
- end
128
- end
129
-
130
- context "#parse without :delete_namespace_attributes" do
131
- it "can be changed to not delete xmlns attributes" do
132
- xml = '<userResponse xmlns="http://schema.company.com/some/path/to/namespace/v1"><accountStatus>active</accountStatus></userResponse>'
133
- hash = nori(:delete_namespace_attributes => false).parse(xml)
134
- expect(hash).to eq({"userResponse" => {"@xmlns" => "http://schema.company.com/some/path/to/namespace/v1", "accountStatus" => "active"}})
135
- end
136
-
137
- it "can be changed to not delete xsi attributes" do
138
- xml = '<userResponse xsi="abc:myType"><accountStatus>active</accountStatus></userResponse>'
139
- hash = nori(:delete_namespace_attributes => false).parse(xml)
140
- expect(hash).to eq({"userResponse" => {"@xsi" => "abc:myType", "accountStatus" => "active"}})
141
- end
142
- end
143
-
144
- context "#parse with :delete_namespace_attributes" do
145
- it "can be changed to delete xmlns attributes" do
146
- xml = '<userResponse xmlns="http://schema.company.com/some/path/to/namespace/v1"><accountStatus>active</accountStatus></userResponse>'
147
- hash = nori(:delete_namespace_attributes => true).parse(xml)
148
- expect(hash).to eq({"userResponse" => {"accountStatus" => "active"}})
149
- end
150
-
151
- it "can be changed to delete xsi attributes" do
152
- xml = '<userResponse xsi="abc:myType"><accountStatus>active</accountStatus></userResponse>'
153
- hash = nori(:delete_namespace_attributes => true).parse(xml)
154
- expect(hash).to eq({"userResponse" => {"accountStatus" => "active"}})
155
- end
156
- end
157
-
158
- context "#parse with :convert_dashes_to_underscores" do
159
- it "can be configured to skip dash to underscore conversion" do
160
- xml = '<any-tag>foo bar</any-tag>'
161
- hash = nori(:convert_dashes_to_underscores => false).parse(xml)
162
- expect(hash).to eq({'any-tag' => 'foo bar'})
163
- end
164
- end
165
-
166
- context "#parse with :empty_tag_value set to empty string" do
167
- it "can be configured to convert empty tags to given value" do
168
- xml = "<parentTag><tag/></parentTag>"
169
- hash = nori(:empty_tag_value => "").parse(xml)
170
- expect(hash).to eq("parentTag" => { "tag" => "" })
171
- end
172
- end
173
-
174
- def nori(options = {})
175
- Nori.new(options)
176
- end
177
- end
@@ -1,30 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Hash do
4
-
5
- describe "#normalize_param" do
6
- it "should have specs"
7
- end
8
-
9
- describe "#to_xml_attributes" do
10
-
11
- it "should turn the hash into xml attributes" do
12
- attrs = { :one => "ONE", "two" => "TWO" }.to_xml_attributes
13
- expect(attrs).to match(/one="ONE"/m)
14
- expect(attrs).to match(/two="TWO"/m)
15
- end
16
-
17
- it "should preserve _ in hash keys" do
18
- attrs = {
19
- :some_long_attribute => "with short value",
20
- :crash => :burn,
21
- :merb => "uses extlib"
22
- }.to_xml_attributes
23
-
24
- expect(attrs).to match(/some_long_attribute="with short value"/)
25
- expect(attrs).to match(/merb="uses extlib"/)
26
- expect(attrs).to match(/crash="burn"/)
27
- end
28
- end
29
-
30
- end