nori 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3e19155f25d041f2c528280d6985a66128069105
4
+ data.tar.gz: a0446834296e76ef56b850fda6d40f455c10bf3f
5
+ SHA512:
6
+ metadata.gz: acdcd81ae0503f8efb3bfbba9975c7c686b3913ca570f7e3b037bd8625517e8be1918e1943223681563222ca6621db655d91423d8f80cd9ad17d979e8d4cf33e
7
+ data.tar.gz: 3e898eedb82cc8d3fe3041f69c3e2879522c9112bddd508da6c704374f652e3ccf05cdab511fa0d2ff881155cad6aee82eacac909af2f058a9ea503dc48b02f4
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ coverage
5
5
  *.gem
6
6
  .bundle
7
7
  Gemfile.lock
8
+ /.idea
@@ -1,3 +1,8 @@
1
+ # 2.2.0 (2013-04-25)
2
+
3
+ * Feature: [#42](https://github.com/savonrb/nori/pull/42) adds the `:delete_namespace_attributes`
4
+ option to remove namespace attributes like `xmlns:*` or `xsi:*`.
5
+
1
6
  # 2.1.0 (2013-04-21)
2
7
 
3
8
  * Feature: Added `Nori.hash_key` and `Nori#find` to work with Hash keys generated by Nori.
@@ -15,10 +15,11 @@ class Nori
15
15
 
16
16
  def initialize(options = {})
17
17
  defaults = {
18
- :strip_namespaces => false,
19
- :convert_tags_to => nil,
20
- :advanced_typecasting => true,
21
- :parser => :nokogiri
18
+ :strip_namespaces => false,
19
+ :delete_namespace_attributes => false,
20
+ :convert_tags_to => nil,
21
+ :advanced_typecasting => true,
22
+ :parser => :nokogiri
22
23
  }
23
24
 
24
25
  validate_options! defaults.keys, options.keys
@@ -1,5 +1,5 @@
1
1
  class Nori
2
2
 
3
- VERSION = "2.1.0"
3
+ VERSION = "2.2.0"
4
4
 
5
5
  end
@@ -101,6 +101,7 @@ class Nori
101
101
  @nil_element = attributes.delete(key) == "true"
102
102
  attributes.delete("xmlns:#{result[2]}") if result[1]
103
103
  end
104
+ attributes.delete(key) if @options[:delete_namespace_attributes] && key[/^(xmlns|xsi)/]
104
105
  end
105
106
  @attributes = undasherize_keys(attributes)
106
107
  @children = []
@@ -126,6 +126,34 @@ describe Nori do
126
126
  end
127
127
  end
128
128
 
129
+ context "#parse without :delete_namespace_attributes" do
130
+ it "can be changed to not delete xmlns attributes" do
131
+ xml = '<userResponse xmlns="http://schema.company.com/some/path/to/namespace/v1"><accountStatus>active</accountStatus></userResponse>'
132
+ hash = nori(:delete_namespace_attributes => false).parse(xml)
133
+ hash.should == {"userResponse" => {"@xmlns" => "http://schema.company.com/some/path/to/namespace/v1", "accountStatus" => "active"}}
134
+ end
135
+
136
+ it "can be changed to not delete xsi attributes" do
137
+ xml = '<userResponse xsi="abc:myType"><accountStatus>active</accountStatus></userResponse>'
138
+ hash = nori(:delete_namespace_attributes => false).parse(xml)
139
+ hash.should == {"userResponse" => {"@xsi" => "abc:myType", "accountStatus" => "active"}}
140
+ end
141
+ end
142
+
143
+ context "#parse with :delete_namespace_attributes" do
144
+ it "can be changed to delete xmlns attributes" do
145
+ xml = '<userResponse xmlns="http://schema.company.com/some/path/to/namespace/v1"><accountStatus>active</accountStatus></userResponse>'
146
+ hash = nori(:delete_namespace_attributes => true).parse(xml)
147
+ hash.should == {"userResponse" => {"accountStatus" => "active"}}
148
+ end
149
+
150
+ it "can be changed to delete xsi attributes" do
151
+ xml = '<userResponse xsi="abc:myType"><accountStatus>active</accountStatus></userResponse>'
152
+ hash = nori(:delete_namespace_attributes => true).parse(xml)
153
+ hash.should == {"userResponse" => {"accountStatus" => "active"}}
154
+ end
155
+ end
156
+
129
157
  def nori(options = {})
130
158
  Nori.new(options)
131
159
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nori
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
5
- prerelease:
4
+ version: 2.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Harrington
@@ -11,12 +10,11 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-04-21 00:00:00.000000000 Z
13
+ date: 2013-04-25 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rake
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
19
  - - ~>
22
20
  - !ruby/object:Gem::Version
@@ -24,7 +22,6 @@ dependencies:
24
22
  type: :development
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
26
  - - ~>
30
27
  - !ruby/object:Gem::Version
@@ -32,23 +29,20 @@ dependencies:
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: nokogiri
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - '>='
38
34
  - !ruby/object:Gem::Version
39
35
  version: 1.4.0
40
36
  type: :development
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - '>='
46
41
  - !ruby/object:Gem::Version
47
42
  version: 1.4.0
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: rspec
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
47
  - - ~>
54
48
  - !ruby/object:Gem::Version
@@ -56,7 +50,6 @@ dependencies:
56
50
  type: :development
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
54
  - - ~>
62
55
  - !ruby/object:Gem::Version
@@ -97,33 +90,26 @@ files:
97
90
  - spec/spec_helper.rb
98
91
  homepage: https://github.com/savonrb/nori
99
92
  licenses: []
93
+ metadata: {}
100
94
  post_install_message:
101
95
  rdoc_options: []
102
96
  require_paths:
103
97
  - lib
104
98
  required_ruby_version: !ruby/object:Gem::Requirement
105
- none: false
106
99
  requirements:
107
- - - ! '>='
100
+ - - '>='
108
101
  - !ruby/object:Gem::Version
109
102
  version: '0'
110
- segments:
111
- - 0
112
- hash: 2288822480346077713
113
103
  required_rubygems_version: !ruby/object:Gem::Requirement
114
- none: false
115
104
  requirements:
116
- - - ! '>='
105
+ - - '>='
117
106
  - !ruby/object:Gem::Version
118
107
  version: '0'
119
- segments:
120
- - 0
121
- hash: 2288822480346077713
122
108
  requirements: []
123
109
  rubyforge_project: nori
124
- rubygems_version: 1.8.24
110
+ rubygems_version: 2.0.3
125
111
  signing_key:
126
- specification_version: 3
112
+ specification_version: 4
127
113
  summary: XML to Hash translator
128
114
  test_files:
129
115
  - spec/nori/api_spec.rb