edtf 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e7e2bbb05637b4e710097d42429a9488e512a0da
4
+ data.tar.gz: 6d1035527b4f7395fe782551986a08d5ffd7b2d9
5
+ SHA512:
6
+ metadata.gz: 3fbc959b80bbc2b1215a8899f8713072f16700d75f210468ad30fb617f8f568ceec0d55e4dc92c21fa8d6604426b66d59af36faaed68db49d74bea134f2d5bef
7
+ data.tar.gz: b05c0b3be42feb8735b81a71d3839663ca6a9028c6a72457d68c8dfa95d80c24bfd1dd1545bed4dea5fdfcfc1681a1514aaa433fc281ce3bfb6312ed31fd121e
data/.gitignore CHANGED
@@ -2,4 +2,6 @@ Gemfile.lock
2
2
  lib/edtf/parser.rb
3
3
  lib/edtf/parser.output
4
4
  *.rbc
5
-
5
+ .rbx
6
+ .ruby-version
7
+ *.swp
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ bundler_args: --without debug extra
3
+ rvm:
4
+ - 2.0.0
5
+ - 1.9.2
6
+ - 1.9.3
7
+ # - jruby-18mode
8
+ # - jruby-19mode
9
+ - rbx-18mode
10
+ - rbx-19mode
11
+ - 1.8.7
12
+ - ree
13
+ notifications:
14
+ email:
15
+ - sk@semicolon.at
16
+ - namyra@gmail.com
17
+ on_success: change
18
+ on_failure: always
data/Gemfile CHANGED
@@ -1,10 +1,20 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  group :debug do
5
- gem 'ruby-debug19', :require => 'ruby-debug', :platforms => [:mri_19]
5
+ gem 'debugger', :platforms => [:mri_19, :mri_20]
6
6
  gem 'ruby-debug', :platforms => [:mri_18, :jruby]
7
- gem 'rbx-trepanning', :platforms => [:rbx]
7
+ end
8
+
9
+ group :development do
10
+ gem 'rake'
11
+ gem 'racc'
12
+ gem 'cucumber'
13
+ gem 'rspec'
14
+ end
15
+
16
+ group :extra do
17
+ gem 'ZenTest'
8
18
  end
9
19
 
10
20
  # active_support requires this
data/README.md CHANGED
@@ -12,16 +12,17 @@ EDTF-Ruby parser implements all levels and features of the EDTF specification
12
12
  (version September 16, 2011). With the following known caveats:
13
13
 
14
14
  * In the latest revision of the EDTF specification alternative versions of
15
- partial uncertain/approximate strings were introduced (with or without nested
16
- parentheses); EDTF-Ruby currently uses the version that tries to reduce
17
- parentheses for printing as we find that one easier to read; the
15
+ partial uncertain/approximate strings were introduced (with or without
16
+ nested parentheses); EDTF-Ruby currently uses the version that tries to
17
+ reduce parentheses for printing as we find that one easier to read; the
18
18
  parser accepts all valid dates using this approach, plus some dates using
19
19
  nested expressions (the parser will not accept some of the more complex
20
20
  examples, though).
21
21
 
22
22
  EDTF-Ruby has been confirmed to work on the following Ruby implementations:
23
- 1.9.3, 1.9.2, 1.8.7, Rubinius, and JRuby. Active Support's date extensions
24
- are currently listed as a dependency, because of many functional overlaps.
23
+ 2.0, 1.9.3, 1.9.2, 1.8.7, Rubinius, and JRuby. Active Support's date
24
+ extensions are currently listed as a dependency, because of many functional
25
+ overlaps.
25
26
 
26
27
 
27
28
  Quickstart
@@ -37,7 +38,7 @@ given a valid EDTF string the return value will either be an (extended) `Date`,
37
38
  Given any of these instances, you can print the corresponding EDTF string
38
39
  using the `#edtf` method.
39
40
 
40
- === Dates
41
+ ### Dates
41
42
 
42
43
  Most of the EDTF features deal with dates; EDTF-Ruby implements these by
43
44
  extending Active Support's version of the regular Ruby Date class. The library
@@ -155,7 +156,7 @@ When printing date strings, EDTF-Ruby will try to avoid nested parentheses:
155
156
  => "1999?-(02)?~-23?"
156
157
 
157
158
 
158
- === Intervals
159
+ ### Intervals
159
160
 
160
161
  If you parse an EDTF interval, the EDTF-Ruby parser will return an instance
161
162
  of `EDTF::Interval`; intervals mimic regular Ruby ranges, but offer additional
@@ -200,7 +201,7 @@ Intervals can be open or have unknown start or end dates.
200
201
  > Date.edtf('2004/open').cover?(Date.today)
201
202
  => true
202
203
 
203
- === Sets
204
+ ### Sets
204
205
 
205
206
  EDTF supports two kind of sets: choice lists (meaning one date out of a list),
206
207
  or inclusive lists. In EDTF-Ruby, these are covered by the class `EDTF::Set`
@@ -242,7 +243,7 @@ EDTF sets also feature an `#earlier?` and `#later?` attribute:
242
243
  => "[..1667, 1668, 1670..1672]"
243
244
 
244
245
 
245
- === Decades and Centuries
246
+ ### Decades and Centuries
246
247
 
247
248
  The EDTF specification supports so called masked precision strings to define
248
249
  decades or centuries. EDTF-Ruby maps these to dedicated intervals which
@@ -261,7 +262,7 @@ always cover 10 or 100 years, respectively.
261
262
  > d.map(&:year)
262
263
  => [1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969]
263
264
 
264
- === Seasons
265
+ ### Seasons
265
266
 
266
267
  Finally, EDTF covers seasons. Again, EDTF-Ruby provides a dedicated class
267
268
  for this. Note that EDTF does not make any assumption about the specifics
data/Rakefile CHANGED
@@ -1,9 +1,30 @@
1
- lib = File.expand_path('../lib/', __FILE__)
2
- $:.unshift lib unless $:.include?(lib)
3
1
 
4
- require 'rake/clean'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+
11
+ $:.unshift(File.join(File.dirname(__FILE__), './lib'))
5
12
  require 'edtf/version'
6
13
 
14
+ require 'rake/clean'
15
+
16
+ task :default => [:racc, :spec, :cucumber]
17
+
18
+ desc 'Run an IRB session with CiteProc loaded'
19
+ task :console, [:script] do |t,args|
20
+ ARGV.clear
21
+
22
+ require 'irb'
23
+ require 'edtf'
24
+
25
+ IRB.conf[:SCRIPT] = args.script
26
+ IRB.start
27
+ end
7
28
 
8
29
  desc 'Generates the parser'
9
30
  task :racc do
@@ -15,6 +36,15 @@ task :racc_debug do
15
36
  system 'bundle exec racc -v -t -o lib/edtf/parser.rb lib/edtf/parser.y'
16
37
  end
17
38
 
39
+ require 'rspec/core'
40
+ require 'rspec/core/rake_task'
41
+ RSpec::Core::RakeTask.new(:spec) do |spec|
42
+ spec.pattern = FileList['spec/**/*_spec.rb']
43
+ end
44
+
45
+ require 'cucumber/rake/task'
46
+ Cucumber::Rake::Task.new(:cucumber)
47
+
18
48
  desc 'Builds the gem file'
19
49
  task :build => [:racc] do
20
50
  system 'gem build edtf.gemspec'
@@ -22,6 +52,7 @@ end
22
52
 
23
53
  task :release => [:build] do
24
54
  system "git tag #{EDTF::VERSION}"
55
+ system "git push --tags"
25
56
  system "gem push edtf-#{EDTF::VERSION}.gem"
26
57
  end
27
58
 
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --format progress --require features --color
data/edtf.gemspec CHANGED
@@ -15,13 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.description = 'A Ruby implementation of the Extended Date/Time Format (EDTF).'
16
16
  s.license = 'FreeBSD'
17
17
 
18
- s.add_runtime_dependency('activesupport', ['~>3.0'])
19
-
20
- s.add_development_dependency('rake', ['~>0.9'])
21
- s.add_development_dependency('racc', ['~>1.4'])
22
- s.add_development_dependency('cucumber', ['~>1.0'])
23
- s.add_development_dependency('rspec', ['~>2.6'])
24
- s.add_development_dependency('ZenTest', ['~>4.6'])
18
+ s.add_runtime_dependency('activesupport', ['~>4.0'])
25
19
 
26
20
  s.files = `git ls-files`.split("\n") << 'lib/edtf/parser.rb'
27
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -30,7 +24,7 @@ Gem::Specification.new do |s|
30
24
 
31
25
  s.rdoc_options = %w{--line-numbers --inline-source --title "EDTF-Ruby" --main README.md --webcvs=http://github.com/inukshuk/edtf-ruby/tree/master/}
32
26
  s.extra_rdoc_files = %w{README.md LICENSE}
33
-
27
+
34
28
  end
35
29
 
36
- # vim: syntax=ruby
30
+ # vim: syntax=ruby
@@ -32,4 +32,10 @@ Feature: EDTF parses date/time strings
32
32
  | string | year | month | day | hours | minutes | seconds |
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
- | 2004-01-01T02:10:10+05:00 | 2003 | 12 | 31 | 21 | 10 | 10 |
35
+ | 2004-01-01T02:10:10+05:00 | 2003 | 12 | 31 | 21 | 10 | 10 |
36
+
37
+ # Scenarios: fractions
38
+ # | string | year | month | day | hours | minutes | seconds |
39
+ # | 2004-01-01T10 | 2004 | 1 | 1 | 10 | 0 | 0 |
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 |
@@ -1,8 +1,6 @@
1
1
 
2
2
  class DateTime
3
-
4
3
  def iso8601
5
4
  to_time.iso8601
6
5
  end unless method_defined?(:iso8601)
7
-
8
6
  end
data/lib/edtf/date.rb CHANGED
@@ -3,18 +3,18 @@ class Date
3
3
  PRECISION = [:year, :month, :day].freeze
4
4
  PRECISIONS = Hash[*PRECISION.map { |p| [p, "#{p}s".to_sym] }.flatten].freeze
5
5
 
6
- FORMATS = %w{ %04d %02d %02d }.freeze
6
+ FORMATS = %w{ %04d %02d %02d }.freeze
7
7
 
8
- SYMBOLS = {
9
- :uncertain => '?',
10
- :approximate => '~',
11
- :calendar => '^',
12
- :unspecified => 'u'
13
- }.freeze
14
-
8
+ SYMBOLS = {
9
+ :uncertain => '?',
10
+ :approximate => '~',
11
+ :calendar => '^',
12
+ :unspecified => 'u'
13
+ }.freeze
14
+
15
15
  EXTENDED_ATTRIBUTES = %w{ calendar precision uncertain approximate
16
16
  unspecified }.map(&:to_sym).freeze
17
-
17
+
18
18
  extend Forwardable
19
19
 
20
20
  class << self
@@ -47,8 +47,8 @@ class Date
47
47
 
48
48
 
49
49
  def initialize_copy(other)
50
- super
51
- copy_extended_attributes(other)
50
+ super
51
+ copy_extended_attributes(other)
52
52
  end
53
53
 
54
54
 
@@ -79,7 +79,7 @@ class Date
79
79
  @precision ||= :day
80
80
  end
81
81
 
82
- # Sets this Date/Time's precision to the passed-in value.
82
+ # Sets this Date/Time's precision to the passed-in value.
83
83
  def precision=(precision)
84
84
  precision = precision.to_sym
85
85
  raise ArgumentError, "invalid precision #{precision.inspect}" unless PRECISION.include?(precision)
@@ -157,7 +157,7 @@ class Date
157
157
  def season?; false; end
158
158
 
159
159
  # Returns true if the Date has an EDTF calendar string attached.
160
- def calendar?; !!@calendar; end
160
+ def calendar?; !!@calendar; end
161
161
 
162
162
  # Converts the Date into a season.
163
163
  def season
@@ -166,10 +166,10 @@ class Date
166
166
 
167
167
  # Returns the Date's EDTF string.
168
168
  def edtf
169
- return "y#{year}" if long_year?
170
-
171
- s = FORMATS.take(values.length).zip(values).map { |f,v| f % v }
172
- s = unspecified.mask(s)
169
+ return "y#{year}" if long_year?
170
+
171
+ s = FORMATS.take(values.length).zip(values).map { |f,v| f % v }
172
+ s = unspecified.mask(s)
173
173
 
174
174
  unless (h = ua_hash).zero?
175
175
  #
@@ -217,24 +217,24 @@ class Date
217
217
  end
218
218
 
219
219
  s = s.join('-')
220
- s << SYMBOLS[:calendar] << calendar if calendar?
221
- s
220
+ s << SYMBOLS[:calendar] << calendar if calendar?
221
+ s
222
222
  end
223
223
 
224
- alias to_edtf edtf
225
-
226
- # Returns an array of the next n days, months, or years depending on the
227
- # current Date/Time's precision.
224
+ alias to_edtf edtf
225
+
226
+ # Returns an array of the next n days, months, or years depending on the
227
+ # current Date/Time's precision.
228
228
  def next(n = 1)
229
- 1.upto(n).map { |by| advance(PRECISIONS[precision] => by) }
229
+ 1.upto(n).map { |by| advance(PRECISIONS[precision] => by) }
230
230
  end
231
231
 
232
- def succ
233
- advance(PRECISIONS[precision] => 1)
234
- end
232
+ def succ
233
+ advance(PRECISIONS[precision] => 1)
234
+ end
235
235
 
236
- # Returns the Date of the previous day, month, or year depending on the
237
- # current Date/Time's precision.
236
+ # Returns the Date of the previous day, month, or year depending on the
237
+ # current Date/Time's precision.
238
238
  def prev(n = 1)
239
239
  if n > 1
240
240
  1.upto(n).map { |by| advance(PRECISIONS[precision] => -by) }
@@ -244,36 +244,42 @@ class Date
244
244
  end
245
245
 
246
246
  def <=>(other)
247
- return nil unless other.is_a?(::Date)
248
- values <=> other.values
247
+ case other
248
+ when ::Date
249
+ values <=> other.values
250
+ when EDTF::Interval, EDTF::Season, EDTF::Epoch
251
+ other.cover?(self) ? other.min <=> self : 0
252
+ else
253
+ nil
254
+ end
249
255
  end
250
256
 
251
257
 
252
- # Returns an array of the current year, month, and day values filtered by
253
- # the Date/Time's precision.
258
+ # Returns an array of the current year, month, and day values filtered by
259
+ # the Date/Time's precision.
254
260
  def values
255
261
  precision_filter.map { |p| send(p) }
256
262
  end
257
263
 
258
264
  # Returns the same date but with negated year.
259
265
  def negate
260
- change(:year => year * -1)
266
+ change(:year => year * -1)
261
267
  end
262
268
 
263
269
  alias -@ negate
264
270
 
265
- # Returns true if this Date/Time has year precision and the year exceeds four digits.
266
- def long_year?
267
- year_precision? && year.abs > 9999
268
- end
269
-
270
-
271
+ # Returns true if this Date/Time has year precision and the year exceeds four digits.
272
+ def long_year?
273
+ year_precision? && year.abs > 9999
274
+ end
275
+
276
+
271
277
  private
272
-
273
- def ua_hash
274
- uncertain.hash + approximate.hash
275
- end
276
-
278
+
279
+ def ua_hash
280
+ uncertain.hash + approximate.hash
281
+ end
282
+
277
283
  def precision_filter
278
284
  @precision_filter ||= update_precision_filter
279
285
  end
data/lib/edtf/season.rb CHANGED
@@ -39,7 +39,7 @@ module EDTF
39
39
  alias fall? autumn?
40
40
  alias fall! autumn!
41
41
 
42
- [:first, :second, :third, :fourth].zip(SEASONS.values).each do |quarter, season|
42
+ [:first, :second, :third, :fourth].zip([:spring, :summer, :autumn, :winter]).each do |quarter, season|
43
43
  alias_method("#{quarter}?", "#{season}?")
44
44
  alias_method("#{quarter}!", "#{season}!")
45
45
  end
data/lib/edtf/set.rb CHANGED
@@ -44,11 +44,11 @@ module EDTF
44
44
  end
45
45
 
46
46
  def edtf
47
- parenthesize(dates.map { |d| d.respond_to?(:edtf) ? d.edtf : d.to_s }.join(', '))
47
+ parenthesize(dates.map { |d| d.respond_to?(:edtf) ? d.edtf : d.to_s }.sort.join(', '))
48
48
  end
49
49
 
50
50
  def to_a
51
- dates.map { |d| Array(d) }.flatten
51
+ dates.map { |d| Array(d) }.flatten.sort
52
52
  end
53
53
 
54
54
  def to_set
data/lib/edtf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module EDTF
2
- VERSION = '1.0.0'.freeze
3
- end
2
+ VERSION = '2.0.0'.freeze
3
+ end
@@ -1,72 +1,71 @@
1
1
  module EDTF
2
2
  describe 'Interval' do
3
-
3
+
4
4
  describe 'the interval 2008/2011' do
5
5
  let(:interval) { Date.edtf('2008/2011') }
6
6
 
7
- it { interval.should_not be_open }
7
+ it { interval.should_not be_open }
8
8
  it { interval.should_not be_open_end }
9
9
  it { interval.should_not be_unknown_start }
10
10
  it { interval.should_not be_unknown_end }
11
-
12
- it 'has a length of 4' do
13
- interval.to_a.length.should == 4
14
- end
15
-
16
- it '#step(2) yields the years 2008 and 2010' do
17
- interval.step(2).map(&:year).should == [2008,2010]
18
- end
19
-
20
- it 'the max date is 2011-12-31' do
21
- interval.max.to_s.should == '2011-12-31'
22
- end
23
-
24
- it 'the max date has year precision' do
25
- interval.max.should be_year_precision
26
- end
27
-
28
- it 'the min date is 2008-01-01' do
29
- interval.min.to_s.should == '2008-01-01'
30
- end
31
-
32
- it 'the min date has year precision' do
33
- interval.min.should be_year_precision
34
- end
35
-
36
-
11
+
12
+ it 'has a length of 4' do
13
+ interval.to_a.length.should == 4
14
+ end
15
+
16
+ it '#step(2) yields the years 2008 and 2010' do
17
+ interval.step(2).map(&:year).should == [2008,2010]
18
+ end
19
+
20
+ it 'the max date is 2011-12-31' do
21
+ interval.max.to_s.should == '2011-12-31'
22
+ end
23
+
24
+ it 'the max date has year precision' do
25
+ interval.max.should be_year_precision
26
+ end
27
+
28
+ it 'the min date is 2008-01-01' do
29
+ interval.min.to_s.should == '2008-01-01'
30
+ end
31
+
32
+ it 'the min date has year precision' do
33
+ interval.min.should be_year_precision
34
+ end
35
+
36
+
37
37
  it 'includes the years 2008, 2009, 2010 and 2011' do
38
38
  interval.to_a.map(&:year).should == [2008, 2009, 2010, 2011]
39
39
  end
40
-
40
+
41
41
  it 'does not include christmas day 2009' do
42
42
  interval.should_not be_include(Date.new(2009,12,24))
43
43
  end
44
44
 
45
- it 'christmas day 2009 is less than max' do
46
- Date.new(2009,12,24).should < interval.max
47
- end
45
+ it 'christmas day 2009 is less than max' do
46
+ Date.new(2009,12,24).should < interval.max
47
+ end
48
+
49
+ it 'christmas day 2009 is greater than min' do
50
+ Date.new(2009,12,24).should > interval.min
51
+ end
48
52
 
49
- it 'christmas day 2009 is greater than min' do
50
- Date.new(2009,12,24).should > interval.min
51
- end
52
-
53
53
  it 'covers christmas day 2009' do
54
54
  interval.should be_cover(Date.new(2009,12,24))
55
55
  end
56
-
56
+
57
57
  it 'covers 2011-12-31' do
58
58
  interval.should be_cover(Date.new(2011,12,31))
59
59
  end
60
-
61
60
  end
62
61
 
63
62
  describe 'the interval 2008-08-23/2011-07-01' do
64
63
  let(:interval) { Date.edtf('2008-08-23/2011-07-01') }
65
-
64
+
66
65
  it 'includes christmas day 2009' do
67
66
  interval.should be_include(Date.new(2009,12,24))
68
67
  end
69
-
68
+
70
69
  it 'covers christmas day 2009' do
71
70
  interval.should be_cover(Date.new(2009,12,24))
72
71
  end
@@ -79,24 +78,24 @@ module EDTF
79
78
  describe 'the interval 2008-08-23/open' do
80
79
  let(:interval) { Date.edtf('2008-08-23/open') }
81
80
 
82
- it { interval.should be_open }
83
- it { interval.should be_open_end }
84
- it { interval.should_not be_unknown }
85
- it { interval.should_not be_unknown_start }
86
- it { interval.should_not be_unknown_end }
87
-
88
- it 'the min date is 2008-08-23' do
89
- interval.min.should == Date.new(2008,8,23)
90
- end
91
-
92
- it 'the max date is nil' do
93
- interval.max.should be nil
94
- end
95
-
81
+ it { interval.should be_open }
82
+ it { interval.should be_open_end }
83
+ it { interval.should_not be_unknown }
84
+ it { interval.should_not be_unknown_start }
85
+ it { interval.should_not be_unknown_end }
86
+
87
+ it 'the min date is 2008-08-23' do
88
+ interval.min.should == Date.new(2008,8,23)
89
+ end
90
+
91
+ it 'the max date is nil' do
92
+ interval.max.should be nil
93
+ end
94
+
96
95
  it 'includes christmas day 2009' do
97
96
  interval.should be_include(Date.new(2009,12,24))
98
97
  end
99
-
98
+
100
99
  it 'covers christmas day 2009' do
101
100
  interval.should be_cover(Date.new(2009,12,24))
102
101
  end
@@ -104,37 +103,34 @@ module EDTF
104
103
  it 'covers 2023-07-02' do
105
104
  interval.should be_cover(Date.new(2023,07,02))
106
105
  end
107
-
108
- end
109
-
110
- describe 'comparisions' do
111
-
112
- it '2007/2009 should be greater than 2001/2002' do
113
- Date.edtf('2007/2009').should > Date.edtf('2001/2002')
114
- end
115
106
 
116
- it '2007/2009 should be less than 2011/2012' do
117
- Date.edtf('2007/2009').should < Date.edtf('2011/2012')
118
- end
107
+ end
119
108
 
120
- it '2007/2009 should be less than 2008/2009' do
121
- Date.edtf('2007/2009').should < Date.edtf('2008/2009')
122
- end
109
+ describe 'comparisions' do
110
+ it '2007/2009 should be greater than 2001/2002' do
111
+ Date.edtf('2007/2009').should > Date.edtf('2001/2002')
112
+ end
113
+
114
+ it '2007/2009 should be less than 2011/2012' do
115
+ Date.edtf('2007/2009').should < Date.edtf('2011/2012')
116
+ end
123
117
 
124
- it '2007/2009 should be greater than 2007/2008' do
125
- Date.edtf('2007/2009').should > Date.edtf('2007/2008')
126
- end
118
+ it '2007/2009 should be less than 2008/2009' do
119
+ Date.edtf('2007/2009').should < Date.edtf('2008/2009')
120
+ end
127
121
 
128
- it '2007/2009 should be greater than 2006/2007' do
129
- Date.edtf('2007/2009').should > Date.edtf('2006/2007')
130
- end
122
+ it '2007/2009 should be greater than 2007/2008' do
123
+ Date.edtf('2007/2009').should > Date.edtf('2007/2008')
124
+ end
131
125
 
132
- it '2007/2009 should be equal to 2007/2009' do
133
- Date.edtf('2007/2009').should == Date.edtf('2007/2009')
134
- end
126
+ it '2007/2009 should be greater than 2006/2007' do
127
+ Date.edtf('2007/2009').should > Date.edtf('2006/2007')
128
+ end
135
129
 
130
+ it '2007/2009 should be equal to 2007/2009' do
131
+ Date.edtf('2007/2009').should == Date.edtf('2007/2009')
132
+ end
133
+ end
136
134
 
137
-
138
- end
139
135
  end
140
136
  end
@@ -1,56 +1,56 @@
1
1
  module EDTF
2
2
  describe 'Seasons' do
3
3
  let(:subject) { Season.new }
4
- let(:summer) { Season.new(:summer) }
5
- let(:winter) { Season.new(:winter) }
6
-
7
-
8
- describe 'uncertain/approximate' do
9
-
10
- it 'is certain by default' do
11
- subject.should be_certain
12
- subject.should_not be_uncertain
13
- end
14
-
15
- it 'is precise by default' do
16
- subject.should be_precise
17
- subject.should_not be_approximate
18
- end
19
-
20
- describe '#approximate!' do
21
- it 'makes the season approximate' do
22
- subject.approximate!.should be_approximate
23
- subject.approximate!.should_not be_precise
24
- end
25
- end
26
-
27
- describe '#uncertain!' do
28
- it 'makes the season uncertain' do
29
- subject.uncertain!.should be_uncertain
30
- subject.uncertain!.should_not be_certain
31
- end
32
- end
33
-
34
- end
35
-
36
- describe '#succ' do
37
-
38
- it 'returns a season' do
39
- summer.succ.should be_instance_of(Season)
40
- end
41
-
42
- it 'it returns a season that is greater than the original one' do
43
- summer.succ.should > summer
44
- end
45
-
46
- it 'the successor of the winter season is spring of the following year' do
47
- spring = winter.succ
48
- spring.should be_spring
49
- spring.year.should == winter.year + 1
50
- end
51
-
52
- end
53
-
4
+ let(:summer) { Season.new(:summer) }
5
+ let(:winter) { Season.new(:winter) }
6
+
7
+
8
+ describe 'uncertain/approximate' do
9
+
10
+ it 'is certain by default' do
11
+ subject.should be_certain
12
+ subject.should_not be_uncertain
13
+ end
14
+
15
+ it 'is precise by default' do
16
+ subject.should be_precise
17
+ subject.should_not be_approximate
18
+ end
19
+
20
+ describe '#approximate!' do
21
+ it 'makes the season approximate' do
22
+ subject.approximate!.should be_approximate
23
+ subject.approximate!.should_not be_precise
24
+ end
25
+ end
26
+
27
+ describe '#uncertain!' do
28
+ it 'makes the season uncertain' do
29
+ subject.uncertain!.should be_uncertain
30
+ subject.uncertain!.should_not be_certain
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ describe '#succ' do
37
+
38
+ it 'returns a season' do
39
+ summer.succ.should be_instance_of(Season)
40
+ end
41
+
42
+ it 'it returns a season that is greater than the original one' do
43
+ summer.succ.should > summer
44
+ end
45
+
46
+ it 'the successor of the winter season is spring of the following year' do
47
+ spring = winter.succ
48
+ spring.should be_spring
49
+ spring.year.should == winter.year + 1
50
+ end
51
+
52
+ end
53
+
54
54
  describe '#season?' do
55
55
  it 'returns true by default' do
56
56
  subject.should be_season
@@ -59,12 +59,12 @@ module EDTF
59
59
 
60
60
  describe '#season' do
61
61
  before(:each) { subject.season = :summer }
62
-
62
+
63
63
  it 'returns the season code' do
64
64
  subject.season.should == :summer
65
65
  end
66
66
  end
67
-
67
+
68
68
  describe '#season=' do
69
69
  it 'sets the season code when called with a valid season code' do
70
70
  lambda {
@@ -73,15 +73,15 @@ module EDTF
73
73
  end
74
74
  }.should_not raise_error
75
75
  end
76
-
76
+
77
77
  it 'throws an exception if given invalid season code' do
78
78
  lambda { subject.season = 13 }.should raise_error
79
79
  end
80
80
  end
81
81
 
82
- describe '#winter!' do
83
- it 'sets the season to :winter' do
84
- lambda { subject.winter! }.should change { subject.season }.to(:winter)
82
+ describe '#summer!' do
83
+ it 'sets the season to :summer' do
84
+ lambda { subject.summer! }.should change { subject.season }.to(:summer)
85
85
  end
86
86
  end
87
87
 
@@ -97,14 +97,14 @@ module EDTF
97
97
  end
98
98
 
99
99
  describe '#include?' do
100
-
100
+
101
101
  context 'for summer' do
102
102
  it 'returns true for August 24' do
103
103
  Season.new(1980, :summer).should include(Date.new(1980,8,24))
104
104
  end
105
105
  end
106
-
106
+
107
107
  end
108
-
108
+
109
109
  end
110
110
  end
metadata CHANGED
@@ -1,82 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edtf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sylvester Keil
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-11-10 00:00:00.000000000 Z
11
+ date: 2013-12-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
- requirement: &70108307717900 !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: '3.0'
19
+ version: '4.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70108307717900
25
- - !ruby/object:Gem::Dependency
26
- name: rake
27
- requirement: &70108307716720 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '0.9'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70108307716720
36
- - !ruby/object:Gem::Dependency
37
- name: racc
38
- requirement: &70108307715280 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: '1.4'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70108307715280
47
- - !ruby/object:Gem::Dependency
48
- name: cucumber
49
- requirement: &70108307714220 !ruby/object:Gem::Requirement
50
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - ~>
53
25
  - !ruby/object:Gem::Version
54
- version: '1.0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70108307714220
58
- - !ruby/object:Gem::Dependency
59
- name: rspec
60
- requirement: &70108307713500 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ~>
64
- - !ruby/object:Gem::Version
65
- version: '2.6'
66
- type: :development
67
- prerelease: false
68
- version_requirements: *70108307713500
69
- - !ruby/object:Gem::Dependency
70
- name: ZenTest
71
- requirement: &70108307712900 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- version: '4.6'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *70108307712900
26
+ version: '4.0'
80
27
  description: A Ruby implementation of the Extended Date/Time Format (EDTF).
81
28
  email:
82
29
  - http://sylvester.keil.or.at
@@ -89,10 +36,12 @@ files:
89
36
  - .autotest
90
37
  - .gitignore
91
38
  - .rspec
39
+ - .travis.yml
92
40
  - Gemfile
93
41
  - LICENSE
94
42
  - README.md
95
43
  - Rakefile
44
+ - cucumber.yml
96
45
  - edtf.gemspec
97
46
  - features/parser/date_times.feature
98
47
  - features/parser/dates.feature
@@ -130,40 +79,33 @@ files:
130
79
  homepage: http://github.com/inukshuk/edtf-ruby
131
80
  licenses:
132
81
  - FreeBSD
82
+ metadata: {}
133
83
  post_install_message:
134
84
  rdoc_options:
135
85
  - --line-numbers
136
86
  - --inline-source
137
87
  - --title
138
- - ! '"EDTF-Ruby"'
88
+ - '"EDTF-Ruby"'
139
89
  - --main
140
90
  - README.md
141
91
  - --webcvs=http://github.com/inukshuk/edtf-ruby/tree/master/
142
92
  require_paths:
143
93
  - lib
144
94
  required_ruby_version: !ruby/object:Gem::Requirement
145
- none: false
146
95
  requirements:
147
- - - ! '>='
96
+ - - '>='
148
97
  - !ruby/object:Gem::Version
149
98
  version: '0'
150
- segments:
151
- - 0
152
- hash: -2732104332429493129
153
99
  required_rubygems_version: !ruby/object:Gem::Requirement
154
- none: false
155
100
  requirements:
156
- - - ! '>='
101
+ - - '>='
157
102
  - !ruby/object:Gem::Version
158
103
  version: '0'
159
- segments:
160
- - 0
161
- hash: -2732104332429493129
162
104
  requirements: []
163
105
  rubyforge_project:
164
- rubygems_version: 1.8.10
106
+ rubygems_version: 2.1.8
165
107
  signing_key:
166
- specification_version: 3
108
+ specification_version: 4
167
109
  summary: Extended Date/Time Format for Ruby.
168
110
  test_files:
169
111
  - features/parser/date_times.feature