nori 1.1.2 → 1.1.3
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 +8 -47
- data/lib/nori/version.rb +1 -1
- data/lib/nori/xml_utility_node.rb +7 -3
- data/spec/nori/nori_spec.rb +18 -0
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,53 +1,14 @@
|
|
1
|
-
##
|
2
|
-
|
3
|
-
*
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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)
|
1
|
+
## 1.1.3 (2012-07-12)
|
2
|
+
|
3
|
+
* Fix: Merged [pull request 21](https://github.com/rubiii/nori/pull/21) to fix an
|
4
|
+
issue with date/time/datetime regexes not matching positive time zone offsets and
|
5
|
+
datetime strings with seconds.
|
6
|
+
|
7
|
+
## 1.1.2 (2012-06-30)
|
47
8
|
|
48
9
|
* Fix: Reverted `Object#xml_attributes` feature which is planned for version 2.0.
|
49
10
|
|
50
|
-
## 1.1.1 (2012-
|
11
|
+
## 1.1.1 (2012-06-29) - yanked
|
51
12
|
|
52
13
|
* Fix: Merged [pull request 17](https://github.com/rubiii/nori/pull/17) for improved
|
53
14
|
xs:time/xs:date/xs:dateTime regular expression matchers.
|
data/lib/nori/version.rb
CHANGED
@@ -23,11 +23,12 @@ module Nori
|
|
23
23
|
# 13:20:00 1:20 PM
|
24
24
|
# 13:20:30.5555 1:20 PM and 30.5555 seconds
|
25
25
|
# 13:20:00-05:00 1:20 PM, US Eastern Standard Time
|
26
|
+
# 13:20:00+02:00 1:20 PM, Central European Standard Time
|
26
27
|
# 13:20:00Z 1:20 PM, Coordinated Universal Time (UTC)
|
27
28
|
# 00:00:00 midnight
|
28
29
|
# 24:00:00 midnight
|
29
30
|
|
30
|
-
XS_TIME = /^\d{2}:\d{2}:\d{2}[Z
|
31
|
+
XS_TIME = /^\d{2}:\d{2}:\d{2}[Z\.\-\+]?\d*:?\d*$/
|
31
32
|
|
32
33
|
# Simple xs:date Regexp.
|
33
34
|
# Valid xs:date formats
|
@@ -35,18 +36,21 @@ module Nori
|
|
35
36
|
# -0045-01-01 January 1, 45 BC
|
36
37
|
# 12004-04-12 April 12, 12004
|
37
38
|
# 2004-04-12-05:00 April 12, 2004, US Eastern Standard Time, which is 5 hours behind Coordinated Universal Time (UTC)
|
39
|
+
# 2004-04-12+02:00 April 12, 2004, Central European Summer Time, which is 2 hours ahead of Coordinated Universal Time (UTC)
|
38
40
|
# 2004-04-12Z April 12, 2004, Coordinated Universal Time (UTC)
|
39
41
|
|
40
|
-
XS_DATE = /^[-]?\d{4}-\d{2}-\d{2}[Z
|
42
|
+
XS_DATE = /^[-]?\d{4}-\d{2}-\d{2}[Z\-\+]?\d*:?\d*$/
|
41
43
|
|
42
44
|
# Simple xs:dateTime Regexp.
|
43
45
|
# Valid xs:dateTime formats
|
44
46
|
# 2004-04-12T13:20:00 1:20 pm on April 12, 2004
|
45
47
|
# 2004-04-12T13:20:15.5 1:20 pm and 15.5 seconds on April 12, 2004
|
46
48
|
# 2004-04-12T13:20:00-05:00 1:20 pm on April 12, 2004, US Eastern Standard Time
|
49
|
+
# 2004-04-12T13:20:00+02:00 1:20 pm on April 12, 2004, Central European Summer Time
|
50
|
+
# 2004-04-12T13:20:15.5-05:00 1:20 pm and 15.5 seconds on April 12, 2004, US Eastern Standard Time
|
47
51
|
# 2004-04-12T13:20:00Z 1:20 pm on April 12, 2004, Coordinated Universal Time (UTC)
|
48
52
|
|
49
|
-
XS_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[\.Z
|
53
|
+
XS_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[\.Z]?\d*[\-\+]?\d*:?\d*$/
|
50
54
|
|
51
55
|
def self.typecasts
|
52
56
|
@@typecasts
|
data/spec/nori/nori_spec.rb
CHANGED
@@ -133,15 +133,33 @@ describe Nori do
|
|
133
133
|
parse("<value>09:33:55Z</value>")["value"].should == Time.parse("09:33:55Z")
|
134
134
|
end
|
135
135
|
|
136
|
+
it "should transform Strings matching the xs:time format ahead of utc to Time objects" do
|
137
|
+
parse("<value>09:33:55+02:00</value>")["value"].should == Time.parse("09:33:55+02:00")
|
138
|
+
end
|
139
|
+
|
136
140
|
it "should transform Strings matching the xs:date format to Date objects" do
|
137
141
|
parse("<value>1955-04-18-05:00</value>")["value"].should == Date.parse("1955-04-18-05:00")
|
138
142
|
end
|
139
143
|
|
144
|
+
it "should transform Strings matching the xs:dateTime format ahead of utc to Date objects" do
|
145
|
+
parse("<value>1955-04-18+02:00</value>")["value"].should == Date.parse("1955-04-18+02:00")
|
146
|
+
end
|
147
|
+
|
140
148
|
it "should transform Strings matching the xs:dateTime format to DateTime objects" do
|
141
149
|
parse("<value>1955-04-18T11:22:33-05:00</value>")["value"].should ==
|
142
150
|
DateTime.parse("1955-04-18T11:22:33-05:00")
|
143
151
|
end
|
144
152
|
|
153
|
+
it "should transform Strings matching the xs:dateTime format ahead of utc to DateTime objects" do
|
154
|
+
parse("<value>1955-04-18T11:22:33+02:00</value>")["value"].should ==
|
155
|
+
DateTime.parse("1955-04-18T11:22:33+02:00")
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should transform Strings matching the xs:dateTime format with seconds and an offset to DateTime objects" do
|
159
|
+
parse("<value>2004-04-12T13:20:15.5-05:00</value>")["value"].should ==
|
160
|
+
DateTime.parse("2004-04-12T13:20:15.5-05:00")
|
161
|
+
end
|
162
|
+
|
145
163
|
it "should not transform Strings containing an xs:time String and more" do
|
146
164
|
parse("<value>09:33:55Z is a time</value>")["value"].should == "09:33:55Z is a time"
|
147
165
|
parse("<value>09:33:55Z_is_a_file_name</value>")["value"].should == "09:33:55Z_is_a_file_name"
|
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: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 3
|
10
|
+
version: 1.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Harrington
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-
|
20
|
+
date: 2012-07-12 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|