hungryform 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 366185c77f738aac57f059664729402272c35d18
4
- data.tar.gz: 4368d143b24f7eec28af6ca428de93eebabbd6fd
3
+ metadata.gz: 39175652aa112a3085607dd1732fbce6a18c8346
4
+ data.tar.gz: 498c9429cddebc710586b04a567fc2971988f0ef
5
5
  SHA512:
6
- metadata.gz: 19bdd1d7bdad63873e2386fe74e0fe8efd184b7eb5d295acf79899093d57ee71a66bc7b36f380fa32b0555917a703ef0f5a6376df5f16df29065bee6d876420e
7
- data.tar.gz: db49ba35e648b857964f43fb82569f270521c196d8153f02337aed5ee47fd9e819233bf5eec81464b9aa42cf64252a6b0aa89191a4d208ac40d5ec53d762b0c1
6
+ metadata.gz: 2513481ab882a6262f40ebb689c5c94fc708c5c00625ab614cf92d36805a86802f4fb2c1c299fa209b40e383989248dd3257f8651cffae7ed38c476d585fea9a
7
+ data.tar.gz: 06c0805c025591833781ce40a039622b2e01831333a8f72ffeef29a420cdb3c5c409fff3df2252b1ee393786d4f51640c555970762acb2cd5448eb3d9eb5f6cc
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # HungryForm [![Build Status](https://travis-ci.org/andrba/hungryform.svg?branch=master)](https://travis-ci.org/andrba/hungryform) [![Code Climate](https://codeclimate.com/github/andrba/hungryform/badges/gpa.svg)](https://codeclimate.com/github/andrba/hungryform)
2
2
 
3
- HungryForm is a gem for managing multiple page forms. The main purpose of this gem is to give developers an easy DSL to build complex forms.
3
+ HungryForm is a gem for managing multiple page forms. The main purpose of this gem is to give developers an easy DSL to build complex forms. Rails integration can be done via the [hungryform-rails](https://github.com/andrba/hungryform-rails) gem.
4
4
 
5
5
  ## Usage
6
6
 
@@ -115,13 +115,10 @@ To configure the gem use the configuration block:
115
115
 
116
116
  ```ruby
117
117
  HungryForm.configure do |config|
118
- config.views_prefix = 'myform'
119
118
  config.text_field maxlength: 100
120
119
  end
121
120
  ```
122
121
 
123
- ```views_prefix```: Set this option in case you want to override the standard elements templates with your own ones. The prefix must match the folder name in your views folder where you keep the elements partials.
124
-
125
122
  ```text_field``` (or any other element name): Assign an attribute to all elements of this type
126
123
 
127
124
  ## Validation
@@ -0,0 +1,15 @@
1
+ module HungryForm
2
+ module Elements
3
+ class CheckboxField < Base::ActiveElement
4
+ def set_value
5
+ super
6
+
7
+ if resolver.params.key?(name)
8
+ self.attributes[:checked] = 'checked'
9
+ else
10
+ self.attributes[:checked] = ''
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -22,4 +22,5 @@ require_relative 'elements/html'
22
22
  require_relative 'elements/text_field'
23
23
  require_relative 'elements/select_field'
24
24
  require_relative 'elements/text_area'
25
+ require_relative 'elements/checkbox_field'
25
26
  require_relative 'elements/radio_group'
@@ -1,3 +1,3 @@
1
1
  module HungryForm
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ describe HungryForm::Elements::CheckboxField do
4
+ let(:resolver_options) { {} }
5
+ let(:resolver) { HungryForm::Resolver.new(resolver_options) }
6
+ let(:group_options) { {} }
7
+ let(:group) { HungryForm::Elements::Group.new(:group, nil, resolver, group_options) {} }
8
+ let(:options) { {} }
9
+
10
+ subject { HungryForm::Elements::CheckboxField.new(:element_name, group, resolver, options) {} }
11
+
12
+ it_behaves_like 'an element'
13
+ it_behaves_like 'an active element'
14
+
15
+ describe "#set_value" do
16
+ context "when resolver contains the element name" do
17
+ before { resolver_options[:params] = {"group_element_name" => "on"} }
18
+
19
+ it "should be checked" do
20
+ expect(subject.attributes[:checked]).to eq 'checked'
21
+ end
22
+ end
23
+
24
+ context "when resolver doesn't contain the element name" do
25
+ it "should not be cheched" do
26
+ expect(subject.attributes[:checked]).to eq ''
27
+ end
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hungryform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Bazhutkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -90,6 +90,7 @@ files:
90
90
  - lib/hungryform/elements/base/group.rb
91
91
  - lib/hungryform/elements/base/hashable.rb
92
92
  - lib/hungryform/elements/base/options_element.rb
93
+ - lib/hungryform/elements/checkbox_field.rb
93
94
  - lib/hungryform/elements/group.rb
94
95
  - lib/hungryform/elements/html.rb
95
96
  - lib/hungryform/elements/page.rb
@@ -102,6 +103,7 @@ files:
102
103
  - lib/hungryform/resolver.rb
103
104
  - lib/hungryform/validator.rb
104
105
  - lib/hungryform/version.rb
106
+ - spec/elements/checkbox_field_spec.rb
105
107
  - spec/elements/group_spec.rb
106
108
  - spec/elements/html_spec.rb
107
109
  - spec/elements/page_spec.rb
@@ -142,6 +144,7 @@ signing_key:
142
144
  specification_version: 4
143
145
  summary: A Ruby Library for working with multi page forms
144
146
  test_files:
147
+ - spec/elements/checkbox_field_spec.rb
145
148
  - spec/elements/group_spec.rb
146
149
  - spec/elements/html_spec.rb
147
150
  - spec/elements/page_spec.rb