icu_utils 1.1.1 → 1.2.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: f97cfbd598b1e453a7e2dcf3de583f60ba462d75
4
+ data.tar.gz: 525cbf547ee580ada1da81cbf4da119361a0c353
5
+ SHA512:
6
+ metadata.gz: cfa42575c3b40cec0f6aa7f531f6db3192009dd44599ab600ef800ca196d65c6b147b1c3825e4daf9799276f699464ec945ba0afdbfc463b6fd5919849fb13ec
7
+ data.tar.gz: eb0da907423c6d21a4b44c2ca4a8be8de670b4758b06947709dbaa8aadd55fb0a9b272a118376807524ab2c34f58e2a9e442c6f3e00ddea0befbd795f9989c93
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --colour
2
- --format nested
2
+ --format doc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p353
data/Gemfile.lock CHANGED
@@ -1,30 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- icu_utils (1.1.1)
4
+ icu_utils (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.2.5)
10
10
  json (1.8.1)
11
- rake (10.1.0)
12
- rdoc (4.0.1)
11
+ rake (10.3.2)
12
+ rdoc (4.1.1)
13
13
  json (~> 1.4)
14
- rspec (2.14.1)
15
- rspec-core (~> 2.14.0)
16
- rspec-expectations (~> 2.14.0)
17
- rspec-mocks (~> 2.14.0)
18
- rspec-core (2.14.7)
19
- rspec-expectations (2.14.4)
20
- diff-lcs (>= 1.1.3, < 2.0)
21
- rspec-mocks (2.14.4)
14
+ rspec (3.0.0)
15
+ rspec-core (~> 3.0.0)
16
+ rspec-expectations (~> 3.0.0)
17
+ rspec-mocks (~> 3.0.0)
18
+ rspec-core (3.0.4)
19
+ rspec-support (~> 3.0.0)
20
+ rspec-expectations (3.0.4)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.0.0)
23
+ rspec-mocks (3.0.4)
24
+ rspec-support (~> 3.0.0)
25
+ rspec-support (3.0.4)
22
26
 
23
27
  PLATFORMS
24
28
  ruby
25
29
 
26
30
  DEPENDENCIES
27
- bundler (~> 1.3)
31
+ bundler
28
32
  icu_utils!
29
33
  rake
30
34
  rdoc
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A place for utilities shared across the various ICU apps and gems.
4
4
 
5
- So far just includes a class to handle FIDE federations.
5
+ Includes a class to handle FIDE federations and one to do date validation.
6
6
 
7
7
  ## Installation
8
8
 
data/icu_utils.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.test_files = s.files.grep(%r{^(spec)/})
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_development_dependency "bundler", "~> 1.3"
21
+ s.add_development_dependency "bundler"
22
22
  s.add_development_dependency "rake"
23
23
  s.add_development_dependency "rspec"
24
24
  s.add_development_dependency "rdoc"
@@ -0,0 +1,72 @@
1
+ module ICU
2
+ # Reproduce some of the functionality of validates_timeliness, a gem no longer maintained.
3
+ class Date
4
+ attr_reader :date, :reasons
5
+
6
+ def initialize(date, constraints={})
7
+ @reasons = []
8
+ if @date = to_date(date)
9
+ @constraints = constraints.each_with_object({}) do |(k,v), h|
10
+ if %i[after on_or_after before on_or_before].include?(k)
11
+ unless h[k] = to_date(v)
12
+ raise ArgumentError.new("invalid date specified for #{k} constraint")
13
+ end
14
+ else
15
+ raise ArgumentError.new("invalid date constraint #{k}")
16
+ end
17
+ end
18
+ else
19
+ @reasons.push "errors.messages.invalid_date"
20
+ end
21
+ end
22
+
23
+ def valid?
24
+ valid = true
25
+ if @date
26
+ if valid && @constraints[:after] && @date <= @constraints[:after]
27
+ valid = false
28
+ @reasons.push "errors.messages.after"
29
+ @reasons.push restriction: @constraints[:after].to_s
30
+ end
31
+ if valid && @constraints[:before] && @date >= @constraints[:before]
32
+ valid = false
33
+ @reasons.push "errors.messages.before"
34
+ @reasons.push restriction: @constraints[:before].to_s
35
+ end
36
+ if valid && @constraints[:on_or_after] && @date < @constraints[:on_or_after]
37
+ valid = false
38
+ @reasons.push "errors.messages.on_or_after"
39
+ @reasons.push restriction: @constraints[:on_or_after].to_s
40
+ end
41
+ if valid && @constraints[:on_or_before] && @date > @constraints[:on_or_before]
42
+ valid = false
43
+ @reasons.push "errors.messages.on_or_before"
44
+ @reasons.push restriction: @constraints[:on_or_before].to_s
45
+ end
46
+ else
47
+ valid = false
48
+ end
49
+ valid
50
+ end
51
+
52
+ # after: must be after %{restriction}
53
+ # before: must be before %{restriction}
54
+ # invalid: invalid
55
+ # invalid_date: invalid date
56
+ # on_or_after: must be on or after %{restriction}
57
+ # on_or_before: must be on or before %{restriction}
58
+
59
+ private
60
+
61
+ def to_date(thing)
62
+ if thing.is_a?(Date)
63
+ thing.dup
64
+ else
65
+ thing = ::Date.parse(thing.to_s)
66
+ end
67
+ thing
68
+ rescue
69
+ nil
70
+ end
71
+ end
72
+ end
@@ -1,3 +1,3 @@
1
1
  module IcuUtils
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
data/lib/icu_utils.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  require 'icu_utils/version'
2
2
  require 'icu_utils/federation'
3
+ require 'icu_utils/date'
data/spec/date_spec.rb ADDED
@@ -0,0 +1,174 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module ICU
4
+ describe Date do
5
+ context "no constraints" do
6
+ it "today" do
7
+ today = ICU::Date.new(::Date.today)
8
+ expect(today).to be_valid
9
+ expect(today.date).to eq ::Date.today
10
+ expect(today.reasons).to be_empty
11
+ end
12
+
13
+ it "now" do
14
+ now = ICU::Date.new(Time.now)
15
+ expect(now).to be_valid
16
+ expect(now.date).to eq ::Date.today
17
+ expect(now.reasons).to be_empty
18
+ end
19
+
20
+ it "human" do
21
+ now = ICU::Date.new("9th November 1955")
22
+ expect(now).to be_valid
23
+ expect(now.date).to eq ::Date.new(1955, 11, 9)
24
+ expect(now.reasons).to be_empty
25
+ end
26
+
27
+ it "abbreviated" do
28
+ now = ICU::Date.new("June 16 1986")
29
+ expect(now).to be_valid
30
+ expect(now.date).to eq ::Date.new(1986, 6, 16)
31
+ expect(now.reasons).to be_empty
32
+ end
33
+
34
+ it "invalid" do
35
+ invalid = ICU::Date.new("rubbish")
36
+ expect(invalid).to_not be_valid
37
+ expect(invalid.reasons).to_not be_empty
38
+ expect(invalid.reasons.size).to eq 1
39
+ expect(invalid.reasons.first).to eq "errors.messages.invalid_date"
40
+ end
41
+
42
+ it "impossible" do
43
+ invalid = ICU::Date.new("2014-02-30")
44
+ expect(invalid).to_not be_valid
45
+ expect(invalid.reasons).to_not be_empty
46
+ expect(invalid.reasons.size).to eq 1
47
+ expect(invalid.reasons.first).to eq "errors.messages.invalid_date"
48
+ end
49
+ end
50
+
51
+ context "after" do
52
+ it "today/yesterday" do
53
+ d = ICU::Date.new(::Date.today, after: ::Date.today - 1)
54
+ expect(d).to be_valid
55
+ expect(d.date).to eq ::Date.today
56
+ expect(d.reasons).to be_empty
57
+ end
58
+
59
+ it "yesterday/today" do
60
+ d = ICU::Date.new(::Date.today - 1, after: ::Date.today)
61
+ expect(d).to_not be_valid
62
+ expect(d.date).to eq ::Date.today - 1
63
+ expect(d.reasons[0]).to eq "errors.messages.after"
64
+ expect(d.reasons[1]).to eq restriction: ::Date.today.to_s
65
+ end
66
+
67
+ it "today/today" do
68
+ d = ICU::Date.new(::Date.today, after: ::Date.today)
69
+ expect(d).to_not be_valid
70
+ expect(d.date).to eq ::Date.today
71
+ expect(d.reasons[0]).to eq "errors.messages.after"
72
+ expect(d.reasons[1]).to eq restriction: ::Date.today.to_s
73
+ end
74
+
75
+ it "invalid" do
76
+ expect{ICU::Date.new(::Date.today, after: "rubbish")}.to raise_error(/invalid/)
77
+ end
78
+ end
79
+
80
+ context "on or after" do
81
+ it "today/yesterday" do
82
+ d = ICU::Date.new(::Date.today, on_or_after: ::Date.today - 1)
83
+ expect(d).to be_valid
84
+ expect(d.date).to eq ::Date.today
85
+ expect(d.reasons).to be_empty
86
+ end
87
+
88
+ it "yesterday/today" do
89
+ d = ICU::Date.new(::Date.today - 1, on_or_after: ::Date.today)
90
+ expect(d).to_not be_valid
91
+ expect(d.date).to eq ::Date.today - 1
92
+ expect(d.reasons[0]).to eq "errors.messages.on_or_after"
93
+ expect(d.reasons[1]).to eq restriction: ::Date.today.to_s
94
+ end
95
+
96
+ it "today/today" do
97
+ d = ICU::Date.new(::Date.today, on_or_after: ::Date.today)
98
+ expect(d).to be_valid
99
+ expect(d.date).to eq ::Date.today
100
+ expect(d.reasons).to be_empty
101
+ end
102
+
103
+ it "impossible" do
104
+ expect{ICU::Date.new(::Date.today, on_or_after: ::Date.new(1955, 2, 29))}.to raise_error(/invalid/)
105
+ end
106
+ end
107
+
108
+ context "before" do
109
+ it "yesterday/today" do
110
+ d = ICU::Date.new(::Date.today - 1, before: ::Date.today)
111
+ expect(d).to be_valid
112
+ expect(d.date).to eq ::Date.today - 1
113
+ expect(d.reasons).to be_empty
114
+ end
115
+
116
+ it "today/yesterday" do
117
+ d = ICU::Date.new(::Date.today, before: ::Date.today - 1)
118
+ expect(d).to_not be_valid
119
+ expect(d.date).to eq ::Date.today
120
+ expect(d.reasons[0]).to eq "errors.messages.before"
121
+ expect(d.reasons[1]).to eq restriction: (::Date.today - 1).to_s
122
+ end
123
+
124
+ it "today/today" do
125
+ d = ICU::Date.new(::Date.today, before: ::Date.today.to_s)
126
+ expect(d).to_not be_valid
127
+ expect(d.date).to eq ::Date.today
128
+ expect(d.reasons[0]).to eq "errors.messages.before"
129
+ expect(d.reasons[1]).to eq restriction: ::Date.today.to_s
130
+ end
131
+
132
+ it "invalid" do
133
+ expect{ICU::Date.new(::Date.today, before: "")}.to raise_error(/invalid/)
134
+ end
135
+ end
136
+
137
+ context "on or before" do
138
+ it "yesterday/today" do
139
+ d = ICU::Date.new(::Date.today - 1, on_or_before: ::Date.today.to_s)
140
+ expect(d).to be_valid
141
+ expect(d.date).to eq ::Date.today - 1
142
+ expect(d.reasons).to be_empty
143
+ end
144
+
145
+ it "today/yesterday" do
146
+ d = ICU::Date.new(::Date.today, on_or_before: ::Date.today - 1)
147
+ expect(d).to_not be_valid
148
+ expect(d.date).to eq ::Date.today
149
+ expect(d.reasons[0]).to eq "errors.messages.on_or_before"
150
+ expect(d.reasons[1]).to eq restriction: (::Date.today - 1).to_s
151
+ end
152
+
153
+ it "today/today" do
154
+ d = ICU::Date.new(::Date.today, on_or_before: ::Date.today)
155
+ expect(d).to be_valid
156
+ expect(d.date).to eq ::Date.today
157
+ expect(d.reasons).to be_empty
158
+ end
159
+
160
+ it "impossible" do
161
+ expect{ICU::Date.new(::Date.today, on_or_before: "2014-06-31")}.to raise_error(/invalid/)
162
+ end
163
+ end
164
+ end
165
+
166
+ context "multiple constraints" do
167
+ it "today/today" do
168
+ d = ICU::Date.new(::Date.today, on_or_after: ::Date.today.to_s, on_or_before: ::Date.today)
169
+ expect(d).to be_valid
170
+ expect(d.date).to eq ::Date.today
171
+ expect(d.reasons).to be_empty
172
+ end
173
+ end
174
+ end
@@ -7,185 +7,185 @@ module ICU
7
7
  context "#find using codes" do
8
8
  it "should find a federation given a valid code" do
9
9
  fed = Federation.find('IRL')
10
- fed.code.should == 'IRL'
11
- fed.name.should == 'Ireland'
10
+ expect(fed.code).to eq('IRL')
11
+ expect(fed.name).to eq('Ireland')
12
12
  end
13
13
 
14
14
  it "should find a federation from code case insensitively" do
15
15
  fed = Federation.find('rUs')
16
- fed.code.should == 'RUS'
17
- fed.name.should == 'Russia'
16
+ expect(fed.code).to eq('RUS')
17
+ expect(fed.name).to eq('Russia')
18
18
  end
19
19
 
20
20
  it "should find a federation despite irrelevant whitespace" do
21
21
  fed = Federation.find(' mex ')
22
- fed.code.should == 'MEX'
23
- fed.name.should == 'Mexico'
22
+ expect(fed.code).to eq('MEX')
23
+ expect(fed.name).to eq('Mexico')
24
24
  end
25
25
 
26
26
  it "should return nil for an invalid code" do
27
- Federation.find('XYZ').should be_nil
27
+ expect(Federation.find('XYZ')).to be_nil
28
28
  end
29
29
  end
30
30
 
31
31
  context "#find using names" do
32
32
  it "should find a federation given a valid name" do
33
33
  fed = Federation.find('England')
34
- fed.code.should == 'ENG'
35
- fed.name.should == 'England'
34
+ expect(fed.code).to eq('ENG')
35
+ expect(fed.name).to eq('England')
36
36
  end
37
37
 
38
38
  it "should find a federation from name case insensitively" do
39
39
  fed = Federation.find('franCE')
40
- fed.code.should == 'FRA'
41
- fed.name.should == 'France'
40
+ expect(fed.code).to eq('FRA')
41
+ expect(fed.name).to eq('France')
42
42
  end
43
43
 
44
44
  it "should not be fooled by irrelevant whitespace" do
45
45
  fed = Federation.find(' united states of america ')
46
- fed.code.should == 'USA'
47
- fed.name.should == 'United States of America'
46
+ expect(fed.code).to eq('USA')
47
+ expect(fed.name).to eq('United States of America')
48
48
  end
49
49
 
50
50
  it "should return nil for an invalid name" do
51
- Federation.find('Mordor').should be_nil
51
+ expect(Federation.find('Mordor')).to be_nil
52
52
  end
53
53
  end
54
54
 
55
55
  context "#find using parts of names" do
56
56
  it "should find a federation given a substring which is unique and at least 4 characters" do
57
57
  fed = Federation.find('bosni')
58
- fed.code.should == 'BIH'
59
- fed.name.should == 'Bosnia and Herzegovina'
58
+ expect(fed.code).to eq('BIH')
59
+ expect(fed.name).to eq('Bosnia and Herzegovina')
60
60
  end
61
61
 
62
62
  it "should not be fooled by irrelevant whitespace" do
63
63
  fed = Federation.find(' arab EMIRATES ')
64
- fed.code.should == 'UAE'
65
- fed.name.should == 'United Arab Emirates'
64
+ expect(fed.code).to eq('UAE')
65
+ expect(fed.name).to eq('United Arab Emirates')
66
66
  end
67
67
 
68
68
  it "should not find a federation if the substring matches more than one" do
69
- Federation.find('land').should be_nil
69
+ expect(Federation.find('land')).to be_nil
70
70
  end
71
71
 
72
72
  it "should return nil for any string smaller in length than 3" do
73
- Federation.find('ze').should be_nil
73
+ expect(Federation.find('ze')).to be_nil
74
74
  end
75
75
  end
76
76
 
77
77
  context "#find federations with alternative names" do
78
78
  it "should find Macedonia multiple ways" do
79
- Federation.find('MKD').name.should == 'Macedonia'
80
- Federation.find('FYROM').name.should == 'Macedonia'
81
- Federation.find('macedoni').name.should == 'Macedonia'
82
- Federation.find('Macedonia').name.should == 'Macedonia'
83
- Federation.find('former YUG Rep').name.should == 'Macedonia'
84
- Federation.find('Republic of Macedonia').name.should == 'Macedonia'
85
- Federation.find('former yugoslav republic').name.should == 'Macedonia'
79
+ expect(Federation.find('MKD').name).to eq('Macedonia')
80
+ expect(Federation.find('FYROM').name).to eq('Macedonia')
81
+ expect(Federation.find('macedoni').name).to eq('Macedonia')
82
+ expect(Federation.find('Macedonia').name).to eq('Macedonia')
83
+ expect(Federation.find('former YUG Rep').name).to eq('Macedonia')
84
+ expect(Federation.find('Republic of Macedonia').name).to eq('Macedonia')
85
+ expect(Federation.find('former yugoslav republic').name).to eq('Macedonia')
86
86
  end
87
87
  end
88
88
 
89
89
  context "#find from common code errors" do
90
90
  it "should find IRL from ICU" do
91
- Federation.find('ICU').code.should == 'IRL'
92
- Federation.find('SPA').code.should == 'ESP'
93
- Federation.find('WAL').code.should == 'WLS'
91
+ expect(Federation.find('ICU').code).to eq('IRL')
92
+ expect(Federation.find('SPA').code).to eq('ESP')
93
+ expect(Federation.find('WAL').code).to eq('WLS')
94
94
  end
95
95
  end
96
96
 
97
97
  context "#find with alternative inputs" do
98
98
  it "should behave robustly with completely invalid inputs" do
99
- Federation.find().should be_nil
100
- Federation.find(nil).should be_nil
101
- Federation.find('').should be_nil
102
- Federation.find(1).should be_nil
99
+ expect(Federation.find()).to be_nil
100
+ expect(Federation.find(nil)).to be_nil
101
+ expect(Federation.find('')).to be_nil
102
+ expect(Federation.find(1)).to be_nil
103
103
  end
104
104
  end
105
105
 
106
106
  context "#new is private" do
107
107
  it "#new cannot be called directly" do
108
- lambda { Federation.new('IRL', 'Ireland') }.should raise_error(/private method/)
108
+ expect { Federation.new('IRL', 'Ireland') }.to raise_error(/private method/)
109
109
  end
110
110
  end
111
111
 
112
112
  context "documentation examples" do
113
113
  it "should all be correct for valid input" do
114
- Federation.find('IRL').name.should == 'Ireland'
115
- Federation.find('IRL').code.should == 'IRL'
116
- Federation.find('rUs').code.should == 'RUS'
117
- Federation.find('ongoli').name.should == 'Mongolia'
118
- Federation.find(' united states ').code.should == 'USA'
114
+ expect(Federation.find('IRL').name).to eq('Ireland')
115
+ expect(Federation.find('IRL').code).to eq('IRL')
116
+ expect(Federation.find('rUs').code).to eq('RUS')
117
+ expect(Federation.find('ongoli').name).to eq('Mongolia')
118
+ expect(Federation.find(' united states ').code).to eq('USA')
119
119
  end
120
120
 
121
121
  it "should return nil for invalid input" do
122
- Federation.find('ZYX').should be_nil
123
- Federation.find('land').should be_nil
122
+ expect(Federation.find('ZYX')).to be_nil
123
+ expect(Federation.find('land')).to be_nil
124
124
  end
125
125
  end
126
126
 
127
127
  context "#menu" do
128
128
  it "should return array of name-code pairs in order of name by default" do
129
129
  menu = Federation.menu
130
- menu.should have(total).items
130
+ expect(menu.size).to eq(total)
131
131
  names = menu.map{|m| m.first}.join(',')
132
132
  codes = menu.map{|m| m.last}.join(',')
133
- names.index('Afghanistan').should == 0
134
- names.index('Iraq,Ireland,Israel').should_not be_nil
135
- codes.index('AFG').should == 0
136
- codes.index('IRQ,IRL,ISR').should_not be_nil
133
+ expect(names.index('Afghanistan')).to eq(0)
134
+ expect(names.index('Iraq,Ireland,Israel')).not_to be_nil
135
+ expect(codes.index('AFG')).to eq(0)
136
+ expect(codes.index('IRQ,IRL,ISR')).not_to be_nil
137
137
  end
138
138
 
139
139
  it "should be configuarble to order the list by codes" do
140
140
  menu = Federation.menu(:order => "code")
141
- menu.should have(total).items
141
+ expect(menu.size).to eq(total)
142
142
  names = menu.map{|m| m.first}.join(',')
143
143
  codes = menu.map{|m| m.last}.join(',')
144
- names.index('Afghanistan').should == 0
145
- names.index('Ireland,Iraq,Iceland').should_not be_nil
146
- codes.index('AFG').should == 0
147
- codes.index('IRL,IRQ,ISL').should_not be_nil
144
+ expect(names.index('Afghanistan')).to eq(0)
145
+ expect(names.index('Ireland,Iraq,Iceland')).not_to be_nil
146
+ expect(codes.index('AFG')).to eq(0)
147
+ expect(codes.index('IRL,IRQ,ISL')).not_to be_nil
148
148
  end
149
149
 
150
150
  it "should be configuarble to have a selected country at the top" do
151
151
  menu = Federation.menu(:top => 'IRL')
152
- menu.should have(total).items
152
+ expect(menu.size).to eq(total)
153
153
  names = menu.map{|m| m.first}.join(',')
154
154
  codes = menu.map{|m| m.last}.join(',')
155
- names.index('Ireland,Afghanistan').should == 0
156
- names.index('Iraq,Israel').should_not be_nil
157
- codes.index('IRL,AFG').should == 0
158
- codes.index('IRQ,ISR').should_not be_nil
155
+ expect(names.index('Ireland,Afghanistan')).to eq(0)
156
+ expect(names.index('Iraq,Israel')).not_to be_nil
157
+ expect(codes.index('IRL,AFG')).to eq(0)
158
+ expect(codes.index('IRQ,ISR')).not_to be_nil
159
159
  end
160
160
 
161
161
  it "should be configuarble to have 'None' entry at the top" do
162
162
  menu = Federation.menu(:none => 'None')
163
- menu.should have(total + 1).items
163
+ expect(menu.size).to eq(total + 1)
164
164
  names = menu.map{|m| m.first}.join(',')
165
165
  codes = menu.map{|m| m.last}.join(',')
166
- names.index('None,Afghanistan').should == 0
167
- codes.index(',AFG').should == 0
166
+ expect(names.index('None,Afghanistan')).to eq(0)
167
+ expect(codes.index(',AFG')).to eq(0)
168
168
  end
169
169
 
170
170
  it "should be able to handle multiple configuarations" do
171
171
  menu = Federation.menu(:top => 'IRL', :order => 'code', :none => 'None')
172
- menu.should have(total + 1).items
172
+ expect(menu.size).to eq(total + 1)
173
173
  names = menu.map{|m| m.first}.join(',')
174
174
  codes = menu.map{|m| m.last}.join(',')
175
- names.index('None,Ireland,Afghanistan').should == 0
176
- names.index('Iraq,Iceland').should_not be_nil
177
- codes.index(',IRL,AFG').should == 0
178
- codes.index('IRQ,ISL').should_not be_nil
175
+ expect(names.index('None,Ireland,Afghanistan')).to eq(0)
176
+ expect(names.index('Iraq,Iceland')).not_to be_nil
177
+ expect(codes.index(',IRL,AFG')).to eq(0)
178
+ expect(codes.index('IRQ,ISL')).not_to be_nil
179
179
  end
180
180
  end
181
181
 
182
182
  context "#codes" do
183
183
  it "should return array of codes ordered alphabetically" do
184
184
  codes = Federation.codes
185
- codes.should have(total).items
185
+ expect(codes.size).to eq(total)
186
186
  all = codes.join(',')
187
- all.index('AFG').should == 0
188
- all.index('INA,IND,IRI,IRL,IRQ,ISL,ISR,ISV,ITA,IVB').should_not be_nil
187
+ expect(all.index('AFG')).to eq(0)
188
+ expect(all.index('INA,IND,IRI,IRL,IRQ,ISL,ISR,ISV,ITA,IVB')).not_to be_nil
189
189
  end
190
190
  end
191
191
 
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icu_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
5
- prerelease:
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mark Orr
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-15 00:00:00.000000000 Z
11
+ date: 2014-08-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '1.3'
19
+ version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
- version: '1.3'
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rdoc
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: A place for shared utilities for sharing between the various ICU apps
@@ -87,6 +78,7 @@ extra_rdoc_files:
87
78
  files:
88
79
  - .gitignore
89
80
  - .rspec
81
+ - .ruby-version
90
82
  - Gemfile
91
83
  - Gemfile.lock
92
84
  - Icon.png
@@ -99,41 +91,37 @@ files:
99
91
  - bin/rspec
100
92
  - icu_utils.gemspec
101
93
  - lib/icu_utils.rb
94
+ - lib/icu_utils/date.rb
102
95
  - lib/icu_utils/federation.rb
103
96
  - lib/icu_utils/version.rb
97
+ - spec/date_spec.rb
104
98
  - spec/federation_spec.rb
105
99
  - spec/spec_helper.rb
106
100
  homepage: http://github.com/sanichi/icu_utils
107
101
  licenses:
108
102
  - MIT
103
+ metadata: {}
109
104
  post_install_message:
110
105
  rdoc_options: []
111
106
  require_paths:
112
107
  - lib
113
108
  required_ruby_version: !ruby/object:Gem::Requirement
114
- none: false
115
109
  requirements:
116
- - - ! '>='
110
+ - - '>='
117
111
  - !ruby/object:Gem::Version
118
112
  version: '0'
119
- segments:
120
- - 0
121
- hash: -1389679885683086703
122
113
  required_rubygems_version: !ruby/object:Gem::Requirement
123
- none: false
124
114
  requirements:
125
- - - ! '>='
115
+ - - '>='
126
116
  - !ruby/object:Gem::Version
127
117
  version: '0'
128
- segments:
129
- - 0
130
- hash: -1389679885683086703
131
118
  requirements: []
132
119
  rubyforge_project:
133
- rubygems_version: 1.8.23
120
+ rubygems_version: 2.1.11
134
121
  signing_key:
135
- specification_version: 3
122
+ specification_version: 4
136
123
  summary: Shared ICU utilities
137
124
  test_files:
125
+ - spec/date_spec.rb
138
126
  - spec/federation_spec.rb
139
127
  - spec/spec_helper.rb