In your Gemfile:
gem "has_safe_dates"
Do a bundle install, then for each model add the has_safe_dates class method to your model:
class Post < ActiveRecord::Base
has_safe_dates :published_date
end
You can now do things like this:
post.update_attributes(:published_date => '1st of November 2012')
And it will work.
Uses Chronic for parsing of the dates to help
HasSafeDates is developed under Ruby-1.9.2-p290
To get the tests to run, make sure you have sqlite3 installed on your system, then run:
$ bundle install
$ rake
Do the following to publish and push a new gem:
-
Make sure the local working copy is clean with no pending commits:
$ git status
nothing to commit (working directory clean)
-
Edit the version number and increment per SEMVER versioning:
$ vi lib/has_safe_dates/version.rb
-
Run gem build to create the gem:
$ gem build has_safe_dates.gemspec
-
Test install the gem locally:
$ gem install has_safe_dates-0.0.1.gem
-
Commit any changes and tag the commit at the current version:
$ git commit lib/has_safe_dates/version.rb -m "Releasing v0.0.1" $ git tag v0.0.1 $ git push
-
Push the gem to rubygems:
$ gem push has_safe_dates-0.0.1.gem