activemodel-form 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/README.md +2 -0
- data/activemodel-form.gemspec +2 -1
- data/lib/active_model/form/attributes.rb +2 -2
- data/lib/active_model/form/version.rb +1 -1
- data/spec/boolean_attribute_form_spec.rb +11 -0
- metadata +22 -5
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# ActiveModel::Form
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/MSch/activemodel-form.png)](http://travis-ci.org/MSch/activemodel-form)
|
4
|
+
|
3
5
|
ActiveModel lets you easily create objects that can be used in form helpers and even support round-tripping (assigning the submitted params again)
|
4
6
|
|
5
7
|
But ActiveModel doesn't support out of the box argument parsing, e.g. having a datetime attribute be a datetime attribute and a boolean attribute be a boolean attribute.
|
data/activemodel-form.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["martin@schuerrer.org"]
|
11
11
|
gem.description = %q{ActiveModel with support for booleans and datetimes in form helpers}
|
12
12
|
gem.summary = %q{}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "https://github.com/MSch/activemodel-form"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -22,4 +22,5 @@ Gem::Specification.new do |gem|
|
|
22
22
|
|
23
23
|
gem.add_development_dependency 'rake'
|
24
24
|
gem.add_development_dependency 'pry'
|
25
|
+
gem.add_development_dependency 'minitest'
|
25
26
|
end
|
@@ -2,9 +2,9 @@ module ActiveModel
|
|
2
2
|
class Form
|
3
3
|
module BooleanAttribute
|
4
4
|
def self.parse(v)
|
5
|
-
if ['1', 't', 'true', 'yes'].include? v
|
5
|
+
if ['1', 't', 'true', 'yes', true].include? v
|
6
6
|
true
|
7
|
-
elsif ['0', 'f', 'false', 'no'].include? v
|
7
|
+
elsif ['0', 'f', 'false', 'no', false].include? v
|
8
8
|
false
|
9
9
|
elsif ['', nil].include? v
|
10
10
|
nil
|
@@ -21,4 +21,15 @@ describe ActiveModel::Form do
|
|
21
21
|
form.checked.must_equal true
|
22
22
|
form.not_set.must_equal nil # TODO: Should this be nil or false?
|
23
23
|
end
|
24
|
+
|
25
|
+
it "accepts ordinary booleans" do
|
26
|
+
class FormWithBooleans < ActiveModel::Form
|
27
|
+
attribute :checked, :boolean
|
28
|
+
attribute :not_checked, :boolean
|
29
|
+
end
|
30
|
+
|
31
|
+
form = FormWithBooleans.new(:checked => true, :not_checked => false)
|
32
|
+
form.checked.must_equal true
|
33
|
+
form.not_checked.must_equal false
|
34
|
+
end
|
24
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: minitest
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
description: ActiveModel with support for booleans and datetimes in form helpers
|
79
95
|
email:
|
80
96
|
- martin@schuerrer.org
|
@@ -83,6 +99,7 @@ extensions: []
|
|
83
99
|
extra_rdoc_files: []
|
84
100
|
files:
|
85
101
|
- .gitignore
|
102
|
+
- .travis.yml
|
86
103
|
- Gemfile
|
87
104
|
- LICENSE.txt
|
88
105
|
- README.md
|
@@ -127,7 +144,7 @@ files:
|
|
127
144
|
- spec/integer_attribute_form_spec.rb
|
128
145
|
- spec/model_name_spec.rb
|
129
146
|
- spec/spec_helper.rb
|
130
|
-
homepage:
|
147
|
+
homepage: https://github.com/MSch/activemodel-form
|
131
148
|
licenses: []
|
132
149
|
post_install_message:
|
133
150
|
rdoc_options: []
|
@@ -141,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
158
|
version: '0'
|
142
159
|
segments:
|
143
160
|
- 0
|
144
|
-
hash:
|
161
|
+
hash: 1924311521467823083
|
145
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
163
|
none: false
|
147
164
|
requirements:
|
@@ -150,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
167
|
version: '0'
|
151
168
|
segments:
|
152
169
|
- 0
|
153
|
-
hash:
|
170
|
+
hash: 1924311521467823083
|
154
171
|
requirements: []
|
155
172
|
rubyforge_project:
|
156
173
|
rubygems_version: 1.8.24
|