validates_timeliness 3.0.15 → 4.0.0
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 +4 -4
- data/.travis.yml +21 -0
- data/CHANGELOG.rdoc +0 -5
- data/README.rdoc +5 -5
- data/gemfiles/rails_4_0.gemfile +19 -0
- data/gemfiles/rails_4_1.gemfile +19 -0
- data/gemfiles/rails_4_2.gemfile +19 -0
- data/lib/generators/validates_timeliness/templates/validates_timeliness.rb +2 -2
- data/lib/validates_timeliness.rb +1 -1
- data/lib/validates_timeliness/attribute_methods.rb +36 -36
- data/lib/validates_timeliness/extensions.rb +3 -4
- data/lib/validates_timeliness/extensions/date_time_select.rb +2 -9
- data/lib/validates_timeliness/extensions/multiparameter_handler.rb +59 -65
- data/lib/validates_timeliness/helper_methods.rb +8 -2
- data/lib/validates_timeliness/orm/active_record.rb +59 -13
- data/lib/validates_timeliness/validator.rb +13 -5
- data/lib/validates_timeliness/version.rb +1 -1
- data/spec/spec_helper.rb +3 -2
- data/spec/support/model_helpers.rb +4 -4
- data/spec/support/tag_matcher.rb +35 -0
- data/spec/support/test_model.rb +0 -1
- data/spec/validates_timeliness/attribute_methods_spec.rb +10 -10
- data/spec/validates_timeliness/conversion_spec.rb +41 -41
- data/spec/validates_timeliness/extensions/date_time_select_spec.rb +5 -4
- data/spec/validates_timeliness/extensions/multiparameter_handler_spec.rb +8 -7
- data/spec/validates_timeliness/helper_methods_spec.rb +8 -8
- data/spec/validates_timeliness/orm/active_record_spec.rb +37 -37
- data/spec/validates_timeliness/validator/after_spec.rb +3 -3
- data/spec/validates_timeliness/validator/before_spec.rb +3 -3
- data/spec/validates_timeliness/validator/is_at_spec.rb +4 -4
- data/spec/validates_timeliness/validator/on_or_after_spec.rb +3 -3
- data/spec/validates_timeliness/validator/on_or_before_spec.rb +3 -3
- data/spec/validates_timeliness/validator_spec.rb +26 -26
- data/spec/validates_timeliness_spec.rb +8 -8
- metadata +7 -11
- data/gemfiles/mongoid_2_1.gemfile +0 -16
- data/gemfiles/mongoid_2_2.gemfile +0 -16
- data/gemfiles/mongoid_2_3.gemfile +0 -16
- data/gemfiles/mongoid_2_4.gemfile +0 -16
- data/gemfiles/rails_3_0.gemfile +0 -15
- data/gemfiles/rails_3_1.gemfile +0 -15
- data/gemfiles/rails_3_2.gemfile +0 -15
- data/lib/validates_timeliness/orm/mongoid.rb +0 -49
- data/spec/validates_timeliness/orm/mongoid_spec.rb +0 -223
@@ -2,28 +2,28 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ValidatesTimeliness::Validator do
|
4
4
|
before do
|
5
|
-
Timecop.freeze(Time.
|
5
|
+
Timecop.freeze(Time.local(2010, 1, 1, 0, 0, 0))
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "Model.validates with :timeliness option" do
|
9
9
|
it 'should use plugin validator class' do
|
10
10
|
Person.validates :birth_date, :timeliness => {:is_at => Date.new(2010,1,1), :type => :date}
|
11
|
-
Person.validators.
|
11
|
+
expect(Person.validators.select { |v| v.is_a?(ActiveModel::Validations::TimelinessValidator) }.size).to eq(1)
|
12
12
|
invalid!(:birth_date, Date.new(2010,1,2))
|
13
13
|
valid!(:birth_date, Date.new(2010,1,1))
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should use default to :datetime type' do
|
17
17
|
Person.validates :birth_datetime, :timeliness => {:is_at => Time.mktime(2010,1,1)}
|
18
|
-
Person.validators.first.type.
|
18
|
+
expect(Person.validators.first.type).to eq(:datetime)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should add attribute to timeliness attributes set' do
|
22
|
-
PersonWithShim.timeliness_validated_attributes.
|
22
|
+
expect(PersonWithShim.timeliness_validated_attributes).not_to include(:birth_time)
|
23
23
|
|
24
24
|
PersonWithShim.validates :birth_time, :timeliness => {:is_at => "12:30"}
|
25
25
|
|
26
|
-
PersonWithShim.timeliness_validated_attributes.
|
26
|
+
expect(PersonWithShim.timeliness_validated_attributes).to include(:birth_time)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -35,10 +35,10 @@ describe ValidatesTimeliness::Validator do
|
|
35
35
|
it 'should not be valid attribute is type cast to nil but raw value is non-nil invalid value' do
|
36
36
|
Person.validates_date :birth_date, :allow_nil => true
|
37
37
|
record = Person.new
|
38
|
-
record.
|
39
|
-
record.
|
40
|
-
record.
|
41
|
-
record.errors[:birth_date].first.
|
38
|
+
allow(record).to receive(:birth_date).and_return(nil)
|
39
|
+
allow(record).to receive(:read_timeliness_attribute_before_type_cast).and_return("Not a date")
|
40
|
+
expect(record).not_to be_valid
|
41
|
+
expect(record.errors[:birth_date].first).to eq('is not a valid date')
|
42
42
|
end
|
43
43
|
|
44
44
|
describe ":allow_nil option" do
|
@@ -60,7 +60,7 @@ describe ValidatesTimeliness::Validator do
|
|
60
60
|
p = PersonWithShim.new
|
61
61
|
p.birth_date = 'bogus'
|
62
62
|
|
63
|
-
p.
|
63
|
+
expect(p).not_to be_valid
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -84,7 +84,7 @@ describe ValidatesTimeliness::Validator do
|
|
84
84
|
p = PersonWithShim.new
|
85
85
|
p.birth_date = 'bogus'
|
86
86
|
|
87
|
-
p.
|
87
|
+
expect(p).not_to be_valid
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -94,8 +94,8 @@ describe ValidatesTimeliness::Validator do
|
|
94
94
|
it 'should be split option into :on_or_after and :on_or_before values' do
|
95
95
|
on_or_after, on_or_before = Date.new(2010,1,1), Date.new(2010,1,2)
|
96
96
|
Person.validates_date :birth_date, :between => [on_or_after, on_or_before]
|
97
|
-
Person.validators.first.options[:on_or_after].
|
98
|
-
Person.validators.first.options[:on_or_before].
|
97
|
+
expect(Person.validators.first.options[:on_or_after]).to eq(on_or_after)
|
98
|
+
expect(Person.validators.first.options[:on_or_before]).to eq(on_or_before)
|
99
99
|
invalid!(:birth_date, on_or_after - 1, "must be on or after 2010-01-01")
|
100
100
|
invalid!(:birth_date, on_or_before + 1, "must be on or before 2010-01-02")
|
101
101
|
valid!(:birth_date, on_or_after)
|
@@ -107,8 +107,8 @@ describe ValidatesTimeliness::Validator do
|
|
107
107
|
it 'should be split option into :on_or_after and :on_or_before values' do
|
108
108
|
on_or_after, on_or_before = Date.new(2010,1,1), Date.new(2010,1,2)
|
109
109
|
Person.validates_date :birth_date, :between => on_or_after..on_or_before
|
110
|
-
Person.validators.first.options[:on_or_after].
|
111
|
-
Person.validators.first.options[:on_or_before].
|
110
|
+
expect(Person.validators.first.options[:on_or_after]).to eq(on_or_after)
|
111
|
+
expect(Person.validators.first.options[:on_or_before]).to eq(on_or_before)
|
112
112
|
invalid!(:birth_date, on_or_after - 1, "must be on or after 2010-01-01")
|
113
113
|
invalid!(:birth_date, on_or_before + 1, "must be on or before 2010-01-02")
|
114
114
|
valid!(:birth_date, on_or_after)
|
@@ -120,8 +120,8 @@ describe ValidatesTimeliness::Validator do
|
|
120
120
|
it 'should be split option into :on_or_after and :before values' do
|
121
121
|
on_or_after, before = Date.new(2010,1,1), Date.new(2010,1,3)
|
122
122
|
Person.validates_date :birth_date, :between => on_or_after...before
|
123
|
-
Person.validators.first.options[:on_or_after].
|
124
|
-
Person.validators.first.options[:before].
|
123
|
+
expect(Person.validators.first.options[:on_or_after]).to eq(on_or_after)
|
124
|
+
expect(Person.validators.first.options[:before]).to eq(before)
|
125
125
|
invalid!(:birth_date, on_or_after - 1, "must be on or after 2010-01-01")
|
126
126
|
invalid!(:birth_date, before, "must be before 2010-01-03")
|
127
127
|
valid!(:birth_date, on_or_after)
|
@@ -159,13 +159,13 @@ describe ValidatesTimeliness::Validator do
|
|
159
159
|
it "should be valid when value matches format" do
|
160
160
|
person.birth_date = '11-12-1913'
|
161
161
|
person.valid?
|
162
|
-
person.errors[:birth_date].
|
162
|
+
expect(person.errors[:birth_date]).to be_empty
|
163
163
|
end
|
164
164
|
|
165
165
|
it "should not be valid when value does not match format" do
|
166
166
|
person.birth_date = '1913-12-11'
|
167
167
|
person.valid?
|
168
|
-
person.errors[:birth_date].
|
168
|
+
expect(person.errors[:birth_date]).to include('is not a valid date')
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -179,21 +179,21 @@ describe ValidatesTimeliness::Validator do
|
|
179
179
|
it "should be added when ignore_restriction_errors is false" do
|
180
180
|
with_config(:ignore_restriction_errors, false) do
|
181
181
|
person.valid?
|
182
|
-
person.errors[:birth_date].first.
|
182
|
+
expect(person.errors[:birth_date].first).to match("Error occurred validating birth_date")
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should not be added when ignore_restriction_errors is true" do
|
187
187
|
with_config(:ignore_restriction_errors, true) do
|
188
188
|
person.valid?
|
189
|
-
person.errors[:birth_date].
|
189
|
+
expect(person.errors[:birth_date]).to be_empty
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
193
|
it 'should exit on first error' do
|
194
194
|
with_config(:ignore_restriction_errors, false) do
|
195
195
|
person.valid?
|
196
|
-
person.errors[:birth_date].
|
196
|
+
expect(person.errors[:birth_date].size).to eq(1)
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
@@ -202,17 +202,17 @@ describe ValidatesTimeliness::Validator do
|
|
202
202
|
describe "default" do
|
203
203
|
it 'should format date error value as yyyy-mm-dd' do
|
204
204
|
validator = ValidatesTimeliness::Validator.new(:attributes => [:birth_date], :type => :date)
|
205
|
-
validator.format_error_value(Date.new(2010,1,1)).
|
205
|
+
expect(validator.format_error_value(Date.new(2010,1,1))).to eq('2010-01-01')
|
206
206
|
end
|
207
207
|
|
208
208
|
it 'should format time error value as hh:nn:ss' do
|
209
209
|
validator = ValidatesTimeliness::Validator.new(:attributes => [:birth_time], :type => :time)
|
210
|
-
validator.format_error_value(Time.mktime(2010,1,1,12,34,56)).
|
210
|
+
expect(validator.format_error_value(Time.mktime(2010,1,1,12,34,56))).to eq('12:34:56')
|
211
211
|
end
|
212
212
|
|
213
213
|
it 'should format datetime error value as yyyy-mm-dd hh:nn:ss' do
|
214
214
|
validator = ValidatesTimeliness::Validator.new(:attributes => [:birth_datetime], :type => :datetime)
|
215
|
-
validator.format_error_value(Time.mktime(2010,1,1,12,34,56)).
|
215
|
+
expect(validator.format_error_value(Time.mktime(2010,1,1,12,34,56))).to eq('2010-01-01 12:34:56')
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
@@ -223,7 +223,7 @@ describe ValidatesTimeliness::Validator do
|
|
223
223
|
|
224
224
|
it 'should use the default format for the type' do
|
225
225
|
validator = ValidatesTimeliness::Validator.new(:attributes => [:birth_date], :type => :date)
|
226
|
-
validator.format_error_value(Date.new(2010,1,1)).
|
226
|
+
expect(validator.format_error_value(Date.new(2010,1,1))).to eq('2010-01-01')
|
227
227
|
end
|
228
228
|
|
229
229
|
after :all do
|
@@ -3,39 +3,39 @@ require 'spec_helper'
|
|
3
3
|
describe ValidatesTimeliness do
|
4
4
|
|
5
5
|
it 'should alias use_euro_formats to remove_us_formats on Timeliness gem' do
|
6
|
-
Timeliness.
|
6
|
+
expect(Timeliness).to respond_to(:remove_us_formats)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should alias to date_for_time_type to dummy_date_for_time_type on Timeliness gem' do
|
10
|
-
Timeliness.
|
10
|
+
expect(Timeliness).to respond_to(:dummy_date_for_time_type)
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "config" do
|
14
14
|
it 'should delegate default_timezone to Timeliness gem' do
|
15
|
-
Timeliness.
|
15
|
+
expect(Timeliness).to receive(:default_timezone=)
|
16
16
|
ValidatesTimeliness.default_timezone = :utc
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should delegate dummy_date_for_time_type to Timeliness gem' do
|
20
|
-
Timeliness.
|
21
|
-
Timeliness.
|
20
|
+
expect(Timeliness).to receive(:dummy_date_for_time_type)
|
21
|
+
expect(Timeliness).to receive(:dummy_date_for_time_type=)
|
22
22
|
array = ValidatesTimeliness.dummy_date_for_time_type
|
23
23
|
ValidatesTimeliness.dummy_date_for_time_type = array
|
24
24
|
end
|
25
25
|
|
26
26
|
context "parser" do
|
27
27
|
it 'should delegate add_formats to Timeliness gem' do
|
28
|
-
Timeliness.
|
28
|
+
expect(Timeliness).to receive(:add_formats)
|
29
29
|
ValidatesTimeliness.parser.add_formats
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should delegate remove_formats to Timeliness gem' do
|
33
|
-
Timeliness.
|
33
|
+
expect(Timeliness).to receive(:remove_formats)
|
34
34
|
ValidatesTimeliness.parser.remove_formats
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should delegate remove_us_formats to Timeliness gem' do
|
38
|
-
Timeliness.
|
38
|
+
expect(Timeliness).to receive(:remove_us_formats)
|
39
39
|
ValidatesTimeliness.parser.remove_us_formats
|
40
40
|
end
|
41
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_timeliness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Meehan
|
@@ -34,17 +34,14 @@ extra_rdoc_files:
|
|
34
34
|
- CHANGELOG.rdoc
|
35
35
|
- LICENSE
|
36
36
|
files:
|
37
|
+
- ".travis.yml"
|
37
38
|
- CHANGELOG.rdoc
|
38
39
|
- LICENSE
|
39
40
|
- README.rdoc
|
40
41
|
- Rakefile
|
41
|
-
- gemfiles/
|
42
|
-
- gemfiles/
|
43
|
-
- gemfiles/
|
44
|
-
- gemfiles/mongoid_2_4.gemfile
|
45
|
-
- gemfiles/rails_3_0.gemfile
|
46
|
-
- gemfiles/rails_3_1.gemfile
|
47
|
-
- gemfiles/rails_3_2.gemfile
|
42
|
+
- gemfiles/rails_4_0.gemfile
|
43
|
+
- gemfiles/rails_4_1.gemfile
|
44
|
+
- gemfiles/rails_4_2.gemfile
|
48
45
|
- init.rb
|
49
46
|
- lib/generators/validates_timeliness/install_generator.rb
|
50
47
|
- lib/generators/validates_timeliness/templates/en.yml
|
@@ -57,13 +54,13 @@ files:
|
|
57
54
|
- lib/validates_timeliness/extensions/multiparameter_handler.rb
|
58
55
|
- lib/validates_timeliness/helper_methods.rb
|
59
56
|
- lib/validates_timeliness/orm/active_record.rb
|
60
|
-
- lib/validates_timeliness/orm/mongoid.rb
|
61
57
|
- lib/validates_timeliness/railtie.rb
|
62
58
|
- lib/validates_timeliness/validator.rb
|
63
59
|
- lib/validates_timeliness/version.rb
|
64
60
|
- spec/spec_helper.rb
|
65
61
|
- spec/support/config_helper.rb
|
66
62
|
- spec/support/model_helpers.rb
|
63
|
+
- spec/support/tag_matcher.rb
|
67
64
|
- spec/support/test_model.rb
|
68
65
|
- spec/validates_timeliness/attribute_methods_spec.rb
|
69
66
|
- spec/validates_timeliness/conversion_spec.rb
|
@@ -71,7 +68,6 @@ files:
|
|
71
68
|
- spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
|
72
69
|
- spec/validates_timeliness/helper_methods_spec.rb
|
73
70
|
- spec/validates_timeliness/orm/active_record_spec.rb
|
74
|
-
- spec/validates_timeliness/orm/mongoid_spec.rb
|
75
71
|
- spec/validates_timeliness/validator/after_spec.rb
|
76
72
|
- spec/validates_timeliness/validator/before_spec.rb
|
77
73
|
- spec/validates_timeliness/validator/is_at_spec.rb
|
@@ -107,6 +103,7 @@ test_files:
|
|
107
103
|
- spec/spec_helper.rb
|
108
104
|
- spec/support/config_helper.rb
|
109
105
|
- spec/support/model_helpers.rb
|
106
|
+
- spec/support/tag_matcher.rb
|
110
107
|
- spec/support/test_model.rb
|
111
108
|
- spec/validates_timeliness/attribute_methods_spec.rb
|
112
109
|
- spec/validates_timeliness/conversion_spec.rb
|
@@ -114,7 +111,6 @@ test_files:
|
|
114
111
|
- spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
|
115
112
|
- spec/validates_timeliness/helper_methods_spec.rb
|
116
113
|
- spec/validates_timeliness/orm/active_record_spec.rb
|
117
|
-
- spec/validates_timeliness/orm/mongoid_spec.rb
|
118
114
|
- spec/validates_timeliness/validator/after_spec.rb
|
119
115
|
- spec/validates_timeliness/validator/before_spec.rb
|
120
116
|
- spec/validates_timeliness/validator/is_at_spec.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", "~> 3.2.6"
|
6
|
-
gem "rspec", "~> 2.8"
|
7
|
-
gem "rspec-rails", "~> 2.8"
|
8
|
-
gem "timecop"
|
9
|
-
gem "rspec_tag_matchers"
|
10
|
-
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
11
|
-
gem "debugger", :platforms=>[:ruby_19]
|
12
|
-
gem "appraisal"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "mongoid", "~> 2.1.0"
|
15
|
-
|
16
|
-
gemspec :path=>"../"
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", "~> 3.2.6"
|
6
|
-
gem "rspec", "~> 2.8"
|
7
|
-
gem "rspec-rails", "~> 2.8"
|
8
|
-
gem "timecop"
|
9
|
-
gem "rspec_tag_matchers"
|
10
|
-
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
11
|
-
gem "debugger", :platforms=>[:ruby_19]
|
12
|
-
gem "appraisal"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "mongoid", "~> 2.2.0"
|
15
|
-
|
16
|
-
gemspec :path=>"../"
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", "~> 3.2.6"
|
6
|
-
gem "rspec", "~> 2.8"
|
7
|
-
gem "rspec-rails", "~> 2.8"
|
8
|
-
gem "timecop"
|
9
|
-
gem "rspec_tag_matchers"
|
10
|
-
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
11
|
-
gem "debugger", :platforms=>[:ruby_19]
|
12
|
-
gem "appraisal"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "mongoid", "~> 2.3.0"
|
15
|
-
|
16
|
-
gemspec :path=>"../"
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", "~> 3.2.6"
|
6
|
-
gem "rspec", "~> 2.8"
|
7
|
-
gem "rspec-rails", "~> 2.8"
|
8
|
-
gem "timecop"
|
9
|
-
gem "rspec_tag_matchers"
|
10
|
-
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
11
|
-
gem "debugger", :platforms=>[:ruby_19]
|
12
|
-
gem "appraisal"
|
13
|
-
gem "sqlite3"
|
14
|
-
gem "mongoid", "~> 2.4.0"
|
15
|
-
|
16
|
-
gemspec :path=>"../"
|
data/gemfiles/rails_3_0.gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rspec", "~> 2.8"
|
6
|
-
gem "rspec-rails", "~> 2.8"
|
7
|
-
gem "timecop"
|
8
|
-
gem "rspec_tag_matchers"
|
9
|
-
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
10
|
-
gem "debugger", :platforms=>[:ruby_19]
|
11
|
-
gem "appraisal"
|
12
|
-
gem "sqlite3"
|
13
|
-
gem "rails", "~> 3.0.0"
|
14
|
-
|
15
|
-
gemspec :path=>"../"
|
data/gemfiles/rails_3_1.gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rspec", "~> 2.8"
|
6
|
-
gem "rspec-rails", "~> 2.8"
|
7
|
-
gem "timecop"
|
8
|
-
gem "rspec_tag_matchers"
|
9
|
-
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
10
|
-
gem "debugger", :platforms=>[:ruby_19]
|
11
|
-
gem "appraisal"
|
12
|
-
gem "sqlite3"
|
13
|
-
gem "rails", "~> 3.1.0"
|
14
|
-
|
15
|
-
gemspec :path=>"../"
|
data/gemfiles/rails_3_2.gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rspec", "~> 2.8"
|
6
|
-
gem "rspec-rails", "~> 2.8"
|
7
|
-
gem "timecop"
|
8
|
-
gem "rspec_tag_matchers"
|
9
|
-
gem "ruby-debug", :platforms=>[:ruby_18, :jruby]
|
10
|
-
gem "debugger", :platforms=>[:ruby_19]
|
11
|
-
gem "appraisal"
|
12
|
-
gem "sqlite3"
|
13
|
-
gem "rails", "~> 3.2.0"
|
14
|
-
|
15
|
-
gemspec :path=>"../"
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module ValidatesTimeliness
|
2
|
-
module ORM
|
3
|
-
module Mongoid
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
# You need define the fields before you define the validations.
|
6
|
-
# It is best to use the plugin parser to avoid errors on a bad
|
7
|
-
# field value in Mongoid. Parser will return nil rather than error.
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
public
|
11
|
-
|
12
|
-
# Mongoid has no bulk attribute method definition hook. It defines
|
13
|
-
# them with each field definition. So we likewise define them after
|
14
|
-
# each validation is defined.
|
15
|
-
#
|
16
|
-
def timeliness_validation_for(attr_names, type)
|
17
|
-
super
|
18
|
-
attr_names.each { |attr_name| define_timeliness_write_method(attr_name) }
|
19
|
-
end
|
20
|
-
|
21
|
-
def timeliness_attribute_type(attr_name)
|
22
|
-
{
|
23
|
-
Date => :date,
|
24
|
-
Time => :time,
|
25
|
-
DateTime => :datetime
|
26
|
-
}[fields[database_field_name(attr_name)].type] || :datetime
|
27
|
-
end
|
28
|
-
|
29
|
-
protected
|
30
|
-
|
31
|
-
def timeliness_type_cast_code(attr_name, var_name)
|
32
|
-
type = timeliness_attribute_type(attr_name)
|
33
|
-
|
34
|
-
"#{var_name} = Timeliness::Parser.parse(value, :#{type})"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def reload(*args)
|
39
|
-
_clear_timeliness_cache
|
40
|
-
super
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
module Mongoid::Document
|
47
|
-
include ValidatesTimeliness::AttributeMethods
|
48
|
-
include ValidatesTimeliness::ORM::Mongoid
|
49
|
-
end
|