icu_utils 1.2.1 → 1.2.2

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
  SHA1:
3
- metadata.gz: ab59aa173d3006e292c62c663aef7e2a324cd541
4
- data.tar.gz: 633b645d25e35b55976aa23930dca65ea338a503
3
+ metadata.gz: 00770614bdea719215c4d382a203b68b141b4c0f
4
+ data.tar.gz: 187677d1ab5db950e1fa4f36f760ec34f7de90a6
5
5
  SHA512:
6
- metadata.gz: 224f78a3f5b8dacf2a587456249361279f43e2a4d96d203af8f44d1801d02a17f65cd031fa00721f975d578b33592239ad318ea85e2dc4104cf17b29fe2a711c
7
- data.tar.gz: 47d8ce1bcce6c40e68bd895baf84462609d0f95a149b249f13465f275b75ddd58fea4762f6cb0b7cd9dd5928b5418787adffa685b58c971ec7012158d979d150
6
+ metadata.gz: 05779d4d2a55d2de9bc27c92c10ee131913dd25f2e7d101dff4696df7ad3268c8f0643d9ac6d99e6d42d7f40556d13ce49a69096f1de398092baf0da4f2c4e47
7
+ data.tar.gz: e1def33b43f99c0ce58d5ff16fa604ea2aa69cc1f466eb2392c4e3c2a3e2a251080d428e01ffd173009d515609f38c0e86eb6ab0fcc11d963988cbec5c048833
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- icu_utils (1.2.1)
4
+ icu_utils (1.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -49,19 +49,14 @@ module ICU
49
49
  valid
50
50
  end
51
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
52
  private
60
53
 
61
54
  def to_date(thing)
62
55
  thing = thing.call if thing.respond_to?(:call)
63
56
  if thing.is_a?(Date)
64
57
  thing.dup
58
+ elsif thing.to_s.downcase == "today"
59
+ thing = ::Date.today
65
60
  else
66
61
  thing = ::Date.parse(thing.to_s)
67
62
  end
@@ -1,3 +1,3 @@
1
1
  module IcuUtils
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -208,5 +208,37 @@ module ICU
208
208
  expect(d.reasons[1]).to eq restriction: penny.to_s
209
209
  end
210
210
  end
211
+
212
+ context "symbol constraints" do
213
+ it "before" do
214
+ d = ICU::Date.new(penny, before: :today)
215
+ expect(d).to be_valid
216
+ expect(d.date).to eq penny
217
+ expect(d.reasons).to be_empty
218
+ end
219
+
220
+ it "after" do
221
+ d = ICU::Date.new(yesterday, after: "TODAY")
222
+ expect(d).to_not be_valid
223
+ expect(d.date).to eq yesterday
224
+ expect(d.reasons[0]).to eq "errors.messages.after"
225
+ expect(d.reasons[1]).to eq restriction: today.to_s
226
+ end
227
+
228
+ it "on or before" do
229
+ d = ICU::Date.new(today, on_or_before: "Today")
230
+ expect(d).to be_valid
231
+ expect(d.date).to eq today
232
+ expect(d.reasons).to be_empty
233
+ end
234
+
235
+ it "on or after" do
236
+ d = ICU::Date.new(mark, on_or_after: "today")
237
+ expect(d).to_not be_valid
238
+ expect(d.date).to eq mark
239
+ expect(d.reasons[0]).to eq "errors.messages.on_or_after"
240
+ expect(d.reasons[1]).to eq restriction: today.to_s
241
+ end
242
+ end
211
243
  end
212
244
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icu_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Orr