edtf 2.1.0 → 2.2.0

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: 68aac723f31efd30a29639ccddba4f552d32f3e2
4
- data.tar.gz: 0997aa8f2861ababa527f1f39b0811ef2db055c9
3
+ metadata.gz: 78ea9e9fd8f43b0113aadd9b17a62de265c11972
4
+ data.tar.gz: 14afd317d3146be4e5d2e4f9bfbf3cbf0c365856
5
5
  SHA512:
6
- metadata.gz: fae111479f8b85e8d308e0075e62a713be2d651ad402c7867183fadb5d929541333d78baad12712b6a244b5dc890557bd9b331188656989508d657117401e9d8
7
- data.tar.gz: 5d3ad065005556811991a501b1ad5f1a73210b0fa5c6e5bd88e4808145d24a5135d48f8bcd7b0d8c0de97634ac61a8e578bd830ffd4e2285f2a0e8874934b2d6
6
+ metadata.gz: 3ae6ab55647c39ed69d384f7b3f82579d58ec6c9c156cc5c6f255d95660229dd518c13039f327e8839c163c126a997978cce9e5a54a170439e5875fa3ac8fafe
7
+ data.tar.gz: 45ce22b6fed0acfec4376094f05a75e7529fb33e28c8311f128451bbf4143498a627c67f62ec0a9e372f827650bf6ff607576a1a0c57f94a20168d2368d3cadf
@@ -2,11 +2,11 @@ language: ruby
2
2
  bundler_args: --without debug extra
3
3
  script: bundle exec rake test_with_coveralls
4
4
  rvm:
5
+ - 2.1.0
5
6
  - 2.0.0
6
7
  - 1.9.3
7
8
  - jruby-19mode
8
- - rbx-2.1.1
9
- - rbx
9
+ - rbx-2
10
10
  notifications:
11
11
  email:
12
12
  - sk@semicolon.at
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ gemspec
3
3
 
4
4
  group :debug do
5
5
  gem 'ruby-debug', :require => false, :platform => :jruby
6
- gem 'debugger', ['~>1.6', '>=1.6.5'], :require => false, :platform => :mri
6
+ gem 'byebug', :require => false, :platform => :mri
7
7
  gem 'rubinius-compiler', '~>2.0', :require => false, :platform => :rbx
8
8
  gem 'rubinius-debugger', '~>2.0', :require => false, :platform => :rbx
9
9
  end
@@ -12,7 +12,7 @@ group :development do
12
12
  gem 'rake'
13
13
  gem 'racc', :platform => :ruby
14
14
  gem 'cucumber'
15
- gem 'rspec'
15
+ gem 'rspec', '~>3.0'
16
16
  gem 'simplecov', '~>0.8', :require => false
17
17
  gem 'rubinius-coverage', :platform => :rbx
18
18
  gem 'coveralls', :require => false
@@ -26,6 +26,11 @@ end
26
26
  gem 'i18n'
27
27
 
28
28
  platform :rbx do
29
- gem 'rubysl', '~>2.0'
29
+ gem 'rubysl-singleton', '~>2.0'
30
+ gem 'rubysl-open3', '~>2.0'
31
+ gem 'rubysl-enumerator', '~>2.0'
32
+ gem 'rubysl-base64', '~>2.0'
33
+ gem 'rubysl-bigdecimal', '~>2.0'
34
+ gem 'rubysl-drb', '~>2.0'
30
35
  gem 'json'
31
36
  end
data/README.md CHANGED
@@ -4,7 +4,7 @@ EDTF-Ruby
4
4
  [![Coverage Status](https://coveralls.io/repos/inukshuk/edtf-ruby/badge.png)](https://coveralls.io/r/inukshuk/edtf-ruby)
5
5
 
6
6
  EDTF-Ruby comprises a parser and an API implementation of the [Extended
7
- Date/Time Format standard](http://www.loc.gov/standards/datetime/spec.html).
7
+ Date/Time Format standard](http://www.loc.gov/standards/datetime/).
8
8
 
9
9
 
10
10
  Compatibility
@@ -21,8 +21,8 @@ EDTF-Ruby parser implements all levels and features of the EDTF specification
21
21
  examples, though).
22
22
 
23
23
  EDTF-Ruby has been confirmed to work on the following Ruby implementations:
24
- 2.1, 2.0, 1.9.3, Rubinius, and JRuby (1.8.7 and 1.9.2 were originally
25
- we are not testing compatibility actively anymore). Active Support's date
24
+ 2.1, 2.0, 1.9.3, Rubinius, and JRuby (1.8.7 and 1.9.2 were originally supported
25
+ but we are not testing compatibility actively anymore). Active Support's date
26
26
  extensions are currently listed as a dependency, because of many functional
27
27
  overlaps (version 3.x and 4.x are supported).
28
28
 
@@ -63,10 +63,10 @@ precision to month, however, the natural successor is not the next day, but
63
63
  a day a month from now. Always keep precision in mind when comparing dates,
64
64
  too:
65
65
 
66
- > Date.new(1666).year_precision! == Date.new(1966)
66
+ > Date.new(1966).year_precision! == Date.new(1966)
67
67
  => false
68
68
 
69
- The year 1666 is not equal to the January 1st, 1966. You can set a date's
69
+ The year 1966 is not equal to the January 1st, 1966. You can set a date's
70
70
  precision directly, or else use the dedicated bang! methods:
71
71
 
72
72
  > d = Date.new(1993)
@@ -213,7 +213,7 @@ and the `choice` attribute.
213
213
  => false
214
214
  > s.choice!
215
215
  > s.edtf
216
- => "[1667, 1668, 1670..1672]"
216
+ => "[1667,1668,1670..1672]"
217
217
 
218
218
  As you can see above, EDTF-Ruby remembers which parts of the set were
219
219
  specified as a range; ranges are however enumerated for membership tests:
@@ -233,7 +233,7 @@ When in doubt, you can always map the set to an array. This will also
233
233
  enumerate all ranges:
234
234
 
235
235
  > s.map(&:year)
236
- => [1667, 1668, 1670, 1671, 1672] # when enumerated there are 5 elements
236
+ => [1667,1668,1670,1671,1672] # when enumerated there are 5 elements
237
237
 
238
238
  EDTF sets also feature an `#earlier?` and `#later?` attribute:
239
239
 
@@ -241,7 +241,7 @@ EDTF sets also feature an `#earlier?` and `#later?` attribute:
241
241
  => false
242
242
  > s.earlier!
243
243
  > s.edtf
244
- => "[..1667, 1668, 1670..1672]"
244
+ => "[..1667,1668,1670..1672]"
245
245
 
246
246
 
247
247
  ### Decades and Centuries
@@ -2,7 +2,7 @@ Feature: EDTF parses date/time strings
2
2
 
3
3
  As a user of edtf-ruby
4
4
  I want to parse date/time strings formatted in EDTF
5
-
5
+
6
6
  Scenario Outline: EDTF parses a date/time string
7
7
  When I parse the string "<string>"
8
8
  Then the year should be "<year>"
@@ -33,9 +33,9 @@ Feature: EDTF parses date/time strings
33
33
  | 2004-01-01T10:10:10Z | 2004 | 1 | 1 | 10 | 10 | 10 |
34
34
  | 2004-01-01T10:10:10+05:00 | 2004 | 1 | 1 | 5 | 10 | 10 |
35
35
  | 2004-01-01T02:10:10+05:00 | 2003 | 12 | 31 | 21 | 10 | 10 |
36
-
36
+
37
37
  # Scenarios: fractions
38
38
  # | string | year | month | day | hours | minutes | seconds |
39
39
  # | 2004-01-01T10 | 2004 | 1 | 1 | 10 | 0 | 0 |
40
40
  # | 2004-01-01T10:10:10+05:00 | 2004 | 1 | 1 | 5 | 10 | 10 |
41
- # | 2004-01-01T02:10:10+05:00 | 2003 | 12 | 31 | 21 | 10 | 10 |
41
+ # | 2004-01-01T02:10:10+05:00 | 2003 | 12 | 31 | 21 | 10 | 10 |
@@ -1,73 +1,73 @@
1
1
  Feature: Print Date/Time objects as Level 0 EDTF strings
2
2
  As a Ruby programmer
3
3
  I want to convert Date/Time objects to EDTF strings
4
-
4
+
5
5
  @001 @level0
6
6
  Scenario: Convert simple dates
7
7
  Given the date "2004-08-12"
8
8
  When I convert the date
9
9
  Then the EDTF string should be "2004-08-12"
10
10
 
11
- @001 @level0
12
- Scenario: Convert simple dates with precision
13
- Given the date "1980-08-24" with precision set to "day"
14
- When I convert the date
15
- Then the EDTF string should be "1980-08-24"
16
- Given the date "1980-08-24" with precision set to "month"
17
- When I convert the date
18
- Then the EDTF string should be "1980-08"
19
- Given the date "1980-08-24" with precision set to "year"
20
- When I convert the date
21
- Then the EDTF string should be "1980"
11
+ @001 @level0
12
+ Scenario: Convert simple dates with precision
13
+ Given the date "1980-08-24" with precision set to "day"
14
+ When I convert the date
15
+ Then the EDTF string should be "1980-08-24"
16
+ Given the date "1980-08-24" with precision set to "month"
17
+ When I convert the date
18
+ Then the EDTF string should be "1980-08"
19
+ Given the date "1980-08-24" with precision set to "year"
20
+ When I convert the date
21
+ Then the EDTF string should be "1980"
22
22
 
23
- @001 @level0
24
- Scenario: Date Roundtrips
25
- When I parse the string "2001-02-03"
26
- When I convert the date
27
- Then the EDTF string should be "2001-02-03"
28
- When I parse the string "2001-02"
29
- When I convert the date
30
- Then the EDTF string should be "2001-02"
31
- When I parse the string "2001"
32
- When I convert the date
33
- Then the EDTF string should be "2001"
34
- When I parse the string "-9909"
35
- When I convert the date
36
- Then the EDTF string should be "-9909"
37
- When I parse the string "0000"
38
- When I convert the date
39
- Then the EDTF string should be "0000"
23
+ @001 @level0
24
+ Scenario: Date Roundtrips
25
+ When I parse the string "2001-02-03"
26
+ When I convert the date
27
+ Then the EDTF string should be "2001-02-03"
28
+ When I parse the string "2001-02"
29
+ When I convert the date
30
+ Then the EDTF string should be "2001-02"
31
+ When I parse the string "2001"
32
+ When I convert the date
33
+ Then the EDTF string should be "2001"
34
+ When I parse the string "-9909"
35
+ When I convert the date
36
+ Then the EDTF string should be "-9909"
37
+ When I parse the string "0000"
38
+ When I convert the date
39
+ Then the EDTF string should be "0000"
40
40
 
41
- @002 @level0
42
- Scenario: DateTime Roundtrips
43
- When I parse the string "2001-02-03T09:30:01"
44
- When I convert the date
45
- Then the EDTF string should be "2001-02-03T09:30:01+00:00"
46
- When I parse the string "2004-01-01T10:10:10Z"
47
- When I convert the date
48
- Then the EDTF string should be "2004-01-01T10:10:10+00:00"
49
- When I parse the string "2004-01-01T10:10:10+05:00"
50
- When I convert the date
51
- Then the EDTF string should be "2004-01-01T10:10:10+05:00"
41
+ @002 @level0
42
+ Scenario: DateTime Roundtrips
43
+ When I parse the string "2001-02-03T09:30:01"
44
+ When I convert the date
45
+ Then the EDTF string should be "2001-02-03T09:30:01"
46
+ When I parse the string "2004-01-01T10:10:10Z"
47
+ When I convert the date
48
+ Then the EDTF string should be "2004-01-01T10:10:10+00:00"
49
+ When I parse the string "2004-01-01T10:10:10+05:00"
50
+ When I convert the date
51
+ Then the EDTF string should be "2004-01-01T10:10:10+05:00"
52
+
53
+ @004 @level0
54
+ Scenario: Interval Roundtrips
55
+ When I parse the string "1964/2008"
56
+ When I convert the date
57
+ Then the EDTF string should be "1964/2008"
58
+ When I parse the string "2004-06/2006-08"
59
+ When I convert the date
60
+ Then the EDTF string should be "2004-06/2006-08"
61
+ When I parse the string "2004-02-01/2005-02-08"
62
+ When I convert the date
63
+ Then the EDTF string should be "2004-02-01/2005-02-08"
64
+ When I parse the string "2004-02-01/2005-02"
65
+ When I convert the date
66
+ Then the EDTF string should be "2004-02-01/2005-02"
67
+ When I parse the string "2004-02-01/2005"
68
+ When I convert the date
69
+ Then the EDTF string should be "2004-02-01/2005"
70
+ When I parse the string "2005/2006-02"
71
+ When I convert the date
72
+ Then the EDTF string should be "2005/2006-02"
52
73
 
53
- @004 @level0
54
- Scenario: Interval Roundtrips
55
- When I parse the string "1964/2008"
56
- When I convert the date
57
- Then the EDTF string should be "1964/2008"
58
- When I parse the string "2004-06/2006-08"
59
- When I convert the date
60
- Then the EDTF string should be "2004-06/2006-08"
61
- When I parse the string "2004-02-01/2005-02-08"
62
- When I convert the date
63
- Then the EDTF string should be "2004-02-01/2005-02-08"
64
- When I parse the string "2004-02-01/2005-02"
65
- When I convert the date
66
- Then the EDTF string should be "2004-02-01/2005-02"
67
- When I parse the string "2004-02-01/2005"
68
- When I convert the date
69
- Then the EDTF string should be "2004-02-01/2005"
70
- When I parse the string "2005/2006-02"
71
- When I convert the date
72
- Then the EDTF string should be "2005/2006-02"
73
-
@@ -8,7 +8,7 @@ When /^I convert the date$/ do
8
8
  end
9
9
 
10
10
  Then /^the EDTF String should be "([^"]*)"$/i do |edtf|
11
- @string.should == edtf
11
+ expect(@string).to eq(edtf)
12
12
  end
13
13
 
14
14
  When /^I parse the string "([^"]*)"$/ do |string|
@@ -16,102 +16,102 @@ When /^I parse the string "([^"]*)"$/ do |string|
16
16
  end
17
17
 
18
18
  Then /^the year should be "([^"]*)"$/ do |year|
19
- @date.year.should == year.to_i
19
+ expect(@date.year).to eq(year.to_i)
20
20
  end
21
21
 
22
22
  Then /^the month should be "([^"]*)"$/ do |month|
23
- @date.month.should == month.to_i
23
+ expect(@date.month).to eq(month.to_i)
24
24
  end
25
25
 
26
26
  Then /^the day should be "([^"]*)"$/ do |day|
27
- @date.day.should == day.to_i
27
+ expect(@date.day).to eq(day.to_i)
28
28
  end
29
29
 
30
30
  Then /^the hours should be "([^"]*)"$/ do |hours|
31
- @date.hour.should == hours.to_i
31
+ expect(@date.hour).to eq(hours.to_i)
32
32
  end
33
33
 
34
34
  Then /^the year should be "([^"]*)" \(UTC\)$/ do |year|
35
- @date.to_time.utc.year.should == year.to_i
35
+ expect(@date.to_time.utc.year).to eq(year.to_i)
36
36
  end
37
37
 
38
38
  Then /^the month should be "([^"]*)" \(UTC\)$/ do |month|
39
- @date.to_time.utc.month.should == month.to_i
39
+ expect(@date.to_time.utc.month).to eq(month.to_i)
40
40
  end
41
41
 
42
42
  Then /^the day should be "([^"]*)" \(UTC\)$/ do |day|
43
- @date.to_time.utc.day.should == day.to_i
43
+ expect(@date.to_time.utc.day).to eq(day.to_i)
44
44
  end
45
45
 
46
46
  Then /^the hours should be "([^"]*)" \(UTC\)$/ do |hours|
47
- @date.to_time.utc.hour.should == hours.to_i
47
+ expect(@date.to_time.utc.hour).to eq(hours.to_i)
48
48
  end
49
49
 
50
50
 
51
51
  Then /^the minutes should be "([^"]*)"$/ do |minutes|
52
- @date.min.should == minutes.to_i
52
+ expect(@date.min).to eq(minutes.to_i)
53
53
  end
54
54
 
55
55
  Then /^the seconds should be "([^"]*)"$/ do |seconds|
56
- @date.sec.should == seconds.to_i
56
+ expect(@date.sec).to eq(seconds.to_i)
57
57
  end
58
58
 
59
59
  Then /^the duration should range from "([^"]*)" to "([^"]*)"$/ do |from,to|
60
- [@date.begin.year.to_s, @date.end.year.to_s].should == [from,to]
60
+ expect([@date.begin.year.to_s, @date.end.year.to_s]).to eq([from,to])
61
61
  end
62
62
 
63
63
  Then /^the interval should start at "([^"]*)"$/ do |date|
64
- @date.begin.to_s.should == date
64
+ expect(@date.begin.to_s).to eq(date)
65
65
  end
66
66
 
67
67
  Then /^the interval should end at "([^"]*)"$/ do |date|
68
- @date.end.to_s.should == date
68
+ expect(@date.end.to_s).to eq(date)
69
69
  end
70
70
 
71
71
  Then /^the interval should include the date "([^"]*)"$/ do |date|
72
- @date.should include(Date.parse(date))
72
+ expect(@date).to include(Date.parse(date))
73
73
  end
74
74
 
75
75
  Then /^the interval should cover the date "([^"]*)"$/ do |date|
76
- @date.should be_cover(Date.parse(date))
76
+ expect(@date).to be_cover(Date.parse(date))
77
77
  end
78
78
 
79
79
 
80
80
  Then /^the date should be uncertain\? "([^"]*)"$/ do |arg1|
81
- @date.uncertain?.should == !!(arg1 =~ /y(es)?/i)
81
+ expect(@date.uncertain?).to eq(!!(arg1 =~ /y(es)?/i))
82
82
  end
83
83
 
84
84
  Then /^the year should be uncertain\? "([^"]*)"$/ do |arg1|
85
- @date.uncertain?(:year).should == !!(arg1 =~ /y(es)?/i)
85
+ expect(@date.uncertain?(:year)).to eq(!!(arg1 =~ /y(es)?/i))
86
86
  end
87
87
 
88
88
  Then /^the month should be uncertain\? "([^"]*)"$/ do |arg1|
89
- @date.uncertain?(:month).should == !!(arg1 =~ /y(es)?/i)
89
+ expect(@date.uncertain?(:month)).to eq(!!(arg1 =~ /y(es)?/i))
90
90
  end
91
91
 
92
92
  Then /^the day should be uncertain\? "([^"]*)"$/ do |arg1|
93
- @date.uncertain?(:day).should == !!(arg1 =~ /y(es)?/i)
93
+ expect(@date.uncertain?(:day)).to eq(!!(arg1 =~ /y(es)?/i))
94
94
  end
95
95
 
96
96
  Then /^the date should be approximate\? "([^"]*)"$/ do |arg1|
97
- @date.approximate?.should == !!(arg1 =~ /y(es)?/i)
97
+ expect(@date.approximate?).to eq(!!(arg1 =~ /y(es)?/i))
98
98
  end
99
99
 
100
100
  Then /^the year should be approximate\? "([^"]*)"$/ do |arg1|
101
- @date.approximate?(:year).should == !!(arg1 =~ /y(es)?/i)
101
+ expect(@date.approximate?(:year)).to eq(!!(arg1 =~ /y(es)?/i))
102
102
  end
103
103
 
104
104
  Then /^the month should be approximate\? "([^"]*)"$/ do |arg1|
105
- @date.approximate?(:month).should == !!(arg1 =~ /y(es)?/i)
105
+ expect(@date.approximate?(:month)).to eq(!!(arg1 =~ /y(es)?/i))
106
106
  end
107
107
 
108
108
  Then /^the day should be approximate\? "([^"]*)"$/ do |arg1|
109
- @date.approximate?(:day).should == !!(arg1 =~ /y(es)?/i)
109
+ expect(@date.approximate?(:day)).to eq(!!(arg1 =~ /y(es)?/i))
110
110
  end
111
111
 
112
112
 
113
113
  Then /^the unspecified string code be "([^"]*)"$/ do |arg1|
114
- @date.unspecified.to_s.should == arg1
114
+ expect(@date.unspecified.to_s).to eq(arg1)
115
115
  end
116
116
 
117
117
  When /^I parse the following strings an error should be raised:$/ do |table|
@@ -13,7 +13,7 @@ begin
13
13
  when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
14
14
  require 'rubinius/debugger'
15
15
  else
16
- require 'debugger'
16
+ require 'byebug'
17
17
  end
18
18
  rescue LoadError
19
19
  # ignore
@@ -13,7 +13,7 @@ class Date
13
13
  }.freeze
14
14
 
15
15
  EXTENDED_ATTRIBUTES = %w{
16
- calendar precision uncertain approximate unspecified
16
+ calendar precision uncertain approximate unspecified skip_timezone
17
17
  }.map(&:to_sym).freeze
18
18
 
19
19
  extend Forwardable
@@ -31,7 +31,7 @@ class Date
31
31
  end
32
32
  end
33
33
 
34
- attr_accessor :calendar
34
+ attr_accessor :calendar, :skip_timezone
35
35
 
36
36
  PRECISION.each do |p|
37
37
  define_method("#{p}_precision?") { precision == p }
@@ -162,6 +162,9 @@ class Date
162
162
  # Returns true if the Date has an EDTF calendar string attached.
163
163
  def calendar?; !!@calendar; end
164
164
 
165
+ # Returns true if the Date's EDTF string should be printed without timezone.
166
+ def skip_timezone?; !!@skip_timezone; end
167
+
165
168
  # Converts the Date into a season.
166
169
  def season
167
170
  Season.new(self)
@@ -192,7 +195,7 @@ class Date
192
195
  y << SYMBOLS[:approximate] if 24&h==8 || 27&h==26
193
196
 
194
197
 
195
- # combine if false-true-true and other m == d
198
+ # combine if false-true-true and other m == d
196
199
  if 7&h==6 && (48&h==48 || 48&h==0) || 56&h==48 && (6&h==6 || 6&h==0)
197
200
  m[0,0] = '('
198
201
  d << ')'