Compare commits

...

6 Commits
3.0.0 ... 3.0.1

Author SHA1 Message Date
Adam Meehan
20c0aaa793 version 3.0.1 2010-11-02 09:53:25 +11:00
Adam Meehan
a756b66f75 add contributors link and change credits to maintainers 2010-11-02 09:51:45 +11:00
José Valim
889b5a9b07 Move timeliness defined methods to a module so they can be overwritten. 2010-11-01 14:56:03 -02:00
José Valim
0e3f56e26d Update Gemfile.
* Use gemspec to retrieve timeliness and other gem specifications.
* Remove test group (since it is the only option) and break groups into AR and Mongoid.
2010-11-01 14:47:19 -02:00
Adam Meehan
7ca662ada8 readme words 2010-10-21 08:25:35 +11:00
Adam Meehan
03effb9e52 readme tweaks 2010-10-21 07:50:37 +11:00
9 changed files with 78 additions and 38 deletions

View File

@@ -1,3 +1,6 @@
= 3.0.1 [2010-11-02]
* Generate timeliness write methods in an included module to allow overriding in model class (josevalim)
= 3.0.0 [2010-10-18]
* Rails 3 and ActiveModel compatibility
* Uses ActiveModel::EachValidator as validator base class.

24
Gemfile
View File

@@ -1,16 +1,20 @@
source 'http://rubygems.org'
gem 'timeliness', '~> 0.1.1'
gemspec
group :test do
gem 'ZenTest'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'ZenTest'
gem 'rails', '3.0.0'
gem 'rspec', '>= 2.0.0.beta.17'
gem 'rspec-rails', '>= 2.0.0.beta.17'
gem 'timecop'
gem 'rspec_tag_matchers'
gem 'ruby-debug'
group :mongoid do
gem 'mongoid', '2.0.0.beta.17'
gem 'bson_ext', '1.0.4'
gem 'rspec', '>= 2.0.0.beta.17'
gem 'rspec-rails', '>= 2.0.0.beta.17'
gem 'timecop'
gem 'rspec_tag_matchers'
gem 'ruby-debug'
end
group :active_record do
gem 'sqlite3-ruby', :require => 'sqlite3'
end

View File

@@ -1,3 +1,9 @@
PATH
remote: .
specs:
validates_timeliness (3.0.0)
timeliness (~> 0.1.0)
GEM
remote: http://rubygems.org/
specs:
@@ -117,4 +123,5 @@ DEPENDENCIES
ruby-debug
sqlite3-ruby
timecop
timeliness (~> 0.1.1)
timeliness (~> 0.1.0)
validates_timeliness!

View File

@@ -18,9 +18,9 @@ If you a looking for the old version for Rails 2.x go here[http://github.com/adz
* Only Rails date/time validation plugin offering complete validation (See ORM/ODM support)
* Adds extensions to fix Rails date/time select issues
* Adds extensions to fix Rails date/time select issues (See Extensions)
* Uses extensible date/time parser ({timeliness gem}[http://github.com/adzap/timeliness])
* Uses extensible date/time parser (Using {timeliness gem}[http://github.com/adzap/timeliness]. See Plugin Parser)
* Supports I18n for the error messages
@@ -31,7 +31,7 @@ As plugin (from master)
rails plugin install git://github.com/adzap/validates_timeliness.git
As gem (in beta)
As gem
# in Gemfile
gem 'validates_timeliness', '~> 3.0.0'
@@ -46,6 +46,8 @@ Then run
This creates configuration initializer and locale files. In the initializer, you there are a number of config
options to customize the plugin.
NOTE: You may wish to enable the plugin parser and the extensions to start. Please read those sections first.
== Examples
@@ -175,7 +177,8 @@ You can also use validation options for custom error messages. The following opt
:after_message
:on_or_after_message
Note: There is no :between_message option. The between error message should be defined using the :on_or_before and :on_or_after messages.
Note: There is no :between_message option. The between error message should be defined using the
:on_or_before and :on_or_after messages.
It is highly recommended you use the I18n system for error messages.
@@ -254,36 +257,42 @@ To turn them on/off:
config.ignore_restriction_errors = true
=== Display Invalid Values in Select Helpers
The plugin offers an extension for ActionView to allowing invalid
date and time values to be redisplayed to the user as feedback, instead of
a blank field which happens by default in Rails. Though the date helpers make this a
pretty rare occurrence, given the select dropdowns for each date/time component, but
it may be something of interest.
To activate it, put this in an initializer:
# in the setup block
config.enable_date_time_select_extension!
== Extensions
=== Strict Parsing for Select Helpers
When using date/time select helpers, the component values are handled by ActiveRecord using
the Time class to instantiate them into a time value. But this mean that some invalid dates,
the Time class to instantiate them into a time value. This means that some invalid dates,
such as 31st June, are shifted forward and treated as valid. To handle these cases in a strict
way you can enable the plugin handler to treat them as invalid dates.
way, you can enable the plugin extension to treat them as invalid dates.
To activate it, put this in an initializer:
To activate it, uncomment this line in the initializer:
# in the setup block
config.enable_multiparameter_extension!
== Credits
=== Display Invalid Values in Select Helpers
* Adam Meehan (adam.meehan@gmail.com, http://github.com/adzap)
The plugin offers an extension for ActionView to allowing invalid date and time values to be
redisplayed to the user as feedback, instead of a blank field which happens by default in
Rails. Though the date helpers make this a pretty rare occurrence, given the select dropdowns
for each date/time component, but it may be something of interest.
To activate it, uncomment this line in the initializer:
# in the setup block
config.enable_date_time_select_extension!
== Contributors
To see the generous people who have contributed code, take a look at the {contributors list}[http://github.com/adzap/validates_timeliness/contributors].
== Maintainers
* {Adam Meehan}[http://github.com/adzap]
== License

View File

@@ -42,7 +42,7 @@ module ValidatesTimeliness
super
end
EOV
class_eval(method_body, __FILE__, line)
generated_timeliness_methods.module_eval(method_body, __FILE__, line)
end
def define_timeliness_before_type_cast_method(attr_name)
@@ -51,7 +51,11 @@ module ValidatesTimeliness
_timeliness_raw_value_for('#{attr_name}')
end
EOV
class_eval(method_body, __FILE__, line)
generated_timeliness_methods.module_eval(method_body, __FILE__, line)
end
def generated_timeliness_methods
@generated_timeliness_methods ||= Module.new.tap { |m| include(m) }
end
end

View File

@@ -1,3 +1,3 @@
module ValidatesTimeliness
VERSION = '3.0.0'
VERSION = '3.0.1'
end

View File

@@ -75,6 +75,13 @@ class Employee < ActiveRecord::Base
validates_time :birth_time
validates_datetime :birth_datetime
define_attribute_methods
attr_accessor :redefined_birth_date_called
def birth_date=(value)
self.redefined_birth_date_called = true
super
end
end
Rspec.configure do |c|

View File

@@ -34,6 +34,12 @@ describe ValidatesTimeliness::AttributeMethods do
r._timeliness_raw_value_for(:birth_datetime).should == date_string
end
it 'should not overwrite user defined methods' do
e = Employee.new
e.birth_date = '2010-01-01'
e.redefined_birth_date_called.should be_true
end
context "with plugin parser" do
class PersonWithParser
include TestModel

View File

@@ -2,11 +2,11 @@
Gem::Specification.new do |s|
s.name = %q{validates_timeliness}
s.version = "3.0.0"
s.version = "3.0.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Adam Meehan"]
s.date = %q{2010-10-18}
s.date = %q{2010-11-02}
s.description = %q{Date and time validation plugin for Rails which allows custom formats}
s.email = %q{adam.meehan@gmail.com}
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "LICENSE"]