edtf 3.0.8 → 3.1.1

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
  SHA256:
3
- metadata.gz: 79b11e60a9c93e8708e3176ac04cecf8a63ea0df9fdbae09aa0c5583d4829632
4
- data.tar.gz: d8cb5d2aefdb707bbd7dc44de1bdc9e470f8198e699fc5bad7ba2a3acd7e2eba
3
+ metadata.gz: 750afc3b14ecab6a3cc5501ce4b3e8f70bc330c446049967912a44b73a5295b2
4
+ data.tar.gz: a0f03a70d0a4e83e1a71fdee6d19ec85edc17c36707ba0df6f60f7006dc83914
5
5
  SHA512:
6
- metadata.gz: b8972cc08117bc4b0b015c7f1f07004a0d5e28f972350d4c3eb0b57ee67e5fcdfa6b4e666f4ee3df5c8478f35852d647f1000de64b0bda9416c5f7f3351c5aef
7
- data.tar.gz: c197e8bffc0377e3d52a841544525b1a8cbf47e5eb1708b6560b6eaf0db7fc6c37371de8e65af3e000e343294da7c51a5d4c378e9f877500ba994548f42a750a
6
+ metadata.gz: 5a25877fc5a242cfc8e936610ae0b4a1cbeb6d71bc0befd2173cafedcaa738c2aaab2f45d9e246ae999dcb73931a504260fec2c2f18a17f512c16d87bc91de81
7
+ data.tar.gz: d00ae2cc4681b6cabdaec8231347e2c3c9674eb7bfc90d3b599b7d10675ec080af3f4527124b84735490e798b824ad69640edba9122f289f8de181aa3a3b2633
@@ -0,0 +1,41 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ build:
11
+ environment: CI
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby-version:
17
+ - '2.7'
18
+ - '3.0'
19
+ - '3.1'
20
+ - '3.2'
21
+ - 'jruby'
22
+
23
+ steps:
24
+ - name: Git checkout
25
+ uses: actions/checkout@v2
26
+
27
+ - name: Setup Ruby
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby-version }}
31
+ bundler-cache: true
32
+
33
+ - name: Run tests
34
+ run: bundle exec rake
35
+
36
+ - name: Upload coverage results
37
+ if: matrix.ruby-version == '3.1'
38
+ continue-on-error: true
39
+ uses: coverallsapp/github-action@master
40
+ with:
41
+ github-token: ${{ github.token }}
data/.simplecov CHANGED
@@ -1,4 +1,19 @@
1
+ require 'simplecov-lcov'
2
+
3
+ SimpleCov::Formatter::LcovFormatter.config do |c|
4
+ c.output_directory = 'coverage'
5
+ c.lcov_file_name = 'lcov.info'
6
+ c.report_with_single_file = true
7
+ end
8
+
9
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
10
+ SimpleCov::Formatter::HTMLFormatter,
11
+ SimpleCov::Formatter::LcovFormatter
12
+ ])
13
+
1
14
  SimpleCov.start do
2
15
  add_filter 'spec/'
3
16
  add_filter 'features/'
17
+
18
+ enable_coverage :branch
4
19
  end
data/Gemfile CHANGED
@@ -2,20 +2,16 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  group :debug do
5
- gem 'ruby-debug', :require => false, :platform => :jruby
6
- gem 'byebug', :require => false, :platform => :mri
7
- gem 'rubinius-compiler', '~>2.0', :require => false, :platform => :rbx
8
- gem 'rubinius-debugger', '~>2.0', :require => false, :platform => :rbx
5
+ gem 'debug', platform: 'mri'
9
6
  end
10
7
 
11
8
  group :development do
12
9
  gem 'rake'
13
- gem 'racc', :platform => :ruby
10
+ gem 'racc'
14
11
  gem 'cucumber'
15
- gem 'rspec', '~>3.0'
16
- gem 'simplecov', :require => false
17
- gem 'rubinius-coverage', :platform => :rbx
18
- gem 'coveralls', '~>0.8', :require => false
12
+ gem 'rspec'
13
+ gem 'simplecov', platform: 'mri'
14
+ gem 'simplecov-lcov', platform: 'mri'
19
15
  end
20
16
 
21
17
  group :extra do
@@ -24,13 +20,3 @@ end
24
20
 
25
21
  # active_support requires this
26
22
  gem 'i18n'
27
-
28
- platform :rbx do
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'
35
- gem 'json'
36
- end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2011-2016 Sylvester Keil. All rights reserved.
1
+ Copyright 2011-2022 Sylvester Keil. All rights reserved.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions are met:
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  EDTF-Ruby
2
2
  =========
3
- [![Build Status](https://travis-ci.org/inukshuk/edtf-ruby.png?branch=master)](https://travis-ci.org/inukshuk/edtf-ruby)
4
- [![Coverage Status](https://coveralls.io/repos/inukshuk/edtf-ruby/badge.png)](https://coveralls.io/r/inukshuk/edtf-ruby)
3
+ [![ci](https://github.com/inukshuk/edtf-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/inukshuk/edtf-ruby/actions/workflows/ci.yml)
4
+ [![Coverage Status](https://coveralls.io/repos/github/inukshuk/edtf-ruby/badge.svg?branch=main)](https://coveralls.io/github/inukshuk/edtf-ruby?branch=main)
5
5
 
6
6
  EDTF-Ruby comprises a parser and an API implementation of the [Extended
7
7
  Date/Time Format standard](http://www.loc.gov/standards/datetime/).
@@ -135,9 +135,11 @@ state of dates in Ruby:
135
135
  As you can see above, you can use the bang! methods to set individual date
136
136
  parts.
137
137
 
138
- In addition, EDTF supports *unspecified* date parts:
138
+ In addition, EDTF supports *unspecified* date parts. EDTF-Ruby provides parsing
139
+ for both the draft and finalized EDTF specifications, with output meeting the
140
+ requirements of the final specification:
139
141
 
140
- > d = Date.edtf('1999-03-uu')
142
+ > d = Date.edtf('1999-03-XX')
141
143
  > d.unspecified?
142
144
  => true
143
145
  > d.unspecified? :year
@@ -146,7 +148,11 @@ In addition, EDTF supports *unspecified* date parts:
146
148
  => true
147
149
  > d.unspecified! :month
148
150
  > d.edtf
149
- => "1999-uu-uu"
151
+ => "1999-XX-XX"
152
+
153
+ > draft_d = Date.edtf('1999-03-uu')
154
+ > draft_d.edtf
155
+ => "1999-03-XX"
150
156
 
151
157
  All three, uncertain, approximate, and unspecified attributes do not factor
152
158
  into date calculations (like comparisons or successors etc.).
@@ -334,8 +340,7 @@ and submit a pull request.
334
340
 
335
341
  Credits
336
342
  -------
337
- EDTF-Ruby was written by [Sylvester Keil](http://sylvester.keil.or.at) and
338
- [Namyra](https://github.com/namyra).
343
+ EDTF-Ruby was written by Sylvester Keil and Ilja Srna.
339
344
 
340
345
  Published under the terms and conditions of the FreeBSD License; see LICENSE
341
346
  for details.
data/Rakefile CHANGED
@@ -50,10 +50,6 @@ task :build => [:check_warnings] do
50
50
  system 'gem build edtf.gemspec'
51
51
  end
52
52
 
53
- require 'coveralls/rake/task'
54
- Coveralls::RakeTask.new
55
- task :test_with_coveralls => [:spec, :cucumber, 'coveralls:push']
56
-
57
53
  task :check_warnings do
58
54
  $VERBOSE = true
59
55
  require 'edtf'
data/cucumber.yml CHANGED
@@ -1 +1 @@
1
- default: --format progress --require features --color
1
+ default: --format progress --require features --color --publish-quiet
data/edtf.gemspec CHANGED
@@ -8,8 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.name = 'edtf'
9
9
  s.version = EDTF::VERSION.dup
10
10
  s.platform = Gem::Platform::RUBY
11
- s.authors = ['Sylvester Keil']
12
- s.email = ['http://sylvester.keil.or.at']
11
+ s.authors = ['Sylvester Keil', 'Ilja Srna']
13
12
  s.homepage = 'http://github.com/inukshuk/edtf-ruby'
14
13
  s.summary = 'Extended Date/Time Format for Ruby.'
15
14
  s.description = 'A Ruby implementation of the Extended Date/Time Format (EDTF).'
@@ -9,15 +9,26 @@ Feature: Parse unspecified date strings
9
9
  And the day should be "<day>"
10
10
  And the unspecified string code be "<unspecified>"
11
11
 
12
- @102 @level1
12
+ @102 @level1 @draft
13
13
  Scenarios: examples from the specification draft
14
14
  | string | year | month | day | unspecified |
15
- | 199u | 1990 | 1 | 1 | sssu-ss-ss |
16
- | 19uu | 1900 | 1 | 1 | ssuu-ss-ss |
17
- | 1999-uu | 1999 | 1 | 1 | ssss-uu-ss |
18
- | 1999-02-uu | 1999 | 2 | 1 | ssss-ss-uu |
19
- | 1999-uu-uu | 1999 | 1 | 1 | ssss-uu-uu |
15
+ | 199u | 1990 | 1 | 1 | sssX-ss-ss |
16
+ | 19uu | 1900 | 1 | 1 | ssXX-ss-ss |
17
+ | 1999-uu | 1999 | 1 | 1 | ssss-XX-ss |
18
+ | 1999-02-uu | 1999 | 2 | 1 | ssss-ss-XX |
19
+ | 1999-uu-uu | 1999 | 1 | 1 | ssss-XX-XX |
20
+
21
+ @102 @level1 @final
22
+ Scenarios: examples from the specification draft
23
+ | string | year | month | day | unspecified |
24
+ | 199X | 1990 | 1 | 1 | sssX-ss-ss |
25
+ | 19XX | 1900 | 1 | 1 | ssXX-ss-ss |
26
+ | 1999-XX | 1999 | 1 | 1 | ssss-XX-ss |
27
+ | 1999-02-XX | 1999 | 2 | 1 | ssss-ss-XX |
28
+ | 1999-XX-XX | 1999 | 1 | 1 | ssss-XX-XX |
20
29
 
21
30
  Scenario: Completely unknown
22
31
  When I parse the string "uuuu"
23
32
  Then the result should be an Unknown
33
+ When I parse the string "XXXX"
34
+ Then the result should be an Unknown
@@ -1,21 +1,21 @@
1
1
  Feature: Print Date/Time objects as Level 1 EDTF strings
2
2
  As a Ruby programmer
3
3
  I want to convert Date/Time objects to EDTF strings
4
-
4
+
5
5
  @101 @level1
6
6
  Scenario: Uncertain or approximate dates
7
7
  When I parse the string "2001?"
8
8
  When I convert the date
9
9
  Then the EDTF string should be "2001?"
10
-
10
+
11
11
  When I parse the string "2004-06?"
12
12
  When I convert the date
13
13
  Then the EDTF string should be "2004-06?"
14
-
14
+
15
15
  When I parse the string "2004-06-11?"
16
16
  When I convert the date
17
17
  Then the EDTF string should be "2004-06-11?"
18
-
18
+
19
19
  When I parse the string "1984~"
20
20
  When I convert the date
21
21
  Then the EDTF string should be "1984~"
@@ -23,28 +23,50 @@ Feature: Print Date/Time objects as Level 1 EDTF strings
23
23
  When I parse the string "1984?~"
24
24
  When I convert the date
25
25
  Then the EDTF string should be "1984?~"
26
-
27
- @102 @level1
26
+
27
+ @102 @level1 @draft
28
28
  Scenario: Unspecified dates
29
29
  When I parse the string "199u"
30
30
  When I convert the date
31
- Then the EDTF string should be "199u"
31
+ Then the EDTF string should be "199X"
32
32
 
33
33
  When I parse the string "19uu"
34
34
  When I convert the date
35
- Then the EDTF string should be "19uu"
35
+ Then the EDTF string should be "19XX"
36
36
 
37
37
  When I parse the string "1999-uu"
38
38
  When I convert the date
39
- Then the EDTF string should be "1999-uu"
39
+ Then the EDTF string should be "1999-XX"
40
40
 
41
41
  When I parse the string "1999-01-uu"
42
42
  When I convert the date
43
- Then the EDTF string should be "1999-01-uu"
43
+ Then the EDTF string should be "1999-01-XX"
44
+
45
+ When I parse the string "1999-XX-XX"
46
+ When I convert the date
47
+ Then the EDTF string should be "1999-XX-XX"
48
+
49
+ @102 @level1 @final
50
+ Scenario: Unspecified dates
51
+ When I parse the string "199X"
52
+ When I convert the date
53
+ Then the EDTF string should be "199X"
54
+
55
+ When I parse the string "19XX"
56
+ When I convert the date
57
+ Then the EDTF string should be "19XX"
58
+
59
+ When I parse the string "1999-XX"
60
+ When I convert the date
61
+ Then the EDTF string should be "1999-XX"
62
+
63
+ When I parse the string "1999-01-XX"
64
+ When I convert the date
65
+ Then the EDTF string should be "1999-01-XX"
44
66
 
45
- When I parse the string "1999-uu-uu"
67
+ When I parse the string "1999-XX-XX"
46
68
  When I convert the date
47
- Then the EDTF string should be "1999-uu-uu"
69
+ Then the EDTF string should be "1999-XX-XX"
48
70
 
49
71
  @103 @level1 @interval
50
72
  Scenario: Prints L1 Extended Intervals
@@ -88,19 +110,28 @@ Feature: Print Date/Time objects as Level 1 EDTF strings
88
110
  When I convert the date
89
111
  Then the EDTF string should be "1984-06-02?/unknown"
90
112
 
91
- @104 @level1
113
+ @104 @level1 @draft
92
114
  Scenario: Prints years with more than four digits
93
115
  When I parse the string "y170000002"
94
116
  When I convert the date
95
- Then the EDTF string should be "y170000002"
117
+ Then the EDTF string should be "Y170000002"
96
118
 
97
119
  When I parse the string "y-170000002"
98
120
  When I convert the date
99
- Then the EDTF string should be "y-170000002"
121
+ Then the EDTF string should be "Y-170000002"
122
+
123
+ @104 @level1 @final
124
+ Scenario: Prints years with more than four digits
125
+ When I parse the string "Y170000002"
126
+ When I convert the date
127
+ Then the EDTF string should be "Y170000002"
128
+
129
+ When I parse the string "Y-170000002"
130
+ When I convert the date
131
+ Then the EDTF string should be "Y-170000002"
100
132
 
101
133
  @105 @level1 @season
102
134
  Scenario: Prints seasons
103
135
  When I parse the string "2001-21"
104
136
  When I convert the date
105
137
  Then the EDTF string should be "2001-21"
106
-
@@ -1,12 +1,16 @@
1
1
  Feature: Print Date/Time objects as Level 2 EDTF strings
2
2
  As a Ruby programmer
3
3
  I want to convert Date/Time objects to EDTF strings
4
-
4
+
5
5
  @202 @level2
6
6
  Scenario: Prints internal unspecified dates
7
7
  When I parse the string "156u-12-25"
8
8
  When I convert the date
9
- Then the EDTF string should be "156u-12-25"
9
+ Then the EDTF string should be "156X-12-25"
10
+
11
+ When I parse the string "156X-12-25"
12
+ When I convert the date
13
+ Then the EDTF string should be "156X-12-25"
10
14
 
11
15
  @205 @level2 @interval
12
16
  Scenario: Prints L2 extended intervals
@@ -16,7 +20,11 @@ Feature: Print Date/Time objects as Level 2 EDTF strings
16
20
 
17
21
  When I parse the string "2004-06-uu/2004-07-03"
18
22
  When I convert the date
19
- Then the EDTF string should be "2004-06-uu/2004-07-03"
23
+ Then the EDTF string should be "2004-06-XX/2004-07-03"
24
+
25
+ When I parse the string "2004-06-XX/2004-07-03"
26
+ When I convert the date
27
+ Then the EDTF string should be "2004-06-XX/2004-07-03"
20
28
 
21
29
  @209 @level2 @season
22
30
  Scenario: Prints qualified seasons
@@ -1,20 +1,11 @@
1
1
  begin
2
2
  require 'simplecov'
3
- require 'coveralls' if ENV['CI']
4
3
  rescue LoadError
5
4
  # ignore
6
5
  end
7
6
 
8
7
  begin
9
- case
10
- when RUBY_PLATFORM < 'java'
11
- require 'debug'
12
- Debugger.start
13
- when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
14
- require 'rubinius/debugger'
15
- else
16
- require 'byebug'
17
- end
8
+ require 'debug' unless RUBY_PLATFORM == 'java'
18
9
  rescue LoadError
19
10
  # ignore
20
11
  end
data/lib/edtf/date.rb CHANGED
@@ -9,7 +9,7 @@ class Date
9
9
  :uncertain => '?',
10
10
  :approximate => '~',
11
11
  :calendar => '^',
12
- :unspecified => 'u'
12
+ :unspecified => 'X'
13
13
  }.freeze
14
14
 
15
15
  EXTENDED_ATTRIBUTES = %w{
@@ -172,7 +172,7 @@ class Date
172
172
 
173
173
  # Returns the Date's EDTF string.
174
174
  def edtf
175
- return "y#{year}" if long_year?
175
+ return "Y#{year}" if long_year?
176
176
 
177
177
  v = values
178
178
  s = FORMATS.take(v.length).zip(v).map { |f,d| f % d.abs }
data/lib/edtf/interval.rb CHANGED
@@ -211,9 +211,9 @@ module EDTF
211
211
  # used to compare values (slower). Returns nil if the first date of the
212
212
  # interval is larger than the last or if the interval has an unknown or
213
213
  # open start.
214
- def min
214
+ def min(&block)
215
215
  if block_given?
216
- to_a.min(&Proc.new)
216
+ to_a.min(&block)
217
217
  else
218
218
  case
219
219
  when unknown_start?, !unknown_end? && !open? && to < from
@@ -244,9 +244,9 @@ module EDTF
244
244
  # To calculate the dates, precision is taken into account. Thus, the max
245
245
  # Date of "2007/2008" would be 2008-12-31, whilst the max Date of
246
246
  # "2007-12/2008-10" would be 2009-10-31.
247
- def max
247
+ def max(&block)
248
248
  if block_given?
249
- to_a.max(&Proc.new)
249
+ to_a.max(&block)
250
250
  else
251
251
  case
252
252
  when open_end?, unknown_end?, !unknown_start? && to < from