has_safe_dates 0.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.
- data/Gemfile +14 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +102 -0
- data/VERSION +1 -0
- data/has_safe_dates.gemspec +64 -0
- data/has_safe_dates.gemspec.txt +41 -0
- data/lib/has_safe_dates.rb +4 -0
- data/lib/has_safe_dates/core_ext.rb +59 -0
- data/spec/db/database.yml +21 -0
- data/spec/db/schema.rb +14 -0
- data/spec/has_safe_dates_spec.rb +84 -0
- data/spec/spec_helper.rb +35 -0
- metadata +154 -0
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.8.3"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Kyle Ginavan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
HasSafeDates
|
2
|
+
===========================
|
3
|
+
|
4
|
+
Installation
|
5
|
+
------------------------
|
6
|
+
|
7
|
+
In your Gemfile:
|
8
|
+
|
9
|
+
gem "has_safe_dates"
|
10
|
+
|
11
|
+
Do a bundle install, then for each model add the has_safe_dates class method to your model:
|
12
|
+
|
13
|
+
class Post < ActiveRecord::Base
|
14
|
+
has_safe_dates :published_date
|
15
|
+
end
|
16
|
+
|
17
|
+
You can now do things like this:
|
18
|
+
|
19
|
+
post.update_attributes(:published_date => '1st of November 2012')
|
20
|
+
|
21
|
+
And it will work.
|
22
|
+
|
23
|
+
Uses [Chronic](https://github.com/mojombo/chronic) for parsing of the dates to help
|
data/Rakefile
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "has_safe_dates"
|
18
|
+
gem.homepage = "http://github.com/kylejginavan/has_safe_dates"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{The easy way to add safe dates to any Rails model.}
|
21
|
+
gem.description = %Q{Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings.}
|
22
|
+
gem.email = "kylejginavan@gmail.com"
|
23
|
+
gem.homepage = "http://github.com/kylejginavan/has_safe_dates"
|
24
|
+
gem.authors = ["kylejginavan"]
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rdoc/task'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "has_safe_dates #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
54
|
+
|
55
|
+
=begin
|
56
|
+
|
57
|
+
begin
|
58
|
+
require 'jeweler'
|
59
|
+
Jeweler::Tasks.new do |gem|
|
60
|
+
gem.name = "has_safe_dates"
|
61
|
+
gem.summary = %Q{The easy way to add safe dates to any Rails model.}
|
62
|
+
gem.description = %Q{Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings.}
|
63
|
+
gem.email = "kylejginavan@gmail.com"
|
64
|
+
gem.homepage = "http://github.com/kylejginavan/has_safe_dates"
|
65
|
+
gem.add_dependency('builder')
|
66
|
+
gem.authors = ["kylejginavan"]
|
67
|
+
end
|
68
|
+
Jeweler::GemcutterTasks.new
|
69
|
+
rescue LoadError
|
70
|
+
puts "has_safe_dates (or a dependency) not available. Install it with: gem install has_safe_dates"
|
71
|
+
end
|
72
|
+
|
73
|
+
begin
|
74
|
+
require 'bundler/setup'
|
75
|
+
rescue LoadError
|
76
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
77
|
+
end
|
78
|
+
|
79
|
+
# begin
|
80
|
+
# require 'rdoc/task'
|
81
|
+
# rescue LoadError
|
82
|
+
# require 'rdoc/rdoc'
|
83
|
+
# require 'rake/task'
|
84
|
+
# RDoc::Task = Rake::RDocTask
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# RDoc::Task.new(:rdoc) do |rdoc|
|
88
|
+
# rdoc.rdoc_dir = 'rdoc'
|
89
|
+
# rdoc.title = 'SafeDates'
|
90
|
+
# rdoc.options << '--line-numbers'
|
91
|
+
# rdoc.rdoc_files.include('README.rdoc')
|
92
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
93
|
+
# end
|
94
|
+
|
95
|
+
Bundler::GemHelper.install_tasks
|
96
|
+
|
97
|
+
task :spec do
|
98
|
+
sh("bundle exec rspec spec") { |ok, res| }
|
99
|
+
end
|
100
|
+
|
101
|
+
task :default => :spec
|
102
|
+
=end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{has_safe_dates}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["kylejginavan"]
|
12
|
+
s.date = %q{2012-02-24}
|
13
|
+
s.description = %q{Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings.}
|
14
|
+
s.email = %q{kylejginavan@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"Gemfile",
|
21
|
+
"LICENSE.txt",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"has_safe_dates.gemspec",
|
26
|
+
"has_safe_dates.gemspec.txt",
|
27
|
+
"lib/has_safe_dates.rb",
|
28
|
+
"lib/has_safe_dates/core_ext.rb",
|
29
|
+
"spec/db/database.yml",
|
30
|
+
"spec/db/schema.rb",
|
31
|
+
"spec/has_safe_dates_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/kylejginavan/has_safe_dates}
|
35
|
+
s.licenses = ["MIT"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.5.2}
|
38
|
+
s.summary = %q{The easy way to add safe dates to any Rails model.}
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
45
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
46
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
47
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
48
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
51
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
54
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
58
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
61
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Describe your gem and declare its dependencies:
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "has_safe_dates"
|
6
|
+
s.version = HasSafeDates::VERSION
|
7
|
+
s.authors = ["kylejginavan"]
|
8
|
+
s.date = %q{2012-02-24}
|
9
|
+
s.description = %q{Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings}
|
10
|
+
s.email = %q{kylejginavan@gmail.com}
|
11
|
+
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.md"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
"Gemfile",
|
18
|
+
"Rakefile",
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"has_safe_dates.gemspec",
|
23
|
+
"lib/has_safe_dates/core_ext.rb",
|
24
|
+
"lib/has_safe_dates/version.rb",
|
25
|
+
"lib/has_safe_dates.rb",
|
26
|
+
"spec/db/database.yml",
|
27
|
+
"spec/db/schema.rb",
|
28
|
+
"spec/has_safe_dates_spec.rb",
|
29
|
+
"spec/spec_helper.rb"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/kylejginavan/has_safe_dates}
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.summary = %q{Chronic based date setting for ActiveRecord models}
|
34
|
+
|
35
|
+
s.add_dependency('activerecord', ['>= 3.1.0'])
|
36
|
+
s.add_dependency('chronic')
|
37
|
+
|
38
|
+
s.add_development_dependency("sqlite3")
|
39
|
+
s.add_development_dependency("rspec")
|
40
|
+
s.add_development_dependency('database_cleaner')
|
41
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'chronic'
|
2
|
+
|
3
|
+
module HasSafeDates
|
4
|
+
|
5
|
+
module CoreExt
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
def has_safe_fields_config
|
11
|
+
@@has_safe_fields_config ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def has_safe_dates(*args)
|
15
|
+
options = args.extract_options!
|
16
|
+
|
17
|
+
if options[:error_message].present?
|
18
|
+
has_safe_fields_config[:error_message] = options[:error_message]
|
19
|
+
else
|
20
|
+
has_safe_fields_config[:error_message] = I18n.translate('activerecord.errors.messages')[:invalid] || 'is invalid'
|
21
|
+
end
|
22
|
+
|
23
|
+
if args.blank?
|
24
|
+
raise ArgumentError, 'Must define the fields you want to be converted to safe dates with "has_safe_dates :my_field_name_date, :my_other_field_name_date"'
|
25
|
+
end
|
26
|
+
has_safe_fields_config[:fields] = args.map(&:to_s)
|
27
|
+
has_safe_fields_config[:fields].each do |field|
|
28
|
+
define_method "#{field.to_s}=" do |value|
|
29
|
+
if value.present?
|
30
|
+
value = Chronic.parse(value)
|
31
|
+
self.errors.add(field, self.class.has_safe_fields_config[:error_message]) unless value.present?
|
32
|
+
end
|
33
|
+
super value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def read_value_from_parameter(name, values_hash_from_param)
|
40
|
+
if self.class.has_safe_fields_config[:fields].include?(name.to_s)
|
41
|
+
|
42
|
+
max_position = extract_max_param_for_multiparameter_attributes(values_hash_from_param, 6)
|
43
|
+
return nil if (1..3).any? {|position| values_hash_from_param[position].blank?}
|
44
|
+
set_values = (1..max_position).collect{|position| values_hash_from_param[position] }
|
45
|
+
|
46
|
+
date = set_values[0..2].join('-')
|
47
|
+
time = set_values[3..5].join(':')
|
48
|
+
value = Chronic.parse("#{date} #{time}")
|
49
|
+
|
50
|
+
return value
|
51
|
+
else
|
52
|
+
super name, values_hash_from_param
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
ActiveRecord::Base.send :include, HasSafeDates::CoreExt
|
@@ -0,0 +1,21 @@
|
|
1
|
+
sqlite:
|
2
|
+
adapter: sqlite
|
3
|
+
database: spec/db/test.sqlite
|
4
|
+
|
5
|
+
sqlite3:
|
6
|
+
adapter: sqlite3
|
7
|
+
database: spec/db/test.sqlite3
|
8
|
+
|
9
|
+
postgresql:
|
10
|
+
adapter: postgresql
|
11
|
+
username: postgres
|
12
|
+
password: postgres
|
13
|
+
database: has_custom_fields_plugin_test
|
14
|
+
min_messages: ERROR
|
15
|
+
|
16
|
+
mysql:
|
17
|
+
adapter: mysql
|
18
|
+
host: localhost
|
19
|
+
username: root
|
20
|
+
password:
|
21
|
+
database: has_custom_fields_plugin_test
|
data/spec/db/schema.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# require File.join(File.dirname(__FILE__), 'fixtures/document')
|
2
|
+
|
3
|
+
ActiveRecord::Schema.define(:version => 0) do
|
4
|
+
|
5
|
+
create_table "posts", :force => true do |t|
|
6
|
+
t.string "title"
|
7
|
+
t.date "published_date"
|
8
|
+
t.date "safe_date"
|
9
|
+
t.date "unsafe_date"
|
10
|
+
t.date "created_at"
|
11
|
+
t.date "updated_at"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestUser < ActiveRecord::Base; end
|
4
|
+
|
5
|
+
class Post < ActiveRecord::Base
|
6
|
+
has_safe_dates :published_date, :safe_date, :error_message => 'is not a real date'
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "HasSafeDates" do
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
@post = Post.new
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "class method" do
|
16
|
+
|
17
|
+
it "should work" do
|
18
|
+
expect {
|
19
|
+
TestUser.send(:has_safe_dates, :published_date)
|
20
|
+
}.to_not raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should raise an error if no fields are passed in" do
|
24
|
+
expect {
|
25
|
+
TestUser.send(:has_safe_dates)
|
26
|
+
}.to raise_error(ArgumentError, 'Must define the fields you want to be converted to safe dates with "has_safe_dates :my_field_name_date, :my_other_field_name_date"')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "does not touch an field that it has not been told to make safe" do
|
30
|
+
@post.update_attribute(:unsafe_date, '1st of December 2012')
|
31
|
+
@post.reload
|
32
|
+
@post.unsafe_date.should be_nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "safe date parsing" do
|
37
|
+
|
38
|
+
['2012-12-1', '1st of December 2012', 'first of dec 2012', '1 Dec 2012'].each do |date|
|
39
|
+
it "allows you to set the date as '#{date}'" do
|
40
|
+
@post.update_attribute(:safe_date, date)
|
41
|
+
@post.reload
|
42
|
+
@post.safe_date.should == Date.new(2012, 12, 1)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
[' ', '', nil].each do |date|
|
47
|
+
it "sets the field to nil if given the blank value #{date.inspect}" do
|
48
|
+
@post.update_attribute(:safe_date, date)
|
49
|
+
@post.reload
|
50
|
+
@post.safe_date.should == nil
|
51
|
+
@post.errors.should be_blank
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
['random', 'does not compute'].each do |date|
|
56
|
+
it "sets the field to nil and sets a validation error if given the value #{date.inspect}" do
|
57
|
+
@post.update_attribute(:safe_date, date)
|
58
|
+
@post.reload
|
59
|
+
@post.safe_date.should == nil
|
60
|
+
@post.errors.should_not be_blank
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "multiparameter parsing" do
|
66
|
+
it "doesn't blow up when given an incorrect values" do
|
67
|
+
invalid_attributes = {'published_date(1)' => "abc", 'published_date(2)' => "12", 'published_date(3)' => "1"}
|
68
|
+
expect {
|
69
|
+
@post.update_attributes(invalid_attributes)
|
70
|
+
}.to_not raise_error
|
71
|
+
end
|
72
|
+
|
73
|
+
it "does not interfere with a date column that it has not been told to make safe" do
|
74
|
+
invalid_attributes = {'unsafe_date(1)' => "abc", 'unsafe_date(2)' => "12", 'unsafe_date(3)' => "1"}
|
75
|
+
expect {
|
76
|
+
@post.update_attributes(invalid_attributes)
|
77
|
+
}.to raise_error(ActiveRecord::MultiparameterAssignmentErrors, '1 error(s) on assignment of multiparameter attributes')
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "active_support"
|
2
|
+
require "active_record"
|
3
|
+
require "database_cleaner"
|
4
|
+
|
5
|
+
ENV['debug'] = 'test' unless ENV['debug']
|
6
|
+
|
7
|
+
# Establish DB Connection
|
8
|
+
config = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'db', 'database.yml')))
|
9
|
+
ActiveRecord::Base.configurations = {'test' => config[ENV['DB'] || 'sqlite3']}
|
10
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
|
11
|
+
|
12
|
+
# Load Test Schema into the Database
|
13
|
+
load(File.dirname(__FILE__) + "/db/schema.rb")
|
14
|
+
|
15
|
+
# Load in our code
|
16
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
17
|
+
|
18
|
+
require 'has_safe_dates'
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
|
22
|
+
config.before(:suite) do
|
23
|
+
DatabaseCleaner.strategy = :transaction
|
24
|
+
DatabaseCleaner.clean_with(:truncation)
|
25
|
+
end
|
26
|
+
|
27
|
+
config.before(:each) do
|
28
|
+
DatabaseCleaner.start
|
29
|
+
end
|
30
|
+
|
31
|
+
config.after(:each) do
|
32
|
+
DatabaseCleaner.clean
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: has_safe_dates
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 0.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- kylejginavan
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-02-24 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :development
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
name: shoulda
|
33
|
+
version_requirements: *id001
|
34
|
+
prerelease: false
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :development
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 31
|
43
|
+
segments:
|
44
|
+
- 3
|
45
|
+
- 12
|
46
|
+
version: "3.12"
|
47
|
+
name: rdoc
|
48
|
+
version_requirements: *id002
|
49
|
+
prerelease: false
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
type: :development
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 23
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 0
|
61
|
+
- 0
|
62
|
+
version: 1.0.0
|
63
|
+
name: bundler
|
64
|
+
version_requirements: *id003
|
65
|
+
prerelease: false
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
type: :development
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 49
|
74
|
+
segments:
|
75
|
+
- 1
|
76
|
+
- 8
|
77
|
+
- 3
|
78
|
+
version: 1.8.3
|
79
|
+
name: jeweler
|
80
|
+
version_requirements: *id004
|
81
|
+
prerelease: false
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
type: :development
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
name: rcov
|
94
|
+
version_requirements: *id005
|
95
|
+
prerelease: false
|
96
|
+
description: Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings.
|
97
|
+
email: kylejginavan@gmail.com
|
98
|
+
executables: []
|
99
|
+
|
100
|
+
extensions: []
|
101
|
+
|
102
|
+
extra_rdoc_files:
|
103
|
+
- LICENSE.txt
|
104
|
+
- README.rdoc
|
105
|
+
files:
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.rdoc
|
109
|
+
- Rakefile
|
110
|
+
- VERSION
|
111
|
+
- has_safe_dates.gemspec
|
112
|
+
- has_safe_dates.gemspec.txt
|
113
|
+
- lib/has_safe_dates.rb
|
114
|
+
- lib/has_safe_dates/core_ext.rb
|
115
|
+
- spec/db/database.yml
|
116
|
+
- spec/db/schema.rb
|
117
|
+
- spec/has_safe_dates_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
has_rdoc: true
|
120
|
+
homepage: http://github.com/kylejginavan/has_safe_dates
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
version: "0"
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
version: "0"
|
146
|
+
requirements: []
|
147
|
+
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 1.5.2
|
150
|
+
signing_key:
|
151
|
+
specification_version: 3
|
152
|
+
summary: The easy way to add safe dates to any Rails model.
|
153
|
+
test_files: []
|
154
|
+
|