edtf 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,12 @@
1
+ module EDTF
2
+ describe 'Interval' do
3
+ describe 'when it ends in 2008' do
4
+
5
+ let(:interval) { Interval.new(Date.new(2007), Date.new(2008)) }
6
+
7
+ it 'should include any day in the year 2008' do
8
+ interval.should include(Date.new(2008, 12, 31))
9
+ end
10
+ end
11
+ end
12
+ end
@@ -2,7 +2,7 @@ module EDTF
2
2
  describe Parser do
3
3
  describe '#parse' do
4
4
 
5
- it 'parses simple dates' do
5
+ it 'parses simple dates "2001-02-03"' do
6
6
  Parser.new.parse('2001-02-03').to_s.should == '2001-02-03'
7
7
  end
8
8
 
@@ -10,6 +10,10 @@ module EDTF
10
10
  Parser.new.parse('-2323').to_s.should == '-2323-01-01'
11
11
  end
12
12
 
13
+ it 'parses the negative year -2101 and sets the precision to :year' do
14
+ Parser.new.parse('-2101').should be_year_precision
15
+ end
16
+
13
17
  it 'parses year zero' do
14
18
  Parser.new.parse('0000').to_s.should == '0000-01-01'
15
19
  end
@@ -20,11 +24,12 @@ module EDTF
20
24
 
21
25
  it 'parses simple intervals like "2007/2008"' do
22
26
  Parser.new.parse('2007/2008').should include(Date.new(2007,12,24))
23
- Parser.new.parse('2007/2008').should_not include(Date.new(2008,1,2))
27
+ Parser.new.parse('2007/2008').should include(Date.new(2008,1,2))
28
+ Parser.new.parse('2007/2008').should_not include(Date.new(2009,1,2))
24
29
  end
25
30
 
26
31
  it 'parses uncertain dates' do
27
- Parser.new.parse('1984?').should be_uncertain
32
+ Parser.new.parse('1984?').should be_uncertain
28
33
  Parser.new.parse('1984').should be_certain
29
34
  end
30
35
 
@@ -1,35 +1,28 @@
1
1
  module EDTF
2
2
  describe 'Seasons' do
3
- let(:subject) { Date.new }
3
+ let(:subject) { Season.new }
4
4
 
5
5
  describe '#season?' do
6
- it 'returns false by default' do
7
- subject.should_not be_season
8
- end
9
-
10
- context 'when a season code is set' do
11
- before(:all) { subject.season = 21 }
12
- it 'returns true if a season code is set' do
13
- subject.should be_season
14
- end
6
+ it 'returns true by default' do
7
+ subject.should be_season
15
8
  end
16
9
  end
17
-
10
+
18
11
  describe '#season' do
19
- before(:each) { subject.season = 21 }
12
+ before(:each) { subject.season = :summer }
20
13
 
21
14
  it 'returns the season code' do
22
- subject.season.should == 21
15
+ subject.season.should == :summer
23
16
  end
24
17
  end
25
18
 
26
19
  describe '#season=' do
27
20
  it 'sets the season code when called with a valid season code' do
28
- lambda do
21
+ lambda {
29
22
  (21..22).each do |i|
30
23
  subject.season = i
31
24
  end
32
- end.should_not raise_error
25
+ }.should_not raise_error
33
26
  end
34
27
 
35
28
  it 'throws an exception if given invalid season code' do
@@ -38,22 +31,31 @@ module EDTF
38
31
  end
39
32
 
40
33
  describe '#winter!' do
41
- it 'sets the season code to 24' do
42
- lambda { subject.winter! }.should change { subject.season }.to(24)
34
+ it 'sets the season to :winter' do
35
+ lambda { subject.winter! }.should change { subject.season }.to(:winter)
43
36
  end
44
37
  end
45
38
 
46
39
  describe '#winter?' do
47
- it 'returns true if the season code is 24' do
48
- subject.season = 24
40
+ it 'returns true if the season is set to :winter' do
41
+ subject.season = :winter
49
42
  subject.should be_winter
50
43
  end
51
- it 'returns false if the season code is not 24' do
52
- subject.season = 23
44
+ it 'returns false if the season is not set to :winter' do
45
+ subject.season = :summer
53
46
  subject.should_not be_winter
54
47
  end
55
48
  end
56
49
 
50
+ describe '#include?' do
51
+
52
+ context 'for summer' do
53
+ it 'returns true for August 24' do
54
+ Season.new(1980, :summer).should include(Date.new(1980,8,24))
55
+ end
56
+ end
57
+
58
+ end
57
59
 
58
60
  end
59
61
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,3 @@
1
1
  $LOAD_PATH << File.expand_path('../../lib', __FILE__)
2
2
 
3
- require 'rubygems'
4
3
  require 'edtf'
5
-
6
- RSpec.configuration do |c|
7
-
8
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edtf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-15 00:00:00.000000000Z
12
+ date: 2011-08-21 00:00:00.000000000Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &2156677080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2156677080
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: rake
16
- requirement: &2157012300 !ruby/object:Gem::Requirement
27
+ requirement: &2156676480 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
@@ -21,10 +32,10 @@ dependencies:
21
32
  version: '0.9'
22
33
  type: :development
23
34
  prerelease: false
24
- version_requirements: *2157012300
35
+ version_requirements: *2156676480
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: racc
27
- requirement: &2156999280 !ruby/object:Gem::Requirement
38
+ requirement: &2156675960 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ~>
@@ -32,10 +43,10 @@ dependencies:
32
43
  version: '1.4'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *2156999280
46
+ version_requirements: *2156675960
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: cucumber
38
- requirement: &2156998780 !ruby/object:Gem::Requirement
49
+ requirement: &2156675420 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ~>
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '1.0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *2156998780
57
+ version_requirements: *2156675420
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rspec
49
- requirement: &2156998280 !ruby/object:Gem::Requirement
60
+ requirement: &2156674860 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ~>
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '2.6'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *2156998280
68
+ version_requirements: *2156674860
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: ZenTest
60
- requirement: &2156997760 !ruby/object:Gem::Requirement
71
+ requirement: &2156674380 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ~>
@@ -65,7 +76,7 @@ dependencies:
65
76
  version: '4.6'
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *2156997760
79
+ version_requirements: *2156674380
69
80
  description: An Extended Date/Time Format (EDTF) Parser for Ruby.
70
81
  email:
71
82
  - http://sylvester.keil.or.at
@@ -88,20 +99,26 @@ files:
88
99
  - features/parser/intervals.feature
89
100
  - features/parser/precision.feature
90
101
  - features/parser/unspecified.feature
102
+ - features/print/level_1_edtf.feature
103
+ - features/print/level_2_edtf.feature
91
104
  - features/step_definitions/edtf_steps.rb
92
105
  - features/support/env.rb
93
106
  - lib/edtf.rb
94
107
  - lib/edtf/compatibility.rb
95
108
  - lib/edtf/date.rb
96
109
  - lib/edtf/date_time.rb
110
+ - lib/edtf/epoch.rb
97
111
  - lib/edtf/extensions.rb
98
112
  - lib/edtf/interval.rb
99
113
  - lib/edtf/parser.y
100
- - lib/edtf/seasons.rb
114
+ - lib/edtf/season.rb
101
115
  - lib/edtf/uncertainty.rb
102
116
  - lib/edtf/version.rb
117
+ - spec/edtf/date_spec.rb
118
+ - spec/edtf/epoch_spec.rb
119
+ - spec/edtf/interval_spec.rb
103
120
  - spec/edtf/parser_spec.rb
104
- - spec/edtf/seasons_spec.rb
121
+ - spec/edtf/season_spec.rb
105
122
  - spec/edtf/uncertainty_spec.rb
106
123
  - spec/spec_helper.rb
107
124
  - lib/edtf/parser.rb
@@ -143,9 +160,14 @@ test_files:
143
160
  - features/parser/intervals.feature
144
161
  - features/parser/precision.feature
145
162
  - features/parser/unspecified.feature
163
+ - features/print/level_1_edtf.feature
164
+ - features/print/level_2_edtf.feature
146
165
  - features/step_definitions/edtf_steps.rb
147
166
  - features/support/env.rb
167
+ - spec/edtf/date_spec.rb
168
+ - spec/edtf/epoch_spec.rb
169
+ - spec/edtf/interval_spec.rb
148
170
  - spec/edtf/parser_spec.rb
149
- - spec/edtf/seasons_spec.rb
171
+ - spec/edtf/season_spec.rb
150
172
  - spec/edtf/uncertainty_spec.rb
151
173
  - spec/spec_helper.rb
data/lib/edtf/seasons.rb DELETED
@@ -1,36 +0,0 @@
1
- module EDTF
2
-
3
- module Seasons
4
-
5
- attr_reader :season
6
-
7
- def season?; !!@season; end
8
-
9
- def season=(new_season)
10
- case new_season
11
- when 1, 2, 3, 4
12
- @season = new_season + 20
13
- when 21, 22, 23, 24
14
- @season = new_season
15
- else
16
- raise ArgumentError, "bad season format (21, 22, 23 or 24 expected; was #{new_season.inspect})"
17
- end
18
- end
19
-
20
- [:first, :second, :third, :fourth].zip((21..24).to_a).each do |quarter, code|
21
- define_method("#{quarter}?") { @season == code }
22
- define_method("#{quarter}!") { @season = code }
23
- end
24
-
25
- [:spring, :summer, :autumn, :winter].zip([:first, :second, :third, :fourth]).each do |season, quarter|
26
- alias_method("#{season}?", "#{quarter}?")
27
- alias_method("#{season}!", "#{quarter}!")
28
- end
29
-
30
- attr_accessor :qualifier
31
-
32
- def qualified?; !!@qualifier; end
33
-
34
- end
35
-
36
- end