iso8601 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,19 +14,19 @@ describe ISO8601::Duration do
14
14
  expect { ISO8601::Duration.new('.P1Y') }.to raise_error(ISO8601::Errors::UnknownPattern)
15
15
  end
16
16
  it "should parse any allowed pattern" do
17
- expect { ISO8601::Duration.new('P1Y') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
18
- expect { ISO8601::Duration.new('P1Y1M') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
19
- expect { ISO8601::Duration.new('P1Y1M1D') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
20
- expect { ISO8601::Duration.new('P1Y1M1DT1H') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
21
- expect { ISO8601::Duration.new('P1Y1M1DT1H1M') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
22
- expect { ISO8601::Duration.new('P1Y1M1DT1H1M1S') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
23
- expect { ISO8601::Duration.new('P1Y1M1DT1H1M1.0S') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
24
- expect { ISO8601::Duration.new('P1W') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
25
- expect { ISO8601::Duration.new('+P1Y') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
26
- expect { ISO8601::Duration.new('-P1Y') }.to_not raise_error(ISO8601::Errors::UnknownPattern)
17
+ expect { ISO8601::Duration.new('P1Y') }.to_not raise_error
18
+ expect { ISO8601::Duration.new('P1Y1M') }.to_not raise_error
19
+ expect { ISO8601::Duration.new('P1Y1M1D') }.to_not raise_error
20
+ expect { ISO8601::Duration.new('P1Y1M1DT1H') }.to_not raise_error
21
+ expect { ISO8601::Duration.new('P1Y1M1DT1H1M') }.to_not raise_error
22
+ expect { ISO8601::Duration.new('P1Y1M1DT1H1M1S') }.to_not raise_error
23
+ expect { ISO8601::Duration.new('P1Y1M1DT1H1M1.0S') }.to_not raise_error
24
+ expect { ISO8601::Duration.new('P1W') }.to_not raise_error
25
+ expect { ISO8601::Duration.new('+P1Y') }.to_not raise_error
26
+ expect { ISO8601::Duration.new('-P1Y') }.to_not raise_error
27
27
  end
28
28
  it "should raise a TypeError when the base is not a ISO8601::DateTime" do
29
- expect { ISO8601::Duration.new('P1Y1M1DT1H1M1S', ISO8601::DateTime.new('2010-01-01')) }.to_not raise_error(TypeError)
29
+ expect { ISO8601::Duration.new('P1Y1M1DT1H1M1S', ISO8601::DateTime.new('2010-01-01')) }.to_not raise_error
30
30
  expect { ISO8601::Duration.new('P1Y1M1DT1H1M1S', '2010-01-01') }.to raise_error(TypeError)
31
31
  expect { ISO8601::Duration.new('P1Y1M1DT1H1M1S', 2010) }.to raise_error(TypeError)
32
32
  expect {
@@ -36,9 +36,7 @@ describe ISO8601::Duration do
36
36
  end
37
37
 
38
38
  it "should return a Duration instance from a Numeric input" do
39
- puts ISO8601::Duration.new(37065906, ISO8601::DateTime.new('2012-01-01')).should be_an_instance_of ISO8601::Duration
40
39
  ISO8601::Duration.new(36993906, ISO8601::DateTime.new('2012-01-01')).should == ISO8601::Duration.new('P1Y2M3DT4H5M6S', ISO8601::DateTime.new('2012-01-01'))
41
-
42
40
  end
43
41
 
44
42
  describe '#base' do
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe ISO8601::Time do
4
+ it "should raise an error for any unknown pattern" do
5
+ expect { ISO8601::Time.new('T10:3012+0400') }.to raise_error(ISO8601::Errors::UnknownPattern)
6
+ expect { ISO8601::Time.new('T10:30:12+0400') }.to raise_error(ISO8601::Errors::UnknownPattern)
7
+ expect { ISO8601::Time.new('T10:30:12+040') }.to raise_error(ISO8601::Errors::UnknownPattern)
8
+ end
9
+
10
+ it "should raise an error for a correct pattern but an invalid date" do
11
+ expect { ISO8601::Time.new('T25:00:00') }.to raise_error(ISO8601::Errors::RangeError)
12
+ expect { ISO8601::Time.new('T00:61:00') }.to raise_error(ISO8601::Errors::RangeError)
13
+ expect { ISO8601::Time.new('T00:00:61') }.to raise_error(ISO8601::Errors::RangeError)
14
+ end
15
+
16
+ it "should parse any allowed pattern" do
17
+ expect { ISO8601::Time.new('T10') }.to_not raise_error
18
+ expect { ISO8601::Time.new('T10:30') }.to_not raise_error
19
+ expect { ISO8601::Time.new('T10:30:12') }.to_not raise_error
20
+ expect { ISO8601::Time.new('T10:30:12Z') }.to_not raise_error
21
+ expect { ISO8601::Time.new('T10:30:12+04') }.to_not raise_error
22
+ expect { ISO8601::Time.new('T10:30:12+04:00') }.to_not raise_error
23
+ expect { ISO8601::Time.new('T10:30:12-04:00') }.to_not raise_error
24
+ expect { ISO8601::Time.new('T103012+0400') }.to_not raise_error
25
+ expect { ISO8601::Time.new('T103012+04') }.to_not raise_error
26
+ expect { ISO8601::Time.new('T10:30:12-00:00') }.to_not raise_error
27
+ expect { ISO8601::Time.new('T16:26:10,5Z') }.to_not raise_error
28
+ end
29
+
30
+ context 'reduced patterns' do
31
+ it "should parse correctly reduced times" do
32
+ reduced_time = ISO8601::Time.new('T101112Z')
33
+ reduced_time.hour.should == 10
34
+ reduced_time.minute.should == 11
35
+ reduced_time.second.should == 12
36
+ end
37
+ end
38
+
39
+ it "should return each atomic value" do
40
+ dt = ISO8601::Time.new('T12:02:01+04:00', ::Date.parse('2010-05-09'))
41
+ dt.hour.should == 12
42
+ dt.minute.should == 2
43
+ dt.second.should == 1
44
+ dt.zone.should == '+04:00'
45
+ end
46
+
47
+ it "should respond to delegated casting methods" do
48
+ dt = ISO8601::Time.new('T10:09:08Z')
49
+ dt.should respond_to(:to_s, :to_time, :to_date, :to_datetime)
50
+ end
51
+
52
+ describe '#+' do
53
+ it "should return the result of the addition" do
54
+ (ISO8601::Time.new('T20:20:20+02:00') + 10).to_s.should == 'T20:20:30+02:00'
55
+ (ISO8601::Time.new('T20:20:20.11+02:00') + 10).to_s.should == 'T20:20:30.11+02:00'
56
+ end
57
+ end
58
+
59
+ describe '#-' do
60
+ it "should return the result of the substraction" do
61
+ (ISO8601::Time.new('T20:20:20+01:00') - 10).to_s.should == 'T20:20:10+01:00'
62
+ (ISO8601::Time.new('T20:20:20.11+02:00') - 10).to_s.should == 'T20:20:10.11+02:00'
63
+ end
64
+ end
65
+
66
+ describe '#to_a' do
67
+ it "should return an array of atoms" do
68
+ ISO8601::Time.new('T19:29:39Z').to_a.should == [19, 29, 39, '+00:00']
69
+ end
70
+ end
71
+
72
+ describe '#atoms' do
73
+ it "should return an array of atoms" do
74
+ ISO8601::Time.new('T19:29:39+04:00').atoms.should == [19, 29, 39, '+04:00']
75
+ ISO8601::Time.new('T19:29:39Z').atoms.should == [19, 29, 39, 'Z']
76
+ ISO8601::Time.new('T19:29:39').atoms.should == [19, 29, 39]
77
+ ISO8601::Time.new('T19:29').atoms.should == [19, 29]
78
+ ISO8601::Time.new('T19').atoms.should == [19]
79
+ end
80
+ end
81
+ end
@@ -2,3 +2,13 @@
2
2
 
3
3
  $:.unshift File.expand_path('..', __FILE__)
4
4
  require 'iso8601'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.color = true
9
+ config.order = 'random'
10
+ config.formatter = :documentation
11
+ # config.fail_fast = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+ end
metadata CHANGED
@@ -1,39 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso8601
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Arnau Siches
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-16 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
- requirement: &70318299471920 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '2.0'
19
+ version: '2.14'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *70318299471920
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.14'
25
27
  - !ruby/object:Gem::Dependency
26
- name: ZenTest
27
- requirement: &70318299469780 !ruby/object:Gem::Requirement
28
- none: false
28
+ name: rerun
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
- version: '4.8'
33
+ version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *70318299469780
36
- description: ! " ISO8601 is a simple implementation in Ruby of the ISO 8601 (Data
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: " ISO8601 is a simple implementation in Ruby of the ISO 8601 (Data
37
42
  elements and \n interchange formats - Information interchange - Representation
38
43
  of dates \n and times) standard.\n"
39
44
  email: arnau.siches@gmail.com
@@ -41,9 +46,8 @@ executables: []
41
46
  extensions: []
42
47
  extra_rdoc_files: []
43
48
  files:
44
- - .gitignore
45
- - .rspec
46
- - .travis.yml
49
+ - ".gitignore"
50
+ - ".travis.yml"
47
51
  - Gemfile
48
52
  - LICENSE
49
53
  - README.md
@@ -51,41 +55,47 @@ files:
51
55
  - iso8601.gemspec
52
56
  - lib/iso8601.rb
53
57
  - lib/iso8601/atoms.rb
58
+ - lib/iso8601/date.rb
54
59
  - lib/iso8601/dateTime.rb
55
60
  - lib/iso8601/duration.rb
56
61
  - lib/iso8601/errors.rb
62
+ - lib/iso8601/time.rb
63
+ - lib/iso8601/version.rb
57
64
  - spec/iso8601/atoms_spec.rb
58
65
  - spec/iso8601/dateTime_spec.rb
66
+ - spec/iso8601/date_spec.rb
59
67
  - spec/iso8601/duration_spec.rb
68
+ - spec/iso8601/time_spec.rb
60
69
  - spec/spec_helper.rb
61
70
  homepage: https://github.com/arnau/ISO8601
62
71
  licenses:
63
72
  - MIT
73
+ metadata: {}
64
74
  post_install_message:
65
75
  rdoc_options: []
66
76
  require_paths:
67
77
  - lib
68
78
  required_ruby_version: !ruby/object:Gem::Requirement
69
- none: false
70
79
  requirements:
71
- - - ! '>='
80
+ - - ">="
72
81
  - !ruby/object:Gem::Version
73
82
  version: '0'
74
83
  required_rubygems_version: !ruby/object:Gem::Requirement
75
- none: false
76
84
  requirements:
77
- - - ! '>='
85
+ - - ">="
78
86
  - !ruby/object:Gem::Version
79
87
  version: '0'
80
88
  requirements: []
81
89
  rubyforge_project: iso8601
82
- rubygems_version: 1.8.10
90
+ rubygems_version: 2.2.2
83
91
  signing_key:
84
- specification_version: 3
92
+ specification_version: 4
85
93
  summary: Ruby parser to work with ISO 8601 dateTimes and durations - http://en.wikipedia.org/wiki/ISO_8601
86
94
  test_files:
87
95
  - spec/iso8601/atoms_spec.rb
88
96
  - spec/iso8601/dateTime_spec.rb
97
+ - spec/iso8601/date_spec.rb
89
98
  - spec/iso8601/duration_spec.rb
99
+ - spec/iso8601/time_spec.rb
90
100
  - spec/spec_helper.rb
91
101
  has_rdoc: yard
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format documentation