activemodel-form 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/active_model/form/attributes.rb +18 -0
- data/lib/active_model/form/version.rb +1 -1
- data/spec/date_time_string_spec.rb +21 -0
- metadata +23 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbe2f1670a51ce74f8a77eafd80bb1216da01782
|
4
|
+
data.tar.gz: bcdf295cb55e85a2d1644b7a7b7467317ed8fbaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bb2bb5a4f8e899525983143e86ff970ba53d7d4df466607694d3805c2497b4ff53396a6e5dd0b8ad08abbe20c2ff2458f5d3d6d27c914dbb5a7a84cd5776fc8
|
7
|
+
data.tar.gz: 5aeff6a3faa6b79ffb0aa6e7c63af0a8795c25d86ec2147a31789bb72de584d8616b0a0c8d7290458dc688da5226cd5c95b6febeedcdc5db5a47c2a26cb11ea7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
#### 1.1.0
|
2
|
+
|
3
|
+
* Add support for parsing date params in ISO format (YYYY-MM-DD)
|
4
|
+
|
5
|
+
#### 1.0.0
|
6
|
+
|
7
|
+
* Add support for file attributes (Thanks [@haihappen](https://github.com/haihappen)).
|
8
|
+
|
1
9
|
#### 0.0.3
|
2
10
|
|
3
11
|
* Added simplecov (Thanks [@colszowka](https://github.com/colszowka))
|
@@ -86,6 +86,24 @@ module ActiveModel
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
module DateAttribute
|
90
|
+
def self.parse(v)
|
91
|
+
if v.is_a?(String)
|
92
|
+
Date.parse(v)
|
93
|
+
else
|
94
|
+
nil
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.type
|
99
|
+
:timestamp
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.number?
|
103
|
+
false
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
89
107
|
module DateTimeAttribute
|
90
108
|
def self.parse(v)
|
91
109
|
if v.compact.present?
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveModel::Form do
|
4
|
+
# DateTime params generated by e.g. https://github.com/zpaulovics/datetimepicker-rails
|
5
|
+
let(:params) do
|
6
|
+
{ "form"=> {"created_at" => "2014-10-30", "whatever" => "yeah"} }
|
7
|
+
end
|
8
|
+
|
9
|
+
it "parses the Rails form helper datetime params" do
|
10
|
+
class FormWithDateTime < ActiveModel::Form
|
11
|
+
attribute :created_at, :date
|
12
|
+
attribute :something_else, :string
|
13
|
+
attribute :whatever, :string
|
14
|
+
end
|
15
|
+
|
16
|
+
form = FormWithDateTime.new(params['form'])
|
17
|
+
form.created_at.must_equal(DateTime.new(2014, 10, 30, 0, 0))
|
18
|
+
form.something_else.must_equal nil
|
19
|
+
form.whatever.must_equal "yeah"
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Schuerrer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.7
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.2.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.2.7
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: actionpack
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: ActiveModel with support for booleans and datetimes in form helpers
|
@@ -115,8 +115,8 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- .gitignore
|
119
|
-
- .travis.yml
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
120
120
|
- CHANGELOG.md
|
121
121
|
- Gemfile
|
122
122
|
- LICENSE.txt
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/activemodel-form.rb
|
160
160
|
- spec/boolean_attribute_form_spec.rb
|
161
161
|
- spec/date_time_form_spec.rb
|
162
|
+
- spec/date_time_string_spec.rb
|
162
163
|
- spec/file_attribute_form_spec.rb
|
163
164
|
- spec/integer_attribute_form_spec.rb
|
164
165
|
- spec/model_name_spec.rb
|
@@ -173,23 +174,24 @@ require_paths:
|
|
173
174
|
- lib
|
174
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
175
176
|
requirements:
|
176
|
-
- -
|
177
|
+
- - ">="
|
177
178
|
- !ruby/object:Gem::Version
|
178
179
|
version: '0'
|
179
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
181
|
requirements:
|
181
|
-
- -
|
182
|
+
- - ">="
|
182
183
|
- !ruby/object:Gem::Version
|
183
184
|
version: '0'
|
184
185
|
requirements: []
|
185
186
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.2.2
|
187
188
|
signing_key:
|
188
189
|
specification_version: 4
|
189
190
|
summary: ''
|
190
191
|
test_files:
|
191
192
|
- spec/boolean_attribute_form_spec.rb
|
192
193
|
- spec/date_time_form_spec.rb
|
194
|
+
- spec/date_time_string_spec.rb
|
193
195
|
- spec/file_attribute_form_spec.rb
|
194
196
|
- spec/integer_attribute_form_spec.rb
|
195
197
|
- spec/model_name_spec.rb
|