nori 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nori might be problematic. Click here for more details.
- data/CHANGELOG.md +71 -17
- data/lib/nori/version.rb +1 -1
- data/lib/nori/xml_utility_node.rb +24 -3
- data/spec/nori/nori_spec.rb +4 -0
- metadata +21 -21
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,58 @@
|
|
1
|
-
|
1
|
+
## 2.0.0 (UPCOMING)
|
2
|
+
|
3
|
+
* Major change: Removed attributes from values and moved them to `Object#xml_attributes`.
|
4
|
+
Even though I don't like extending Object, this change solves a lot of problems and confusion
|
5
|
+
with XML attributes and values.
|
6
|
+
|
7
|
+
``` xml
|
8
|
+
<Contact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
9
|
+
<Name xsi:type="xsd:string">Some name in here</Name>
|
10
|
+
<Address xsi:nil="true"></Address>
|
11
|
+
</Contact>
|
12
|
+
```
|
13
|
+
|
14
|
+
What you got before this change was the "Name" without the attribute
|
15
|
+
and the `xsi` attribute from the "Contact" node prefixed with an @.
|
16
|
+
|
17
|
+
``` ruby
|
18
|
+
old = {
|
19
|
+
"Contact" => {
|
20
|
+
"Name" => "Some name in here",
|
21
|
+
"Address" => nil,
|
22
|
+
"@xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
```
|
26
|
+
|
27
|
+
What you get now, is this:
|
28
|
+
|
29
|
+
``` ruby
|
30
|
+
new = {
|
31
|
+
"Contact" => {
|
32
|
+
"Name" => "Some name in here",
|
33
|
+
"Address" => nil
|
34
|
+
}
|
35
|
+
}
|
36
|
+
```
|
37
|
+
|
38
|
+
No namespaces in your Hashes. If you need to access the attributes of node,
|
39
|
+
they are now stored on the nodes value.
|
40
|
+
|
41
|
+
``` ruby
|
42
|
+
new["Contact"].xml_attributes # => { "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance" }
|
43
|
+
new["Contact"]["Name"].xml_attributes # => { "xsi:type" => "xsd:string" }
|
44
|
+
```
|
45
|
+
|
46
|
+
## 1.1.2 (2012-02-30)
|
47
|
+
|
48
|
+
* Fix: Reverted `Object#xml_attributes` feature which is planned for version 2.0.
|
49
|
+
|
50
|
+
## 1.1.1 (2012-02-29) - yanked
|
51
|
+
|
52
|
+
* Fix: Merged [pull request 17](https://github.com/rubiii/nori/pull/17) for improved
|
53
|
+
xs:time/xs:date/xs:dateTime regular expression matchers.
|
54
|
+
|
55
|
+
## 1.1.0 (2012-02-17)
|
2
56
|
|
3
57
|
* Improvement: Merged [pull request 9](https://github.com/rubiii/nori/pull/9) to
|
4
58
|
allow multiple configurations of Nori.
|
@@ -6,17 +60,17 @@
|
|
6
60
|
* Fix: Merged [pull request 10](https://github.com/rubiii/nori/pull/10) to handle
|
7
61
|
date/time parsing errors. Fixes a couple of similar error reports.
|
8
62
|
|
9
|
-
|
63
|
+
## 1.0.2 (2011-07-04)
|
10
64
|
|
11
65
|
* Fix: When specifying a custom formula to convert tags, XML attributes were ignored.
|
12
66
|
Now, a formula is applied to both XML tags and attributes.
|
13
67
|
|
14
|
-
|
68
|
+
## 1.0.1 (2011-06-21)
|
15
69
|
|
16
70
|
* Fix: Make sure to always load both StringWithAttributes and StringIOFile
|
17
71
|
to prevent NameError's.
|
18
72
|
|
19
|
-
|
73
|
+
## 1.0.0 (2011-06-20)
|
20
74
|
|
21
75
|
* Notice: As of v1.0.0, Nori will follow [Semantic Versioning](http://semver.org).
|
22
76
|
|
@@ -45,22 +99,22 @@
|
|
45
99
|
end
|
46
100
|
|
47
101
|
xml = '<userResponse><accountStatus>active</accountStatus></userResponse>'
|
48
|
-
parse(xml).should
|
102
|
+
parse(xml).should ## { :user_response => { :account_status => "active" }
|
49
103
|
|
50
|
-
|
104
|
+
## 0.2.4 (2011-06-21)
|
51
105
|
|
52
106
|
* Fix: backported fixes from v1.0.1
|
53
107
|
|
54
|
-
|
108
|
+
## 0.2.3 (2011-05-26)
|
55
109
|
|
56
110
|
* Fix: Use extended core classes StringWithAttributes and StringIOFile instead of
|
57
111
|
creating singletons to prevent serialization problems.
|
58
112
|
|
59
|
-
|
113
|
+
## 0.2.2 (2011-05-16)
|
60
114
|
|
61
115
|
* Fix: namespaced xs:nil values should be nil objects.
|
62
116
|
|
63
|
-
|
117
|
+
## 0.2.1 (2011-05-15)
|
64
118
|
|
65
119
|
* Fix: Changed XML attributes converted to Hash keys to be prefixed with an @-sign.
|
66
120
|
This avoids problems with attributes and child nodes having the same name.
|
@@ -74,7 +128,7 @@
|
|
74
128
|
|
75
129
|
{ "multiRef" => { "@id" => "id1", "id" => "76737", "approved" => "true" } }
|
76
130
|
|
77
|
-
|
131
|
+
## 0.2.0 (2011-04-30)
|
78
132
|
|
79
133
|
* Removed JSON from the original Crack basis
|
80
134
|
* Fixed a problem with Object#blank?
|
@@ -83,30 +137,30 @@
|
|
83
137
|
|
84
138
|
Nori.parser = :nokogiri
|
85
139
|
|
86
|
-
|
140
|
+
## 0.1.7 2010-02-19
|
87
141
|
* 1 minor patch
|
88
142
|
* Added patch from @purp for ISO 8601 date/time format
|
89
143
|
|
90
|
-
|
144
|
+
## 0.1.6 2010-01-31
|
91
145
|
* 1 minor patch
|
92
146
|
* Added Crack::VERSION constant - http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
|
93
147
|
|
94
|
-
|
148
|
+
## 0.1.5 2010-01-27
|
95
149
|
* 1 minor patch
|
96
150
|
* Strings that begin with dates shouldn't be parsed as such (sandro)
|
97
151
|
|
98
|
-
|
152
|
+
## 0.1.3 2009-06-22
|
99
153
|
* 1 minor patch
|
100
154
|
* Parsing a text node with attributes stores them in the attributes method (tamalw)
|
101
155
|
|
102
|
-
|
156
|
+
## 0.1.2 2009-04-21
|
103
157
|
* 2 minor patches
|
104
158
|
* Correct unnormalization of attribute values (der-flo)
|
105
159
|
* Fix error in parsing YAML in the case where a hash value ends with backslashes, and there are subsequent values in the hash (deadprogrammer)
|
106
160
|
|
107
|
-
|
161
|
+
## 0.1.1 2009-03-31
|
108
162
|
* 1 minor patch
|
109
163
|
* Parsing empty or blank xml now returns empty hash instead of raising error.
|
110
164
|
|
111
|
-
|
165
|
+
## 0.1.0 2009-03-28
|
112
166
|
* Initial release.
|
data/lib/nori/version.rb
CHANGED
@@ -19,13 +19,34 @@ module Nori
|
|
19
19
|
class XMLUtilityNode
|
20
20
|
|
21
21
|
# Simple xs:time Regexp.
|
22
|
-
|
22
|
+
# Valid xs:time formats
|
23
|
+
# 13:20:00 1:20 PM
|
24
|
+
# 13:20:30.5555 1:20 PM and 30.5555 seconds
|
25
|
+
# 13:20:00-05:00 1:20 PM, US Eastern Standard Time
|
26
|
+
# 13:20:00Z 1:20 PM, Coordinated Universal Time (UTC)
|
27
|
+
# 00:00:00 midnight
|
28
|
+
# 24:00:00 midnight
|
29
|
+
|
30
|
+
XS_TIME = /^\d{2}:\d{2}:\d{2}[Z\.\-]?\d*:?\d*$/
|
23
31
|
|
24
32
|
# Simple xs:date Regexp.
|
25
|
-
|
33
|
+
# Valid xs:date formats
|
34
|
+
# 2004-04-12 April 12, 2004
|
35
|
+
# -0045-01-01 January 1, 45 BC
|
36
|
+
# 12004-04-12 April 12, 12004
|
37
|
+
# 2004-04-12-05:00 April 12, 2004, US Eastern Standard Time, which is 5 hours behind Coordinated Universal Time (UTC)
|
38
|
+
# 2004-04-12Z April 12, 2004, Coordinated Universal Time (UTC)
|
39
|
+
|
40
|
+
XS_DATE = /^[-]?\d{4}-\d{2}-\d{2}[Z\-]?\d*:?\d*$/
|
26
41
|
|
27
42
|
# Simple xs:dateTime Regexp.
|
28
|
-
|
43
|
+
# Valid xs:dateTime formats
|
44
|
+
# 2004-04-12T13:20:00 1:20 pm on April 12, 2004
|
45
|
+
# 2004-04-12T13:20:15.5 1:20 pm and 15.5 seconds on April 12, 2004
|
46
|
+
# 2004-04-12T13:20:00-05:00 1:20 pm on April 12, 2004, US Eastern Standard Time
|
47
|
+
# 2004-04-12T13:20:00Z 1:20 pm on April 12, 2004, Coordinated Universal Time (UTC)
|
48
|
+
|
49
|
+
XS_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[\.Z\-]?\d*:?\d*$/
|
29
50
|
|
30
51
|
def self.typecasts
|
31
52
|
@@typecasts
|
data/spec/nori/nori_spec.rb
CHANGED
@@ -144,15 +144,19 @@ describe Nori do
|
|
144
144
|
|
145
145
|
it "should not transform Strings containing an xs:time String and more" do
|
146
146
|
parse("<value>09:33:55Z is a time</value>")["value"].should == "09:33:55Z is a time"
|
147
|
+
parse("<value>09:33:55Z_is_a_file_name</value>")["value"].should == "09:33:55Z_is_a_file_name"
|
147
148
|
end
|
148
149
|
|
149
150
|
it "should not transform Strings containing an xs:date String and more" do
|
150
151
|
parse("<value>1955-04-18-05:00 is a date</value>")["value"].should == "1955-04-18-05:00 is a date"
|
152
|
+
parse("<value>1955-04-18-05:00_is_a_file_name</value>")["value"].should == "1955-04-18-05:00_is_a_file_name"
|
151
153
|
end
|
152
154
|
|
153
155
|
it "should not transform Strings containing an xs:dateTime String and more" do
|
154
156
|
parse("<value>1955-04-18T11:22:33-05:00 is a dateTime</value>")["value"].should ==
|
155
157
|
"1955-04-18T11:22:33-05:00 is a dateTime"
|
158
|
+
parse("<value>1955-04-18T11:22:33-05:00_is_a_file_name</value>")["value"].should ==
|
159
|
+
"1955-04-18T11:22:33-05:00_is_a_file_name"
|
156
160
|
end
|
157
161
|
|
158
162
|
["00-00-00", "0000-00-00", "0000-00-00T00:00:00", "0569-23-0141", "DS2001-19-1312654773", "e6:53:01:00:ce:b4:06"].each do |date_string|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nori
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Harrington
|
@@ -17,12 +17,10 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-
|
20
|
+
date: 2012-06-29 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
24
|
-
type: :development
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
24
|
none: false
|
27
25
|
requirements:
|
28
26
|
- - ~>
|
@@ -33,12 +31,12 @@ dependencies:
|
|
33
31
|
- 8
|
34
32
|
- 7
|
35
33
|
version: 0.8.7
|
36
|
-
version_requirements: *id001
|
37
34
|
name: rake
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
prerelease: false
|
40
35
|
type: :development
|
41
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
40
|
none: false
|
43
41
|
requirements:
|
44
42
|
- - ">="
|
@@ -49,12 +47,12 @@ dependencies:
|
|
49
47
|
- 4
|
50
48
|
- 0
|
51
49
|
version: 1.4.0
|
52
|
-
version_requirements: *id002
|
53
50
|
name: nokogiri
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
|
-
prerelease: false
|
56
51
|
type: :development
|
57
|
-
|
52
|
+
prerelease: false
|
53
|
+
requirement: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
58
56
|
none: false
|
59
57
|
requirements:
|
60
58
|
- - ~>
|
@@ -65,12 +63,12 @@ dependencies:
|
|
65
63
|
- 5
|
66
64
|
- 0
|
67
65
|
version: 2.5.0
|
68
|
-
version_requirements: *id003
|
69
66
|
name: rspec
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
prerelease: false
|
72
67
|
type: :development
|
73
|
-
|
68
|
+
prerelease: false
|
69
|
+
requirement: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
74
72
|
none: false
|
75
73
|
requirements:
|
76
74
|
- - ">="
|
@@ -79,8 +77,10 @@ dependencies:
|
|
79
77
|
segments:
|
80
78
|
- 0
|
81
79
|
version: "0"
|
82
|
-
version_requirements: *id004
|
83
80
|
name: autotest
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
requirement: *id004
|
84
84
|
description: XML to Hash translator
|
85
85
|
email: me@rubiii.com
|
86
86
|
executables: []
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements: []
|
149
149
|
|
150
150
|
rubyforge_project: nori
|
151
|
-
rubygems_version: 1.8.
|
151
|
+
rubygems_version: 1.8.21
|
152
152
|
signing_key:
|
153
153
|
specification_version: 3
|
154
154
|
summary: XML to Hash translator
|