foundation_rails_helper 2.0.0 → 4.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.
- checksums.yaml +5 -5
- data/.rubocop.yml +3 -6
- data/.rubocop_todo.yml +6 -48
- data/.travis.yml +29 -11
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -0
- data/README.md +49 -50
- data/Rakefile +1 -0
- data/foundation_rails_helper.gemspec +31 -32
- data/lib/foundation_rails_helper.rb +2 -0
- data/lib/foundation_rails_helper/action_view_extension.rb +1 -0
- data/lib/foundation_rails_helper/configuration.rb +4 -1
- data/lib/foundation_rails_helper/flash_helper.rb +43 -16
- data/lib/foundation_rails_helper/form_builder.rb +61 -83
- data/lib/foundation_rails_helper/size_class_calculator.rb +32 -0
- data/lib/foundation_rails_helper/version.rb +2 -1
- data/lib/railtie.rb +1 -0
- data/spec/.rubocop.yml +3 -0
- data/spec/foundation_rails_helper/configuration_spec.rb +30 -3
- data/spec/foundation_rails_helper/flash_helper_spec.rb +37 -23
- data/spec/foundation_rails_helper/form_builder_spec.rb +464 -178
- data/spec/spec_helper.rb +1 -0
- data/spec/support/classes/author.rb +13 -0
- data/spec/support/classes/book.rb +13 -0
- data/spec/support/classes/genre.rb +13 -0
- data/spec/support/mock_rails.rb +64 -100
- metadata +39 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c5962c4414ac022cb6a63fb5434372336432cf09de65ab351cd70e9c14c58aba
|
4
|
+
data.tar.gz: f50f71a68f51ce4bb94ba4ed11a826460b4fc6de56555cfb9c8bbe8806798fd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 856f10ab7f85bb7890215c1904458aa929d560f7fea557e9a18fb0d0ec7aa9564beae795f4e443cbec7746923db2687df16b270b1dcb6a8b4fac92fd0385dfb6
|
7
|
+
data.tar.gz: 9df3bef01064d042534444257f31723367742fec84d41265bd7a40bf7d5a974475fb1a7475b7e45e859b2840d3c360aa3cd69d8d5c8f4d29d471f0daed3fda29
|
data/.rubocop.yml
CHANGED
@@ -9,11 +9,8 @@ AllCops:
|
|
9
9
|
Exclude:
|
10
10
|
- 'vendor/**/*'
|
11
11
|
|
12
|
-
# A quick fix for not having magic comments at the top of each file
|
13
|
-
# # frozen_string_literal: true
|
14
|
-
# https://github.com/bbatsov/rubocop/issues/3284
|
15
|
-
FrozenStringLiteralComment:
|
16
|
-
Enabled: false
|
17
|
-
|
18
12
|
Documentation:
|
19
13
|
Enabled: false
|
14
|
+
|
15
|
+
Style/VariableNumber:
|
16
|
+
EnforcedStyle: 'snake_case'
|
data/.rubocop_todo.yml
CHANGED
@@ -1,67 +1,25 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2017-01-13 13:27:28 -0800 using RuboCop version 0.44.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
Lint/NestedMethodDefinition:
|
11
|
-
Exclude:
|
12
|
-
- 'spec/support/mock_rails.rb'
|
13
|
-
|
14
|
-
# Offense count: 3
|
9
|
+
# Offense count: 1
|
15
10
|
Metrics/AbcSize:
|
16
|
-
Max:
|
11
|
+
Max: 17
|
17
12
|
|
18
13
|
# Offense count: 1
|
19
14
|
# Configuration parameters: CountComments.
|
20
15
|
Metrics/ClassLength:
|
21
|
-
Max:
|
16
|
+
Max: 183
|
22
17
|
|
23
18
|
# Offense count: 1
|
24
19
|
Metrics/CyclomaticComplexity:
|
25
20
|
Max: 7
|
26
21
|
|
27
|
-
# Offense count: 157
|
28
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
29
|
-
# URISchemes: http, https
|
30
|
-
Metrics/LineLength:
|
31
|
-
Max: 163
|
32
|
-
|
33
|
-
# Offense count: 5
|
34
|
-
# Configuration parameters: CountComments.
|
35
|
-
Metrics/MethodLength:
|
36
|
-
Max: 55
|
37
|
-
|
38
22
|
# Offense count: 1
|
39
23
|
# Configuration parameters: CountComments.
|
40
|
-
Metrics/
|
41
|
-
Max:
|
42
|
-
|
43
|
-
# Offense count: 2
|
44
|
-
# Configuration parameters: CountKeywordArgs.
|
45
|
-
Metrics/ParameterLists:
|
46
|
-
Max: 8
|
47
|
-
|
48
|
-
# Offense count: 1
|
49
|
-
Metrics/PerceivedComplexity:
|
50
|
-
Max: 8
|
51
|
-
|
52
|
-
# Offense count: 3
|
53
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
54
|
-
# SupportedStyles: nested, compact
|
55
|
-
Style/ClassAndModuleChildren:
|
56
|
-
Exclude:
|
57
|
-
- 'spec/support/mock_rails.rb'
|
58
|
-
|
59
|
-
# Offense count: 1
|
60
|
-
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
|
61
|
-
# NamePrefix: is_, has_, have_
|
62
|
-
# NamePrefixBlacklist: is_, has_, have_
|
63
|
-
# NameWhitelist: is_a?
|
64
|
-
Style/PredicateName:
|
65
|
-
Exclude:
|
66
|
-
- 'spec/**/*'
|
67
|
-
- 'lib/foundation_rails_helper/form_builder.rb'
|
24
|
+
Metrics/MethodLength:
|
25
|
+
Max: 13
|
data/.travis.yml
CHANGED
@@ -3,20 +3,38 @@ branches:
|
|
3
3
|
only:
|
4
4
|
- master
|
5
5
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
6
|
+
- 2.3.8
|
7
|
+
- 2.4.10
|
8
|
+
- 2.5.8
|
9
|
+
- 2.6.6
|
10
|
+
- 2.7.2
|
10
11
|
env:
|
11
|
-
- "RAILS_VERSION=4.1.0"
|
12
12
|
- "RAILS_VERSION=4.2.0"
|
13
13
|
- "RAILS_VERSION=5.0.0"
|
14
|
-
|
14
|
+
- "RAILS_VERSION=5.2.0"
|
15
|
+
- "RAILS_VERSION=6.0.0"
|
16
|
+
- "RAILS_VERSION=6.1.0"
|
17
|
+
jobs:
|
15
18
|
exclude:
|
16
|
-
- rvm: 2.
|
19
|
+
- rvm: 2.4.10
|
20
|
+
env: "RAILS_VERSION=6.1.0"
|
21
|
+
- rvm: 2.3.8
|
22
|
+
env: "RAILS_VERSION=6.1.0"
|
23
|
+
- rvm: 2.7.2
|
24
|
+
env: "RAILS_VERSION=6.0.0"
|
25
|
+
- rvm: 2.4.10
|
26
|
+
env: "RAILS_VERSION=6.0.0"
|
27
|
+
- rvm: 2.3.8
|
28
|
+
env: "RAILS_VERSION=6.0.0"
|
29
|
+
- rvm: 2.7.2
|
30
|
+
env: "RAILS_VERSION=5.2.0"
|
31
|
+
- rvm: 2.7.2
|
17
32
|
env: "RAILS_VERSION=5.0.0"
|
18
|
-
- rvm: 2.
|
19
|
-
env: "RAILS_VERSION=4.
|
20
|
-
- rvm: 2.
|
33
|
+
- rvm: 2.7.2
|
34
|
+
env: "RAILS_VERSION=4.2.0"
|
35
|
+
- rvm: 2.6.6
|
36
|
+
env: "RAILS_VERSION=4.2.0"
|
37
|
+
- rvm: 2.5.8
|
38
|
+
env: "RAILS_VERSION=4.2.0"
|
39
|
+
- rvm: 2.4.10
|
21
40
|
env: "RAILS_VERSION=4.2.0"
|
22
|
-
sudo: false
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
## Version 3.0.0
|
2
|
+
* Added Foundation 6 support
|
3
|
+
* Added auto_labels config
|
4
|
+
|
1
5
|
## Version 2.0
|
2
6
|
This will be used for Foundation 5 support
|
3
7
|
|
4
8
|
### Breaking changes:
|
5
9
|
* Dropped support for Ruby 1.9.3
|
10
|
+
* display_flash_messages now requires the key_matching hash to be prefixed with the keyword argument :key_matching
|
6
11
|
|
7
12
|
### Features:
|
8
13
|
* Add Rubocop code style linting
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,23 +1,34 @@
|
|
1
1
|
# Foundation Rails Helper [](http://travis-ci.org/sgruhier/foundation_rails_helper)
|
2
2
|
|
3
|
-
Gem for Rails 4.1+ applications that use the excellent Zurb Foundation framework.
|
3
|
+
Gem for Rails 4.1+ applications that use the excellent [Zurb Foundation framework](https://github.com/zurb/foundation-rails).
|
4
4
|
|
5
|
-
|
6
|
-
* [Zurb Foundation Rails](https://github.com/zurb/foundation-rails)
|
7
|
-
|
8
|
-
So far it includes:
|
5
|
+
Includes:
|
9
6
|
|
10
7
|
* A custom FormBuilder that generates a form using the Foundation framework classes. It replaces the current `form_for`, so there is no need to change your Rails code. Error messages are properly displayed.
|
11
8
|
|
12
|
-
* A `display_flash_messages` helper method that uses Zurb Foundation
|
9
|
+
* A `display_flash_messages` helper method that uses Zurb Foundation Callout UI.
|
13
10
|
|
14
|
-
|
11
|
+
## Installation
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'foundation-rails', '~> 6.0' # required
|
17
|
+
gem 'foundation_rails_helper', '~> 3.0'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
```bash
|
23
|
+
$ bundle
|
24
|
+
```
|
25
|
+
|
26
|
+
## Compatibility
|
27
|
+
|
28
|
+
* Only Rails 4.1/4.2/5/6, and Foundation 6 are fully supported
|
29
|
+
* Some features may work with Foundation 5 and older, but results may vary, and markup which exists only for those versions will be gradually removed
|
30
|
+
* Legacy branches exist for Rails 3, 4.0, and Foundation 5 (see the rails3, rails4.0, and foundation-5 branches). These are not actively supported, and fixes are not retroactively applied, but pull requests are welcome.
|
31
|
+
* We test against ruby versions 2.1 and up. This gem may still work fine on 1.9.3, but your mileage may vary
|
21
32
|
|
22
33
|
|
23
34
|
## Screenshots
|
@@ -27,7 +38,7 @@ A classic devise sign up view will look like this:
|
|
27
38
|
|
28
39
|
```erb
|
29
40
|
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
30
|
-
<%= f.email_field :email
|
41
|
+
<%= f.email_field :email %>
|
31
42
|
<%= f.password_field :password %>
|
32
43
|
<%= f.password_field :password_confirmation %>
|
33
44
|
|
@@ -45,10 +56,10 @@ A classic devise sign up view will look like this:
|
|
45
56
|
<tbody>
|
46
57
|
<tr>
|
47
58
|
<td valign='top'>
|
48
|
-
<img src="https://cloud.githubusercontent.com/assets/1400414/
|
59
|
+
<img src="https://cloud.githubusercontent.com/assets/1400414/18522106/8b981524-7a63-11e6-8450-0605cc310205.png"/>
|
49
60
|
</td>
|
50
61
|
<td valign='top'>
|
51
|
-
<img src="https://cloud.githubusercontent.com/assets/1400414/
|
62
|
+
<img src="https://cloud.githubusercontent.com/assets/1400414/18522107/8d0bfa24-7a63-11e6-8c0a-12757528b9ee.png"/>
|
52
63
|
</td>
|
53
64
|
</tr>
|
54
65
|
</tbody>
|
@@ -56,29 +67,14 @@ A classic devise sign up view will look like this:
|
|
56
67
|
|
57
68
|
### Flash messages
|
58
69
|
|
59
|
-

|
64
71
|
|
65
|
-
|
66
|
-
gem 'foundation-rails'
|
67
|
-
gem 'foundation_rails_helper', '~> 1.2.0'
|
68
|
-
```
|
69
|
-
|
70
|
-
And then execute:
|
71
|
-
|
72
|
-
```bash
|
73
|
-
$ bundle
|
74
|
-
```
|
72
|
+
## Usage
|
75
73
|
|
76
74
|
### Flash Messages
|
77
75
|
|
78
76
|
To use the built in flash helper, add `<%= display_flash_messages %>` to your layout file (eg. *app/views/layouts/application.html.erb*).
|
79
77
|
|
80
|
-
## Usage
|
81
|
-
|
82
78
|
### form_for
|
83
79
|
|
84
80
|
Form_for wraps the standard rails form_for helper.
|
@@ -112,11 +108,11 @@ generates:
|
|
112
108
|
<input id="user_name" name="user[name]" type="text">
|
113
109
|
```
|
114
110
|
|
115
|
-
Preventing the generation of labels can be accomplished
|
111
|
+
Preventing the generation of labels can be accomplished three ways. To disable on a form element:
|
116
112
|
```ruby
|
117
113
|
f.text_field :name, label: false
|
118
114
|
```
|
119
|
-
For all form elements, add the option: `auto_labels: false` to the form helper.
|
115
|
+
For all form elements, add the option: `auto_labels: false` to the form helper. To disable for all forms in you project, use the `auto_labels` config option, see the Configuration section for more information.
|
120
116
|
|
121
117
|
Change the label text and add a class on the label:
|
122
118
|
|
@@ -124,21 +120,21 @@ Change the label text and add a class on the label:
|
|
124
120
|
f.text_field :name, label: 'Nombre', label_options: { class: 'large' }
|
125
121
|
```
|
126
122
|
|
127
|
-
If the
|
123
|
+
If the help_text option is specified
|
128
124
|
|
129
125
|
```ruby
|
130
|
-
f.text_field :name,
|
126
|
+
f.text_field :name, help_text: "I'm a text field"
|
131
127
|
```
|
132
128
|
|
133
|
-
an additional
|
129
|
+
an additional p element will be added after the input element:
|
134
130
|
|
135
131
|
```html
|
136
|
-
<
|
132
|
+
<p class="help-text">I'm a text field</p>
|
137
133
|
```
|
138
134
|
|
139
135
|
### Submit Button
|
140
136
|
|
141
|
-
The 'submit' helper wraps the rails helper and sets the class attribute to "
|
137
|
+
The 'submit' helper wraps the rails helper and sets the class attribute to "success button" by default.
|
142
138
|
|
143
139
|
```ruby
|
144
140
|
f.submit
|
@@ -147,7 +143,7 @@ f.submit
|
|
147
143
|
generates:
|
148
144
|
|
149
145
|
```html
|
150
|
-
<input class="
|
146
|
+
<input class="success button" name="commit" type="submit" value="Create User">
|
151
147
|
```
|
152
148
|
|
153
149
|
Specify the class option to override the default classes.
|
@@ -163,9 +159,9 @@ f.email_field :email
|
|
163
159
|
generates:
|
164
160
|
|
165
161
|
```html
|
166
|
-
<label class="
|
167
|
-
<input class="
|
168
|
-
<small class="error">can't be blank</small>
|
162
|
+
<label class="is-invalid-label" for="user_email">Email</label>
|
163
|
+
<input class="is-invalid-input" id="user_email" name="user[email]" type="email" value="">
|
164
|
+
<small class="form-error is-visible">can't be blank</small>
|
169
165
|
```
|
170
166
|
|
171
167
|
The class attribute of the 'small' element will mirror the class attribute of the 'input' element.
|
@@ -200,13 +196,11 @@ FoundationRailsHelper.configure do |config|
|
|
200
196
|
end
|
201
197
|
```
|
202
198
|
|
203
|
-
Currently supported options:
|
204
|
-
|
205
199
|
### Submit Button Class
|
206
200
|
To use a different class for the [submit button](https://github.com/sgruhier/foundation_rails_helper#submit-button) used in `form_for`, add a config named **button_class**:
|
207
201
|
```ruby
|
208
|
-
# Default: '
|
209
|
-
config.button_class = 'large secondary button'
|
202
|
+
# Default: 'success button'
|
203
|
+
config.button_class = 'large hollow secondary button'
|
210
204
|
```
|
211
205
|
|
212
206
|
Please note, the button class can still be overridden by an options hash.
|
@@ -221,12 +215,17 @@ you can specify a blacklist of keys to ignore with the **ignored_flash_keys** co
|
|
221
215
|
config.ignored_flash_keys = [:timedout]
|
222
216
|
```
|
223
217
|
|
218
|
+
### Auto Labels
|
219
|
+
If you prefer to not have the form builder automatically generate labels, set `auto_labels` to false.
|
220
|
+
```ruby
|
221
|
+
# Default: true
|
222
|
+
config.auto_labels = false
|
223
|
+
```
|
224
|
+
|
224
225
|
## Contributing
|
225
226
|
|
226
227
|
See the [CONTRIBUTING](CONTRIBUTING.md) file.
|
227
228
|
|
228
229
|
## Copyright
|
229
230
|
|
230
|
-
Sébastien Gruhier (http://xilinus.com
|
231
|
-
|
232
|
-
[](https://bitdeli.com/free "Bitdeli Badge")
|
231
|
+
Sébastien Gruhier (http://xilinus.com) - MIT LICENSE
|
data/Rakefile
CHANGED
@@ -1,39 +1,38 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require File.expand_path('../lib/foundation_rails_helper/version', __FILE__)
|
3
3
|
|
4
|
-
Gem::Specification
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
12
|
-
gem.files = `git ls-files`.split("\n")
|
13
|
-
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
-
gem.name = 'foundation_rails_helper'
|
15
|
-
gem.require_paths = ['lib']
|
16
|
-
gem.version = FoundationRailsHelper::VERSION
|
17
|
-
gem.license = 'MIT'
|
4
|
+
class Gem::Specification # rubocop:disable ClassAndModuleChildren
|
5
|
+
def self.rails_gem_version
|
6
|
+
# Allow different versions of the rails gems to be specified, for testing
|
7
|
+
@rails_gem_version ||=
|
8
|
+
ENV['RAILS_VERSION'] ? "~> #{ENV['RAILS_VERSION']}" : ['>= 4.1', '< 7.0']
|
9
|
+
end
|
10
|
+
end
|
18
11
|
|
19
|
-
|
20
|
-
|
12
|
+
Gem::Specification.new do |gem|
|
13
|
+
gem.authors = ['Sebastien Gruhier']
|
14
|
+
gem.email = ['sebastien.gruhier@xilinus.com']
|
15
|
+
gem.description =
|
16
|
+
'Rails for zurb foundation CSS framework. Form builder, flash message, ...'
|
17
|
+
gem.summary = 'Rails helpers for zurb foundation CSS framework'
|
18
|
+
gem.homepage = 'http://github.com/sgruhier/foundation_rails_helper'
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
gem.executables =
|
21
|
+
`git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
22
|
+
gem.files = `git ls-files`.split("\n")
|
23
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
gem.name = 'foundation_rails_helper'
|
25
|
+
gem.require_paths = %w(lib)
|
26
|
+
gem.version = FoundationRailsHelper::VERSION
|
27
|
+
gem.license = 'MIT'
|
28
28
|
|
29
|
-
gem.add_dependency 'railties',
|
30
|
-
gem.add_dependency 'actionpack',
|
31
|
-
gem.add_dependency 'activemodel',
|
32
|
-
gem.add_dependency 'activesupport',
|
33
|
-
gem.add_dependency 'tzinfo', '~> 1.2', '>= 1.2.2'
|
29
|
+
gem.add_dependency 'railties', Gem::Specification.rails_gem_version
|
30
|
+
gem.add_dependency 'actionpack', Gem::Specification.rails_gem_version
|
31
|
+
gem.add_dependency 'activemodel', Gem::Specification.rails_gem_version
|
32
|
+
gem.add_dependency 'activesupport', Gem::Specification.rails_gem_version
|
34
33
|
|
35
|
-
gem.add_development_dependency 'rspec-rails', '
|
36
|
-
gem.add_development_dependency 'mime-types',
|
37
|
-
gem.add_development_dependency 'capybara',
|
38
|
-
gem.add_development_dependency 'rubocop',
|
34
|
+
gem.add_development_dependency 'rspec-rails', '~> 3.1'
|
35
|
+
gem.add_development_dependency 'mime-types', '~> 2'
|
36
|
+
gem.add_development_dependency 'capybara', '~> 2.7'
|
37
|
+
gem.add_development_dependency 'rubocop', '~> 0.44.1'
|
39
38
|
end
|