flexyear 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03f0180f05ab5d01948b0a24796cbfd9a7b23970
4
- data.tar.gz: cfaa51b4ed1ebae6f300a629cd1d500b3a1ab7e2
3
+ metadata.gz: c600ec9615d1a122bb9a76973bfaaa44c38e9b38
4
+ data.tar.gz: 60878b3ded358e15414b064e64266aadcde5b22c
5
5
  SHA512:
6
- metadata.gz: b48806ae6b6b7658b7b0893a56bcfbb3ee28dbec7991cc3bad224495bb66ec3a8fd57fafbffd6a1b92c482ad431fbae6e21a215a0c62451fdb87c40e38cad2e5
7
- data.tar.gz: 82427042b5d194fdc6afe64fc615e638ff9a4c7252071f76bb6cb6b4b2dc9cfd5c66ddaa724962d614985432cc921cb599dbea10fbd680beae595a958b73bdd0
6
+ metadata.gz: faa9538ccd247cad361ccaa8d7061e0d5850a274a46f5f1b90e24d7472cd14234e7c8926482955ba123c76f65450e2b457a73ffbcbac823595bd45949ff7e4f8
7
+ data.tar.gz: 631f4828f79dd5e188ae9a81774c4ce6a18f3406427b104267eb86f12b4825fa255d15a1633c3f8d46fd85181068aa5cf15b79db8d33e85e227f9ce36a1b70e7
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.0.3
2
+ - Bugfix: FlexYear::Historical was broken in 0.0.2 when dealing with date
3
+ ranges
1
4
  0.0.2
2
5
  - Refactor main parser code into parser subclasses (@tmaier)
3
6
  - Remove ReissueParser, moved to Reverb codebase as it's not generic
@@ -80,7 +80,7 @@ class FlexYear
80
80
  def parse_year
81
81
  super
82
82
 
83
- if @base_year > DateTime.now.year
83
+ if @year_low > DateTime.now.year || @year_high > DateTime.now.year
84
84
  raise InvalidYearError, "The year must be in the past. You specified #{@base_year}; Today is #{DateTime.now.year}"
85
85
  end
86
86
  end
@@ -1,3 +1,3 @@
1
1
  class FlexYear
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,179 +1,181 @@
1
1
  require 'flexyear'
2
2
 
3
3
  describe FlexYear do
4
- context "given a blank string" do
5
- subject { FlexYear.new("") }
6
- its(:year_low) { should eq(0) }
7
- its(:year_high) { should eq(0) }
8
- end
9
-
10
- context "given nil" do
11
- subject { FlexYear.new(nil) }
12
- its(:year_low) { should eq(0) }
13
- its(:year_high) { should eq(0) }
14
- end
15
-
16
- context "text" do
17
- subject { FlexYear.new("something") }
18
- its(:year_low) { should eq(0) }
19
- its(:year_high) { should eq(0) }
20
- end
21
-
22
- context "given 1979 as number" do
23
- subject { FlexYear.new(1979) }
24
- its(:year_low) { should eq(1979) }
25
- its(:year_high) { should eq(1979) }
26
- end
27
-
28
- context "given 1979" do
29
- subject { FlexYear.new("1979") }
30
- its(:year_low) { should eq(1979) }
31
- its(:year_high) { should eq(1979) }
32
- end
4
+ [FlexYear, FlexYear::Historical].each do |flexyear_class|
5
+ context "given a blank string" do
6
+ subject { flexyear_class.new("") }
7
+ its(:year_low) { should eq(0) }
8
+ its(:year_high) { should eq(0) }
9
+ end
33
10
 
34
- context "given 1970s" do
35
- subject { FlexYear.new("1970s") }
36
- its(:year_low) { should eq(1970) }
37
- its(:year_high) { should eq(1979) }
38
- end
11
+ context "given nil" do
12
+ subject { flexyear_class.new(nil) }
13
+ its(:year_low) { should eq(0) }
14
+ its(:year_high) { should eq(0) }
15
+ end
39
16
 
40
- context "given 70s" do
41
- subject { FlexYear.new("70s") }
42
- its(:year_low) { should eq(1970) }
43
- its(:year_high) { should eq(1979) }
44
- end
17
+ context "text" do
18
+ subject { flexyear_class.new("something") }
19
+ its(:year_low) { should eq(0) }
20
+ its(:year_high) { should eq(0) }
21
+ end
45
22
 
46
- context "given something with negative and dots" do
47
- subject { FlexYear.new("approx.-2006") }
48
- its(:year_low) { should eq(2005) }
49
- its(:year_high) { should eq(2007) }
50
- end
23
+ context "given 1979 as number" do
24
+ subject { flexyear_class.new(1979) }
25
+ its(:year_low) { should eq(1979) }
26
+ its(:year_high) { should eq(1979) }
27
+ end
51
28
 
52
- ["mid 1970s", "mid 70s", "mid-70s", "mid-70's"].each do |year|
53
- context "given #{year}" do
54
- subject { FlexYear.new(year) }
55
- its(:year_low) { should eq(1973) }
56
- its(:year_high) { should eq(1976) }
57
- its(:to_s) { should eq(year) }
29
+ context "given 1979" do
30
+ subject { flexyear_class.new("1979") }
31
+ its(:year_low) { should eq(1979) }
32
+ its(:year_high) { should eq(1979) }
58
33
  end
59
- end
60
34
 
61
- ["early 1970s", "early 70s", "early-70s", "early 70's"].each do |year|
62
- context "given #{year}" do
63
- subject { FlexYear.new(year) }
35
+ context "given 1970s" do
36
+ subject { flexyear_class.new("1970s") }
64
37
  its(:year_low) { should eq(1970) }
65
- its(:year_high) { should eq(1973) }
38
+ its(:year_high) { should eq(1979) }
66
39
  end
67
- end
68
40
 
69
- ["late 1970s", "late 70s", "late -70s", "late 70 s"].each do |year|
70
- context "given #{year}" do
71
- subject { FlexYear.new(year) }
72
- its(:year_low) { should eq(1976) }
41
+ context "given 70s" do
42
+ subject { flexyear_class.new("70s") }
43
+ its(:year_low) { should eq(1970) }
73
44
  its(:year_high) { should eq(1979) }
74
45
  end
75
- end
76
46
 
77
- ["73-75", "1973-1975", "1973 - 1975", "1973- 1975", "1973 -1975", "1973-75"].each do |range|
78
- context "given a range #{range}" do
79
- subject { FlexYear.new(range) }
80
- its(:year_low) { should eq(1973) }
81
- its(:year_high) { should eq(1975) }
47
+ context "given something with negative and dots" do
48
+ subject { flexyear_class.new("approx.-2006") }
49
+ its(:year_low) { should eq(2005) }
50
+ its(:year_high) { should eq(2007) }
82
51
  end
83
- end
84
-
85
- context "given a range 1975-1973 (from high to low)" do
86
- subject { FlexYear.new('1975-1973') }
87
- its(:year_low) { should eq(1973) }
88
- its(:year_high) { should eq(1975) }
89
- end
90
52
 
91
- context "given a range" do
92
- ["2003-4", "2003-04"].each do |range|
93
- subject { FlexYear.new(range) }
94
- its(:year_low) { should eq(2003) }
95
- its(:year_high) { should eq(2004) }
53
+ ["mid 1970s", "mid 70s", "mid-70s", "mid-70's"].each do |year|
54
+ context "given #{year}" do
55
+ subject { flexyear_class.new(year) }
56
+ its(:year_low) { should eq(1973) }
57
+ its(:year_high) { should eq(1976) }
58
+ its(:to_s) { should eq(year) }
59
+ end
96
60
  end
97
- end
98
61
 
99
- context 'given a circa' do
100
- context 'at the end of the string' do
101
- subject { FlexYear.new('1973 (Circa)') }
102
- its(:year_low) { should eq(1972) }
103
- its(:year_high) { should eq(1974) }
62
+ ["early 1970s", "early 70s", "early-70s", "early 70's"].each do |year|
63
+ context "given #{year}" do
64
+ subject { flexyear_class.new(year) }
65
+ its(:year_low) { should eq(1970) }
66
+ its(:year_high) { should eq(1973) }
67
+ end
104
68
  end
105
69
 
106
- context 'at the beginning of the string' do
107
- subject { FlexYear.new('Circa 1973') }
108
- its(:year_low) { should eq(1972) }
109
- its(:year_high) { should eq(1974) }
70
+ ["late 1970s", "late 70s", "late -70s", "late 70 s"].each do |year|
71
+ context "given #{year}" do
72
+ subject { flexyear_class.new(year) }
73
+ its(:year_low) { should eq(1976) }
74
+ its(:year_high) { should eq(1979) }
75
+ end
110
76
  end
111
77
 
112
- context 'abbreviated' do
113
- subject { FlexYear.new('ca 1973') }
114
- its(:year_low) { should eq(1972) }
115
- its(:year_high) { should eq(1974) }
78
+ ["73-75", "1973-1975", "1973 - 1975", "1973- 1975", "1973 -1975", "1973-75"].each do |range|
79
+ context "given a range #{range}" do
80
+ subject { flexyear_class.new(range) }
81
+ its(:year_low) { should eq(1973) }
82
+ its(:year_high) { should eq(1975) }
83
+ end
116
84
  end
117
85
 
118
- context 'with dots' do
119
- subject { FlexYear.new('c.a. 1973') }
120
- its(:year_low) { should eq(1972) }
121
- its(:year_high) { should eq(1974) }
86
+ context "given a range 1975-1973 (from high to low)" do
87
+ subject { flexyear_class.new('1975-1973') }
88
+ its(:year_low) { should eq(1973) }
89
+ its(:year_high) { should eq(1975) }
122
90
  end
123
91
 
124
- context 'with c.' do
125
- subject { FlexYear.new('c. 1973') }
126
- its(:year_low) { should eq(1972) }
127
- its(:year_high) { should eq(1974) }
92
+ context "given a range" do
93
+ ["2003-4", "2003-04"].each do |range|
94
+ subject { flexyear_class.new(range) }
95
+ its(:year_low) { should eq(2003) }
96
+ its(:year_high) { should eq(2004) }
97
+ end
128
98
  end
129
99
 
130
- context 'with ca.' do
131
- subject { FlexYear.new('ca. 1973') }
132
- its(:year_low) { should eq(1972) }
133
- its(:year_high) { should eq(1974) }
134
- end
100
+ context 'given a circa' do
101
+ context 'at the end of the string' do
102
+ subject { flexyear_class.new('1973 (Circa)') }
103
+ its(:year_low) { should eq(1972) }
104
+ its(:year_high) { should eq(1974) }
105
+ end
135
106
 
136
- context 'with approx.' do
137
- subject { FlexYear.new('approx. 1973') }
138
- its(:year_low) { should eq(1972) }
139
- its(:year_high) { should eq(1974) }
140
- end
107
+ context 'at the beginning of the string' do
108
+ subject { flexyear_class.new('Circa 1973') }
109
+ its(:year_low) { should eq(1972) }
110
+ its(:year_high) { should eq(1974) }
111
+ end
141
112
 
142
- context 'with appxly.' do
143
- subject { FlexYear.new('appxly 1973') }
144
- its(:year_low) { should eq(1972) }
145
- its(:year_high) { should eq(1974) }
146
- end
113
+ context 'abbreviated' do
114
+ subject { flexyear_class.new('ca 1973') }
115
+ its(:year_low) { should eq(1972) }
116
+ its(:year_high) { should eq(1974) }
117
+ end
147
118
 
148
- context 'with around' do
149
- subject { FlexYear.new('around 1973') }
150
- its(:year_low) { should eq(1972) }
151
- its(:year_high) { should eq(1974) }
152
- end
119
+ context 'with dots' do
120
+ subject { flexyear_class.new('c.a. 1973') }
121
+ its(:year_low) { should eq(1972) }
122
+ its(:year_high) { should eq(1974) }
123
+ end
153
124
 
154
- context 'with about' do
155
- subject { FlexYear.new('about 1973') }
156
- its(:year_low) { should eq(1972) }
157
- its(:year_high) { should eq(1974) }
158
- end
125
+ context 'with c.' do
126
+ subject { flexyear_class.new('c. 1973') }
127
+ its(:year_low) { should eq(1972) }
128
+ its(:year_high) { should eq(1974) }
129
+ end
159
130
 
160
- context 'with circ' do
161
- subject { FlexYear.new('circ. 1973') }
162
- its(:year_low) { should eq(1972) }
163
- its(:year_high) { should eq(1974) }
164
- end
131
+ context 'with ca.' do
132
+ subject { flexyear_class.new('ca. 1973') }
133
+ its(:year_low) { should eq(1972) }
134
+ its(:year_high) { should eq(1974) }
135
+ end
165
136
 
166
- context 'with cca' do
167
- subject { FlexYear.new('cca 1973') }
168
- its(:year_low) { should eq(1972) }
169
- its(:year_high) { should eq(1974) }
170
- end
137
+ context 'with approx.' do
138
+ subject { flexyear_class.new('approx. 1973') }
139
+ its(:year_low) { should eq(1972) }
140
+ its(:year_high) { should eq(1974) }
141
+ end
171
142
 
172
- end
143
+ context 'with appxly.' do
144
+ subject { flexyear_class.new('appxly 1973') }
145
+ its(:year_low) { should eq(1972) }
146
+ its(:year_high) { should eq(1974) }
147
+ end
148
+
149
+ context 'with around' do
150
+ subject { flexyear_class.new('around 1973') }
151
+ its(:year_low) { should eq(1972) }
152
+ its(:year_high) { should eq(1974) }
153
+ end
154
+
155
+ context 'with about' do
156
+ subject { flexyear_class.new('about 1973') }
157
+ its(:year_low) { should eq(1972) }
158
+ its(:year_high) { should eq(1974) }
159
+ end
160
+
161
+ context 'with circ' do
162
+ subject { flexyear_class.new('circ. 1973') }
163
+ its(:year_low) { should eq(1972) }
164
+ its(:year_high) { should eq(1974) }
165
+ end
166
+
167
+ context 'with cca' do
168
+ subject { flexyear_class.new('cca 1973') }
169
+ its(:year_low) { should eq(1972) }
170
+ its(:year_high) { should eq(1974) }
171
+ end
172
+
173
+ end
173
174
 
174
- context "given 12345 (five digit year)" do
175
- specify do
176
- expect { FlexYear.new('12345') }.to raise_error(FlexYear::InvalidYearError)
175
+ context "given 12345 (five digit year)" do
176
+ specify do
177
+ expect { flexyear_class.new('12345') }.to raise_error(FlexYear::InvalidYearError)
178
+ end
177
179
  end
178
180
  end
179
181
 
@@ -184,4 +186,5 @@ describe FlexYear do
184
186
  end
185
187
  end
186
188
  end
189
+
187
190
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexyear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Melnick & Yan Pritzker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-21 00:00:00.000000000 Z
11
+ date: 2013-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler