date_validator 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use ruby-1.9.2@date_validator > /dev/null
data/Gemfile CHANGED
@@ -2,7 +2,9 @@
2
2
  source :gemcutter
3
3
 
4
4
  group :development do
5
- gem "rspec", ">= 2.0.0.beta.20"
5
+ gem "rspec", "2.0.0"
6
+ gem "jeweler"
7
+ gem "simplecov"
6
8
  gem "activesupport", "3.0.0"
7
9
  gem "tzinfo"
8
10
  end
@@ -8,16 +8,30 @@ GEM
8
8
  activesupport (3.0.0)
9
9
  builder (2.1.2)
10
10
  diff-lcs (1.1.2)
11
+ gemcutter (0.6.1)
12
+ git (1.2.5)
11
13
  i18n (0.4.1)
12
- rspec (2.0.0.beta.20)
13
- rspec-core (= 2.0.0.beta.20)
14
- rspec-expectations (= 2.0.0.beta.20)
15
- rspec-mocks (= 2.0.0.beta.20)
16
- rspec-core (2.0.0.beta.20)
17
- rspec-expectations (2.0.0.beta.20)
14
+ jeweler (1.4.0)
15
+ gemcutter (>= 0.1.0)
16
+ git (>= 1.2.5)
17
+ rubyforge (>= 2.0.0)
18
+ json_pure (1.4.6)
19
+ rspec (2.0.0)
20
+ rspec-core (= 2.0.0)
21
+ rspec-expectations (= 2.0.0)
22
+ rspec-mocks (= 2.0.0)
23
+ rspec-core (2.0.0)
24
+ rspec-expectations (2.0.0)
18
25
  diff-lcs (>= 1.1.2)
19
- rspec-mocks (2.0.0.beta.20)
20
- tzinfo (0.3.22)
26
+ rspec-mocks (2.0.0)
27
+ rspec-core (= 2.0.0)
28
+ rspec-expectations (= 2.0.0)
29
+ rubyforge (2.0.4)
30
+ json_pure (>= 1.1.7)
31
+ simplecov (0.3.6)
32
+ simplecov-html (>= 0.3.7)
33
+ simplecov-html (0.3.8)
34
+ tzinfo (0.3.23)
21
35
 
22
36
  PLATFORMS
23
37
  java
@@ -26,5 +40,7 @@ PLATFORMS
26
40
  DEPENDENCIES
27
41
  activemodel (= 3.0.0)
28
42
  activesupport (= 3.0.0)
29
- rspec (>= 2.0.0.beta.20)
43
+ jeweler
44
+ rspec (= 2.0.0)
45
+ simplecov
30
46
  tzinfo
@@ -1,6 +1,7 @@
1
1
  = date_validator
2
2
 
3
- A simple date validator for Rails 3.
3
+ A simple date validator for Rails 3. Compatible with Ruby 1.8, 1.9, JRuby 1.5.3
4
+ and Rubinius 1.1.
4
5
 
5
6
  gem sources -a http://gemcutter.org/
6
7
  gem install date_validator
@@ -8,7 +9,7 @@ A simple date validator for Rails 3.
8
9
  And I mean simple. In your model:
9
10
 
10
11
  validates :expiration_date, :date => {:after => lambda { Time.now } :before => lambda { Time.now + 1.year } }
11
- Using lambda prevents production cache issues.
12
+ # Using lambda prevents production cache issues
12
13
 
13
14
  For now these are the available options you can use:
14
15
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.8
1
+ 0.5.9
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{date_validator}
8
- s.version = "0.5.8"
8
+ s.version = "0.5.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oriol Gual", "Josep M. Bach", "Josep Jaume Rey"]
12
- s.date = %q{2010-09-10}
12
+ s.date = %q{2010-10-14}
13
13
  s.description = %q{A simple, ORM agnostic, Ruby 1.9 compatible date validator for Rails 3, based on ActiveModel. Currently supporting :after, :before, :after_or_equal_to and :before_or_equal_to options.}
14
14
  s.email = %q{info@codegram.com}
15
15
  s.extra_rdoc_files = [
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  ".document",
22
22
  ".gitignore",
23
23
  ".rspec",
24
+ ".rvmrc",
24
25
  "Gemfile",
25
26
  "Gemfile.lock",
26
27
  "LICENSE",
@@ -38,7 +39,7 @@ Gem::Specification.new do |s|
38
39
  s.homepage = %q{http://github.com/codegram/date_validator}
39
40
  s.rdoc_options = ["--charset=UTF-8"]
40
41
  s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.3.6}
42
+ s.rubygems_version = %q{1.3.7}
42
43
  s.summary = %q{A simple, ORM agnostic, Ruby 1.9 compatible date validator for Rails 3, based on ActiveModel.}
43
44
  s.test_files = [
44
45
  "spec/date_validator_spec.rb",
@@ -49,7 +50,7 @@ Gem::Specification.new do |s|
49
50
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
51
  s.specification_version = 3
51
52
 
52
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
54
  s.add_runtime_dependency(%q<activemodel>, [">= 3.0.0"])
54
55
  s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.20"])
55
56
  s.add_development_dependency(%q<activesupport>, [">= 3.0.0"])
@@ -56,14 +56,6 @@ module ActiveModel
56
56
  object.is_a?(Time) || (defined?(Date) and object.is_a?(Date)) || (defined?(ActiveSupport::TimeWithZone) and object.is_a?(ActiveSupport::TimeWithZone))
57
57
  end
58
58
 
59
- module ClassMethods
60
-
61
- def validates_date_of(*attr_names)
62
- validates_with DateValidator, _merge_attributes(attr_names)
63
- end
64
-
65
- end
66
-
67
59
  end
68
60
  end
69
61
  end
@@ -8,7 +8,7 @@ describe "DateValidator" do
8
8
  TestRecord.reset_callbacks(:validate)
9
9
  end
10
10
 
11
- it "should check validity of the arguments" do
11
+ it "checks validity of the arguments" do
12
12
  [3, "foo", 1..6].each do |wrong_argument|
13
13
  expect {
14
14
  TestRecord.validates :expiration_date, :date => {:before => wrong_argument}
@@ -16,6 +16,13 @@ describe "DateValidator" do
16
16
  end
17
17
  end
18
18
 
19
+ it "complains if provided with no options" do
20
+ TestRecord.validates :expiration_date, :date => {:before => Time.now}
21
+ model = TestRecord.new(nil)
22
+ model.should_not be_valid
23
+ model.errors[:expiration_date].should == ["is not a date"]
24
+ end
25
+
19
26
  [:valid,:invalid].each do |should_be|
20
27
 
21
28
  _context = should_be == :valid ? 'when value validates correctly' : 'when value does not match validation requirements'
@@ -33,7 +40,7 @@ describe "DateValidator" do
33
40
  when :before_or_equal_to then should_be == :valid ? now : now + 21000
34
41
  end
35
42
 
36
- it "should ensure that an attribute is #{should_be} when #{should_be == :valid ? 'respecting' : 'offending' } the #{check} check" do
43
+ it "ensures that an attribute is #{should_be} when #{should_be == :valid ? 'respecting' : 'offending' } the #{check} check" do
37
44
  TestRecord.validates :expiration_date, :date => {:"#{check}" => Time.now}
38
45
  model = TestRecord.new(model_date)
39
46
  should_be == :valid ? model.should(be_valid, "an attribute should be valid when respecting the #{check} check") : model.should_not(be_valid, "an attribute should be invalidwhen offending the #{check} check")
@@ -41,7 +48,7 @@ describe "DateValidator" do
41
48
 
42
49
  if _context == 'when value does not match validation requirements'
43
50
 
44
- it "should yield a default error message indicating that value must be #{check} validation requirements" do
51
+ it "yields a default error message indicating that value must be #{check} validation requirements" do
45
52
  TestRecord.validates :expiration_date, :date => {:"#{check}" => Time.now}
46
53
  model = TestRecord.new(model_date)
47
54
  model.should_not be_valid
@@ -54,7 +61,7 @@ describe "DateValidator" do
54
61
 
55
62
  if _context == 'when value does not match validation requirements'
56
63
 
57
- it "should allow for a custom validation message" do
64
+ it "allows for a custom validation message" do
58
65
  TestRecord.validates :expiration_date, :date => {:before_or_equal_to => Time.now, :message => 'must be after Christmas'}
59
66
  model = TestRecord.new(Time.now + 21000)
60
67
  model.should_not be_valid
@@ -72,7 +79,7 @@ describe "DateValidator" do
72
79
  extra_types.push(:time_with_zone) if defined?(ActiveSupport::TimeWithZone)
73
80
 
74
81
  extra_types.each do |type|
75
- it "should accept a #{type} as an argument to a check" do
82
+ it "accepts a #{type} as an argument to a check" do
76
83
  case type
77
84
  when :proc then
78
85
  expect {
@@ -96,12 +103,12 @@ describe "DateValidator" do
96
103
  end
97
104
  end
98
105
 
99
- it "should gracefully handle an unexpected result from a proc argument evaluation" do
106
+ it "gracefully handles an unexpected result from a proc argument evaluation" do
100
107
  TestRecord.validates :expiration_date, :date => {:after => Proc.new{ nil }}
101
108
  TestRecord.new(Time.now).should_not be_valid
102
109
  end
103
110
 
104
- it "should gracefully handle an unexpected result from a symbol argument evaluation" do
111
+ it "gracefully handles an unexpected result from a symbol argument evaluation" do
105
112
  TestRecord.send(:define_method, :min_date, lambda { nil })
106
113
  TestRecord.validates :expiration_date, :date => {:after => :min_date}
107
114
  TestRecord.new(Time.now).should_not be_valid
@@ -1,12 +1,15 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_group "Lib", "lib"
6
+ end
3
7
 
4
8
  require 'rubygems'
5
9
  require 'active_model'
6
10
 
7
11
  require 'date_validator'
8
12
  require 'rspec'
9
- require 'rspec/autorun'
10
13
 
11
14
  I18n.load_path += Dir[File.join('locales', '*.{rb,yml}')]
12
15
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 8
9
- version: 0.5.8
8
+ - 9
9
+ version: 0.5.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Oriol Gual
@@ -16,13 +16,14 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-10 00:00:00 +02:00
19
+ date: 2010-10-14 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: activemodel
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
@@ -37,6 +38,7 @@ dependencies:
37
38
  name: rspec
38
39
  prerelease: false
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
@@ -53,6 +55,7 @@ dependencies:
53
55
  name: activesupport
54
56
  prerelease: false
55
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
56
59
  requirements:
57
60
  - - ">="
58
61
  - !ruby/object:Gem::Version
@@ -67,6 +70,7 @@ dependencies:
67
70
  name: bundler
68
71
  prerelease: false
69
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
70
74
  requirements:
71
75
  - - ">="
72
76
  - !ruby/object:Gem::Version
@@ -81,6 +85,7 @@ dependencies:
81
85
  name: tzinfo
82
86
  prerelease: false
83
87
  requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
84
89
  requirements:
85
90
  - - ">="
86
91
  - !ruby/object:Gem::Version
@@ -103,6 +108,7 @@ files:
103
108
  - .document
104
109
  - .gitignore
105
110
  - .rspec
111
+ - .rvmrc
106
112
  - Gemfile
107
113
  - Gemfile.lock
108
114
  - LICENSE
@@ -126,6 +132,7 @@ rdoc_options:
126
132
  require_paths:
127
133
  - lib
128
134
  required_ruby_version: !ruby/object:Gem::Requirement
135
+ none: false
129
136
  requirements:
130
137
  - - ">="
131
138
  - !ruby/object:Gem::Version
@@ -133,6 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
140
  - 0
134
141
  version: "0"
135
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
136
144
  requirements:
137
145
  - - ">="
138
146
  - !ruby/object:Gem::Version
@@ -142,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
150
  requirements: []
143
151
 
144
152
  rubyforge_project:
145
- rubygems_version: 1.3.6
153
+ rubygems_version: 1.3.7
146
154
  signing_key:
147
155
  specification_version: 3
148
156
  summary: A simple, ORM agnostic, Ruby 1.9 compatible date validator for Rails 3, based on ActiveModel.