xml-mapping_extensions 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26f76a9fe36b5554f940110297aefbf62e26cc99
4
- data.tar.gz: 30c72c8dc6b1c9c8757c493c14919a65ff4df36f
3
+ metadata.gz: e73d6da3501c828dfcc61abf5e57819fafe02503
4
+ data.tar.gz: 658f243f24e3893e5ef5c9db5119253590a35e80
5
5
  SHA512:
6
- metadata.gz: a5d5359795785430506b583c13ad3274ba6cf5b237cd5cdb90f201da76d959bc295faf408f5e885e3d9e69b79a5bc4ea64a951a3eeb1e12405f2b40a6e12ccef
7
- data.tar.gz: e16fabb2475ce3b7c3e15b68e57fa8a9c6acf32f89834e370ab2e6176f2c427dec7bd04422218272ef093243039245fb2a031204ddea05e7bc257f229b965f9d
6
+ metadata.gz: 5491021c83c519e27adeb55c3b4f2b965a75818c1446ade0028ffbf47e7cac9e227cc63448856945cca2852c48afdfcc9a3f0679bf6fd4dcb74b00c798fdc9f0
7
+ data.tar.gz: ec5cb7318df6f5e049eb0eaec50f9efff2047060d0b7b772cf5d6770408d064b9e74227ead666aedde8d14183ab5074a763c6fddec22e028a189fb90e4f2649a
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.2 (1 June 2016)
2
+
3
+ - Made `DateNode` truncate a `DateTime` to a date
4
+
1
5
  ## 0.4.1 (18 May 2016)
2
6
 
3
7
  - Fixed various issues with nested namespaces
@@ -28,6 +28,7 @@ module XML
28
28
  # @return [String] the value as an XML Schema date string, without
29
29
  # time zone information unless {#zulu} is set
30
30
  def to_xml_text(value)
31
+ value = value.to_date if value.respond_to?(:to_date)
31
32
  text = value.iso8601 # use iso8601 instead of xmlschema in case of ActiveSupport shenanigans
32
33
  (zulu && !text.end_with?('Z')) ? "#{text}Z" : text
33
34
  end
@@ -1,6 +1,6 @@
1
1
  module XML
2
2
  module MappingExtensions
3
3
  # The version of this gem
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
6
6
  end
@@ -13,8 +13,8 @@ module XML
13
13
  load_from_xml(doc.root)
14
14
  end
15
15
  end
16
- describe DateNode do
17
16
 
17
+ describe DateNode do
18
18
  def to_date(str)
19
19
  DateNodeSpecElem.from_str(str).date
20
20
  end
@@ -57,12 +57,36 @@ module XML
57
57
  expect(actual).to eq(expected)
58
58
  end
59
59
 
60
+ it 'truncates a Time to a date' do
61
+ expected = '2002-09-24'
62
+ actual = to_text(Time.utc(2002, 9, 24, 0, 1, 2))
63
+ expect(actual).to eq(expected)
64
+ end
65
+
66
+ it 'truncates a DateTime to a Date' do
67
+ expected = '2002-09-24'
68
+ actual = to_text(DateTime.new(2002, 9, 24, 0, 1, 2))
69
+ expect(actual).to eq(expected)
70
+ end
71
+
60
72
  it 'outputs a UTC "zulu" date (time zone designator "Z")' do
61
73
  expected = '2002-09-24Z'
62
74
  actual = to_zulu_text(Date.new(2002, 9, 24))
63
75
  expect(actual).to eq(expected)
64
76
  end
65
77
 
78
+ it 'truncates a DateTime to a zulu date' do
79
+ expected = '2002-09-24Z'
80
+ actual = to_zulu_text(DateTime.new(2002, 9, 24, 0, 1, 2))
81
+ expect(actual).to eq(expected)
82
+ end
83
+
84
+ it 'truncates a Time to a zulu date' do
85
+ expected = '2002-09-24Z'
86
+ actual = to_zulu_text(Time.utc(2002, 9, 24, 0, 1, 2))
87
+ expect(actual).to eq(expected)
88
+ end
89
+
66
90
  describe 'works with Date.today' do
67
91
  it 'as plain date' do
68
92
  date = Date.today
@@ -47,6 +47,11 @@ module XML
47
47
  expect { to_mime_type(mt_str) }.to raise_error(MIME::Type::InvalidContentType)
48
48
  end
49
49
 
50
+ it 'parses a nil mime-type as nil' do
51
+ elem = MimeTypeSpecElem.parse_xml('<elem/>')
52
+ expect(elem.mime_type).to be_nil
53
+ end
54
+
50
55
  end
51
56
  end
52
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-mapping_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types