multiparameter_date_time 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Set a DateTime via two accessors, one for the date, one for the time
4
4
 
5
+ [![Build Status](https://secure.travis-ci.org/Casecommons/multiparameter_date_time.png?branch=master)](http://travis-ci.org/Casecommons/multiparameter_date_time)
6
+ [![Dependency Status](https://gemnasium.com/Casecommons/multiparameter_date_time.png)](https://gemnasium.com/Casecommons/multiparameter_date_time)
7
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Casecommons/multiparameter_date_time)
8
+
9
+ ## Requirements
10
+
11
+ * Ruby 1.9
12
+
5
13
  ## Installation
6
14
 
7
15
  Add this line to your application's Gemfile:
@@ -66,6 +74,11 @@ MultiparameterDateTime.time_format = "%-I:%M %P"
66
74
  validates :published_at, presence: true, is_valid_multiparameter_date_time: true
67
75
  ````
68
76
 
77
+ ### Accessing the datetime error message used
78
+
79
+ ````ruby
80
+ IsValidMultiparameterDateTimeValidator.invalid_format_error_message
81
+ ````
69
82
 
70
83
  ## Contributing
71
84
 
@@ -14,7 +14,7 @@ class IsValidMultiparameterDateTimeValidator < ActiveModel::EachValidator
14
14
  end
15
15
 
16
16
  if date_invalid || time_invalid
17
- record.errors.add(attribute, invalid_format_error_message)
17
+ record.errors.add(attribute, self.class.invalid_format_error_message)
18
18
  elsif date_value.blank?
19
19
  record.errors.add(attribute, "Please enter a date.")
20
20
  elsif time_value.blank?
@@ -25,14 +25,12 @@ class IsValidMultiparameterDateTimeValidator < ActiveModel::EachValidator
25
25
  Time.zone.parse("#{date_value} #{time_value}")
26
26
  Time.zone.parse(attribute_value)
27
27
  rescue ArgumentError
28
- record.errors.add(attribute, invalid_format_error_message)
28
+ record.errors.add(attribute, self.class.invalid_format_error_message)
29
29
  end
30
30
  end
31
31
  end
32
32
 
33
- private
34
-
35
- def invalid_format_error_message
33
+ def self.invalid_format_error_message
36
34
  date_time = Time.zone.parse("1/29/2000 5:15pm")
37
35
  date_string = date_time.strftime(MultiparameterDateTime.date_format)
38
36
  time_string = date_time.strftime(MultiparameterDateTime.time_format)
@@ -1,3 +1,3 @@
1
1
  module MultiparameterDateTime
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -14,11 +14,13 @@ Gem::Specification.new do |gem|
14
14
  gem.require_paths = ["lib"]
15
15
  gem.version = MultiparameterDateTime::VERSION
16
16
 
17
+ gem.required_ruby_version = '>= 1.9.2'
18
+
17
19
  gem.add_dependency "american_date"
18
20
 
19
21
  gem.add_development_dependency 'activerecord'
20
22
  gem.add_development_dependency 'activesupport'
21
23
  gem.add_development_dependency 'rspec', '~> 2.11'
22
24
  gem.add_development_dependency 'with_model', "~> 0.3"
23
- gem.add_development_dependency 'informal', "~> 0.0.3"
25
+ gem.add_development_dependency 'informal', "~> 0.1.0"
24
26
  end
@@ -234,7 +234,7 @@ describe IsValidMultiparameterDateTimeValidator do
234
234
  end
235
235
  end
236
236
 
237
- context "accepts dates in a variety of formats" do
237
+ describe "accepts dates in a variety of formats" do
238
238
  ["2010-1-1", "02-01-1971", "4/4/92", "01/02/2001", "01/02/2001", "01.02.2011"].each do |format|
239
239
  context format do
240
240
  let(:date_string) { format }
@@ -250,4 +250,12 @@ describe IsValidMultiparameterDateTimeValidator do
250
250
  end
251
251
  end
252
252
 
253
+ describe ".invalid_format_error_message" do
254
+ subject { IsValidMultiparameterDateTimeValidator.invalid_format_error_message }
255
+
256
+ it do
257
+ should ==
258
+ "Please enter a valid date and time using the following formats: 1/29/2000, 5:15 pm"
259
+ end
260
+ end
253
261
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiparameter_date_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-08-13 00:00:00.000000000 Z
15
+ date: 2012-08-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: american_date
@@ -101,7 +101,7 @@ dependencies:
101
101
  requirements:
102
102
  - - ~>
103
103
  - !ruby/object:Gem::Version
104
- version: 0.0.3
104
+ version: 0.1.0
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ dependencies:
109
109
  requirements:
110
110
  - - ~>
111
111
  - !ruby/object:Gem::Version
112
- version: 0.0.3
112
+ version: 0.1.0
113
113
  description:
114
114
  email:
115
115
  - casecommons-dev@googlegroups.com
@@ -143,10 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ! '>='
145
145
  - !ruby/object:Gem::Version
146
- version: '0'
147
- segments:
148
- - 0
149
- hash: 2147667943549675245
146
+ version: 1.9.2
150
147
  required_rubygems_version: !ruby/object:Gem::Requirement
151
148
  none: false
152
149
  requirements:
@@ -155,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
152
  version: '0'
156
153
  segments:
157
154
  - 0
158
- hash: 2147667943549675245
155
+ hash: 4193815623193875602
159
156
  requirements: []
160
157
  rubyforge_project:
161
158
  rubygems_version: 1.8.24