bootstrap_form 4.2.0 → 4.3.0

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
  SHA256:
3
- metadata.gz: 3eb9dd9edad01a3b8fc83d83506c4a9a19d70f849620dde77847baaaa0231b9a
4
- data.tar.gz: 942e9b16f5ffe3873e49defc113255c61939e479621c25ed5846348b2bdfe304
3
+ metadata.gz: 60d4313478eda1a0db587b6c45b7e107aedca0d59683f2231d348c09e9585e59
4
+ data.tar.gz: f07b72a464b509975d9a6a573718787b9c245b7b3b1f362e3448d842fff93891
5
5
  SHA512:
6
- metadata.gz: e61107ff84b13b61270438556d0320c94a1f395b5acdb9221122ba89078c7dca3c0d96b3f2db8bc5e3c7e0cdca4eb124f0bb5944fd47be31a9a217ad6a714716
7
- data.tar.gz: 55b15e5a89aa152ad0c2ca05e1bfb6fc99c15f0e1b5235ad6a0d41df0429097e775d3c006ed59e0773e9b397d2c7332fb57334bc577a47331eebff0c7dff75b8
6
+ metadata.gz: 370f4f419457d0737505add14f48f6ebb879e185f9b132d7409d59b789944dff9a156eabb3c821764f1de8783879729639f99334812077f2c99cccf44da7378c
7
+ data.tar.gz: a5ac9f28944a788c996a7da4d57760cb6331bf2d3a490a8a3a96ddaffec2f7357fce07e2e16fcabbe59eb7f12967fc8950f19f4644369981b30eaaa63fd588a4
@@ -0,0 +1,13 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
@@ -1,9 +1,11 @@
1
1
  # Taken from: https://github.com/mattbrictson/rails-template/blob/master/rubocop.yml.tt
2
2
  # Modified for demo app in `demo/` directory.
3
+ require: rubocop-rails
4
+
3
5
  AllCops:
4
6
  DisplayCopNames: true
5
7
  DisplayStyleGuide: true
6
- TargetRubyVersion: 2.2.2
8
+ TargetRubyVersion: 2.3
7
9
  Exclude:
8
10
  - "bin/*"
9
11
  - Capfile
@@ -59,9 +61,6 @@ Naming/MemoizedInstanceVariableName:
59
61
  Naming/VariableNumber:
60
62
  Enabled: false
61
63
 
62
- Performance/Casecmp:
63
- Enabled: false
64
-
65
64
  Rails:
66
65
  Enabled: true
67
66
 
@@ -1,13 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.9
4
- - 2.3.6
5
- - 2.4.3
6
- - 2.5.0
3
+ - 2.4.6
4
+ - 2.5.6
5
+ - 2.6.4
7
6
  gemfile:
8
7
  - test/gemfiles/5.0.gemfile
9
8
  - test/gemfiles/5.1.gemfile
10
9
  - test/gemfiles/5.2.gemfile
10
+ - test/gemfiles/6.0.gemfile
11
11
  before_install:
12
12
  - gem i rubygems-update -v '<3' && update_rubygems
13
13
  - gem install bundler -v 1.17.3 --no-document
@@ -15,18 +15,22 @@ script:
15
15
  - bundle exec rake test
16
16
 
17
17
  matrix:
18
+ exclude:
19
+ - rvm: 2.4.6
20
+ gemfile: test/gemfiles/6.0.gemfile
21
+
18
22
  include:
19
23
  # Bleeding edge Ruby
20
24
  - rvm: ruby-head
21
- gemfile: test/gemfiles/5.2.gemfile
25
+ gemfile: test/gemfiles/6.0.gemfile
22
26
 
23
27
  # Next version of Rails
24
28
  - rvm: 2.5.0
25
- gemfile: test/gemfiles/6.0.gemfile
29
+ gemfile: test/gemfiles/edge.gemfile
26
30
 
27
31
  # Running one job to execute DANGER bot and linting
28
32
  - rvm: 2.5.0
29
- gemfile: test/gemfiles/5.2.gemfile
33
+ gemfile: test/gemfiles/6.0.gemfile
30
34
  script:
31
35
  - gem install danger
32
36
  - danger
@@ -35,4 +39,4 @@ matrix:
35
39
  allow_failures:
36
40
  - rvm: ruby-head
37
41
  - rvm: 2.5.0
38
- gemfile: test/gemfiles/6.0.gemfile
42
+ gemfile: test/gemfiles/edge.gemfile
@@ -12,6 +12,13 @@
12
12
 
13
13
  * Your contribution here!
14
14
 
15
+ ## [4.3.0][] (2019-03-08)
16
+
17
+ ### New features
18
+
19
+ * [#503] Support Rails 6.0.0.
20
+ * Small documentation changes.
21
+
15
22
  ## [4.2.0][] (2019-03-08)
16
23
 
17
24
  ### New features
@@ -63,7 +63,7 @@ merged into the master branch. Eventually the gem will be published with your ch
63
63
  ### Coding guidelines
64
64
 
65
65
  This project uses [RuboCop](https://github.com/bbatsov/rubocop) to enforce standard Ruby coding
66
- guidelines. Currently we run RuboCop's as described by [this post](https://tech.offgrid-electric.com/rubocop-getting-to-green-in-a-huge-rails-app-12d1ad6678eb), under the section "How to make CI pass". That means we allow certain existing RuboCop offences in the code, but prevent people from adding any new offences. So you might copy some existing code, and then discover that it doesn't pass. Please fix the new code, and if you're ambitious, fix the old code as well.
66
+ guidelines.
67
67
 
68
68
  * Test that your contribution passes with `rake rubocop`.
69
69
  * RuboCop is also run as part of the full test suite with `bundle exec rake`.
@@ -71,6 +71,12 @@ guidelines. Currently we run RuboCop's as described by [this post](https://tech.
71
71
 
72
72
  Note that most editors have plugins to run RuboCop as you type, or when you save a file. You may find it well worth your time to install and configure the RuboCop plugin for your editor. Read the [RuboCop documentation](https://rubocop.readthedocs.io/en/latest/integration_with_other_tools/).
73
73
 
74
+ ### Supported Versions of Ruby and Rails
75
+
76
+ The goal of `bootstrap_form` is to support all versions of Rails currently supported for bug fixes and security issues. We do not test against versions supported for severe security issues. We test against the minimum [version of Ruby required](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#ruby-versions) for those versions of Rails.
77
+
78
+ The Ruby on Rails support policy is [here](https://guides.rubyonrails.org/maintenance_policy.html).
79
+
74
80
  ## Documentation Contributions
75
81
 
76
82
  Contributions to documentation are always welcome. Even fixing one typo improves the quality of `bootstrap_form`. To make a documentation contribution, follow steps 1-3 of Code Contributions, then make the documentation changes, then make the pull request (step 6 of Code Contributions).
data/Gemfile CHANGED
@@ -3,15 +3,15 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  # Uncomment and change rails version for testing purposes
6
- gem "rails", "~> 5.2.0"
7
- # gem "rails", "~> 6.0.0.beta1"
6
+ # gem "rails", "~> 5.2.0"
7
+ gem "rails", "~> 6.0.0"
8
8
 
9
9
  group :development do
10
10
  gem "chandler", ">= 0.7.0"
11
11
  gem "htmlbeautifier"
12
- gem "rubocop", require: false
13
- gem "sass-rails"
14
- gem 'webpacker', '>= 4.0.0.rc.3'
12
+ gem "rubocop-rails", require: false
13
+ gem "sassc-rails"
14
+ gem "webpacker", ">= 4.0.0.rc.3"
15
15
  end
16
16
 
17
17
  group :test do
@@ -21,8 +21,6 @@ group :test do
21
21
  gem "diffy"
22
22
  gem "equivalent-xml"
23
23
  gem "mocha"
24
- # sqlite3 1.4.0 breaks the test suite.
25
- # https://github.com/rails/rails/pull/35154
26
- gem "sqlite3", "~> 1.3.6"
24
+ gem "sqlite3"
27
25
  gem "timecop", "~> 0.7.1"
28
26
  end
@@ -415,8 +415,19 @@ Here's the output for a horizontal layout:
415
415
  You can also create a static control that isn't based on a model attribute:
416
416
 
417
417
  ```erb
418
- <%= f.static_control label: "Custom Static Control" value: "Content Here" %>
418
+ <%= f.static_control :field_name, label: "Custom Static Control" value: "Content Here" %>
419
419
  ```
420
+
421
+ `field_name` may be any name that isn't already used in the form. Note that you may get "unpermitted parameter" messages in your log file with this approach.
422
+
423
+ You can also create the static control the following way, if you don't need to get the value of the static control as a parameter when the form is submitted:
424
+
425
+ ```erb
426
+ <%= f.static_control label: "Custom Static Control" value: "Content Here", name: nil %>
427
+ ```
428
+
429
+ (If you neither provide a field name nor `name: nil`, the Rails code that submits the form will give a JavaScript error.)
430
+
420
431
  Prior to version 4 of `bootstrap_form`, you could pass a block to the `static_control` method.
421
432
  The value of the block would be used for the content of the static "control".
422
433
  Bootstrap 4 actually creates and styles a disabled input field for static controls, so the value of the control has to be specified by the `value:` option.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ⚠️ **This documentation is for the master branch, which is not yet stable and targets Bootstrap v4.** If you are using Bootstrap v3, refer to the stable [legacy-2.7](https://github.com/bootstrap-ruby/bootstrap_form/tree/legacy-2.7) branch.
1
+ If you are using Bootstrap v3, refer to the legacy [legacy-2.7](https://github.com/bootstrap-ruby/bootstrap_form/tree/legacy-2.7) branch.
2
2
 
3
3
  This is a new take on the `bootstrap_form` README. Please leave comments at: #520. You can go back to the traditional [README](/OLD-README.md).
4
4
 
@@ -28,18 +28,19 @@ Some other nice things that `bootstrap_form` does for you are:
28
28
  `bootstrap_form` works like the standard Rails form helpers, and this README assumes you know how they work. You start a form with one of [`bootstrap_form_with`](#bootstrap-form-with), [`bootstrap_form_for`](#bootstrap-form-for), or [`bootstrap_form_tag`](#bootstrap-form-tag) in a view file. You get a form builder that calls the [`bootstrap_form` helpers](#form-helpers) instead of the standard Rails helpers. You use that form builder in the view file to render one or more form fields.
29
29
 
30
30
  ## Requirements
31
- `bootstrap_form` supports currently supported versions of Rails:
32
31
 
33
- * Ruby 2.2.2+
32
+ `bootstrap_form` supports at a minimum the currently supported versions of Ruby and Rails:
33
+
34
+ * Ruby 2.4+
34
35
  * Rails 5.0+ (Rails 5.1+ for `bootstrap_form_with`)
35
- * Bootstrap 4.0.0+
36
+ * Bootstrap 4.0+
36
37
 
37
38
  ## Installation
38
39
 
39
40
  Add it to your Gemfile:
40
41
 
41
42
  ```ruby
42
- gem "bootstrap_form", ">= 4.2.0"
43
+ gem "bootstrap_form", "~> 4.0"
43
44
  ```
44
45
 
45
46
  Then:
@@ -386,7 +387,7 @@ To render checkboxes as switches with Bootstrap 4.2+, use `custom: :switch`:
386
387
  <%= f.collection_check_boxes :skills, Skill.all, :id, :name %>
387
388
  ```
388
389
 
389
- NOTE: These helpers do not currently support a block, unlike their equivalent Rails helpers. See issue #477.
390
+ NOTE: These helpers do not currently support a block, unlike their equivalent Rails helpers. See issue [#477](https://github.com/bootstrap-ruby/bootstrap_form/issues/477). If you need to use the block syntax, use `collection_check_boxes_without_bootstrap` or `collection_radio_buttons_without_bootstrap` for now.
390
391
 
391
392
  Collection methods accept these options:
392
393
  * `:label`: Customize the `form_group`'s label
@@ -416,8 +417,19 @@ Here's the output for a horizontal layout:
416
417
  You can also create a static control that isn't based on a model attribute:
417
418
 
418
419
  ```erb
419
- <%= f.static_control label: "Custom Static Control" value: "Content Here" %>
420
+ <%= f.static_control :field_name, label: "Custom Static Control", value: "Content Here" %>
420
421
  ```
422
+
423
+ `field_name` may be any name that isn't already used in the form. Note that you may get "unpermitted parameter" messages in your log file with this approach.
424
+
425
+ You can also create the static control the following way, if you don't need to get the value of the static control as a parameter when the form is submitted:
426
+
427
+ ```erb
428
+ <%= f.static_control label: "Custom Static Control", value: "Content Here", name: nil %>
429
+ ```
430
+
431
+ (If you neither provide a field name nor `name: nil`, the Rails code that submits the form will give a JavaScript error.)
432
+
421
433
  Prior to version 4 of `bootstrap_form`, you could pass a block to the `static_control` method.
422
434
  The value of the block would be used for the content of the static "control".
423
435
  Bootstrap 4 actually creates and styles a disabled input field for static controls, so the value of the control has to be specified by the `value:` option.
@@ -497,13 +509,17 @@ will be rendered as
497
509
  (some unimportant HTML attributes have been removed for simplicity)
498
510
 
499
511
  ## Rich Text Areas AKA Trix Editor
512
+
500
513
  If you're using Rails 6, `bootstrap_form` supports the `rich_text_area` helper.
501
514
 
502
- ```
515
+
516
+ ```erb
503
517
  <%= f.rich_text_area(:life_story) %>
504
518
  ```
519
+
505
520
  will be rendered as:
506
- ```
521
+
522
+ ```html
507
523
  <div class="form-group">
508
524
  <label for="user_life_story">Life story</label>
509
525
  <input type="hidden" name="user[life_story]" id="user_life_story_trix_input_user"/>
@@ -513,9 +529,11 @@ will be rendered as:
513
529
  ```
514
530
 
515
531
  ## File Fields
532
+
516
533
  The `file_field` helper generates mark-up for a Bootstrap 4 custom file field entry. It takes the [options for `text_field`](#form-helper-options), minus `append` and `prepend`.
517
534
 
518
535
  ## Hidden Fields
536
+
519
537
  The `hidden_field` helper in `bootstrap_form` calls the Rails helper directly, and does no additional mark-up.
520
538
 
521
539
  ## Accessing Rails Form Helpers
@@ -589,7 +607,7 @@ The `label_col` and `control_col` css classes can also be changed per control:
589
607
 
590
608
  or default value can be changed in initializer:
591
609
 
592
- ```erb
610
+ ```ruby
593
611
  # config/initializers/bootstrap_form.rb
594
612
  module BootstrapForm
595
613
  class FormBuilder
@@ -646,6 +664,7 @@ The `custom` option can be used to replace the browser default styles for check
646
664
  ```
647
665
 
648
666
  ## Validation and Errors
667
+
649
668
  Rails normally wraps fields with validation errors in a `div.field_with_errors`, but this behaviour isn't consistent with Bootstrap 4 styling. By default, `bootstrap_form` generations in-line errors which appear below the field. But it can also generate errors on the label, or not display any errors, leaving it up to you.
650
669
 
651
670
  ### Inline Errors
@@ -674,7 +693,7 @@ You can turn off inline errors for the entire form like this:
674
693
  You can also display validation errors in the field's label; just turn
675
694
  on the `:label_errors` option. Here's an example:
676
695
 
677
- ```
696
+ ```erb
678
697
  <%= bootstrap_form_for(@user, label_errors: true) do |f| %>
679
698
  ...
680
699
  <% end %>
@@ -683,7 +702,7 @@ on the `:label_errors` option. Here's an example:
683
702
  By default, turning on `:label_errors` will also turn off
684
703
  `:inline_errors`. If you want both turned on, you can do that too:
685
704
 
686
- ```
705
+ ```erb
687
706
  <%= bootstrap_form_for(@user, label_errors: true, inline_errors: true) do |f| %>
688
707
  ...
689
708
  <% end %>
@@ -792,24 +811,25 @@ here: http://guides.rubyonrails.org/i18n.html#translations-for-active-record-mod
792
811
  The Rails team has [suggested](https://github.com/rails/rails/issues/25197) that `form_for` and `form_tag` may be deprecated and then removed in future versions of Rails. `bootstrap_form` will continue to support `bootstrap_form_for` and `bootstrap_form_tag` as long as Rails supports `form_for` and `form_tag`.
793
812
 
794
813
  ## Other Tips and Edge Cases
814
+
795
815
  By their very nature, forms are extremely diverse. It would be extremely difficult to provide a gem that could handle every need. Here are some tips for handling edge cases.
796
816
 
797
817
  ### Empty But Visible Labels
818
+
798
819
  Some third party plug-ins require an empty but visible label on an input control. The `hide_label` option generates a label that won't appear on the screen, but it's considered invisible and therefore doesn't work with such a plug-in. An empty label (e.g. `""`) causes the underlying Rails helper to generate a label based on the field's attribute's name.
799
820
 
800
821
  The solution is to use a zero-width character for the label, or some other "empty" HTML. For example:
801
- ```
822
+
823
+ ```ruby
802
824
  label: "&#8203;".html_safe
803
825
  ```
826
+
804
827
  or
805
- ```
828
+
829
+ ```ruby
806
830
  label: "<span></span>".html_safe
807
831
  ```
808
832
 
809
- ## Code Triage page
810
-
811
- http://www.codetriage.com/potenza/bootstrap_form
812
-
813
833
  ## Contributing
814
834
 
815
835
  We welcome contributions.
@@ -6,13 +6,13 @@ Follow these steps to release a new version of bootstrap_form to rubygems.org.
6
6
 
7
7
  * You must have commit rights to the bootstrap_form repository.
8
8
  * You must have push rights for the bootstrap_form gem on rubygems.org.
9
- * You must be using Ruby >= 2.2.
9
+ * You must be using Ruby >= 2.4.
10
10
  * Your GitHub credentials must be available to Chandler via `~/.netrc` or an environment variable, [as explained here](https://github.com/mattbrictson/chandler#2-configure-credentials).
11
11
 
12
12
  ## How to release
13
13
 
14
14
  1. Run `bundle install` to make sure that you have all the gems necessary for testing and releasing.
15
- 2. **Ensure the tests are passing by running `bundle exec rake`.**
15
+ 2. **Ensure the tests are passing by running `bundle exec rake`.**
16
16
  3. Determine which would be the correct next version number according to [semver](http://semver.org/).
17
17
  4. Update the version in `./lib/bootstrap_form/version.rb`.
18
18
  5. Update the `CHANGELOG.md` (for an illustration of these steps, refer to the [4.0.0.alpha1 commit](https://github.com/bootstrap-ruby/bootstrap_form/commit/8aac3667931a16537ab68038ec4cebce186bd596#diff-4ac32a78649ca5bdd8e0ba38b7006a1e) as an example):
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.bindir = "exe"
23
23
  s.require_paths = ["lib"]
24
24
 
25
- s.required_ruby_version = ">= 2.2.2"
25
+ s.required_ruby_version = ">= 2.3"
26
26
 
27
27
  s.add_dependency("actionpack", ">= 5.0")
28
28
  s.add_dependency("activemodel", ">= 5.0")
@@ -5,7 +5,7 @@ module BootstrapHelper
5
5
  content_tag(:div, class: "example") do
6
6
  concat(form_html)
7
7
  concat(toggle)
8
- concat(codemirror)
8
+ concat(codemirror(form_html))
9
9
  end
10
10
  end
11
11
 
@@ -40,7 +40,7 @@
40
40
  <% end %>
41
41
  <% end %>
42
42
 
43
- <h3>Simple</h3>
43
+ <h3>Simple Action Text Example</h3>
44
44
 
45
45
  <%= form_with_source do %>
46
46
  <%= bootstrap_form_for @user, url: "/" do |form| %>
@@ -39,7 +39,7 @@ module BootstrapForm
39
39
 
40
40
  def check_box_description(name, options, &block)
41
41
  content = block_given? ? capture(&block) : options[:label]
42
- content || (object && object.class.human_attribute_name(name)) || name.to_s.humanize
42
+ content || object&.class&.human_attribute_name(name) || name.to_s.humanize
43
43
  end
44
44
 
45
45
  def check_box_value(name, value)
@@ -61,14 +61,14 @@ module BootstrapForm
61
61
  end
62
62
 
63
63
  def standard_radio_button_wrapper_class(options)
64
- classes = ["form-check"]
64
+ classes = %w[form-check]
65
65
  classes << "form-check-inline" if layout_inline?(options[:inline])
66
66
  classes << "disabled" if options[:disabled]
67
67
  classes
68
68
  end
69
69
 
70
70
  def custom_radio_button_wrapper_class(options)
71
- classes = ["custom-control", "custom-radio"]
71
+ classes = %w[custom-control custom-radio]
72
72
  classes << "custom-control-inline" if layout_inline?(options[:inline])
73
73
  classes
74
74
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapForm
2
- VERSION = "4.2.0".freeze
2
+ VERSION = "4.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Potenza
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-03-08 00:00:00.000000000 Z
12
+ date: 2019-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -48,6 +48,7 @@ executables: []
48
48
  extensions: []
49
49
  extra_rdoc_files: []
50
50
  files:
51
+ - ".editorconfig"
51
52
  - ".gitignore"
52
53
  - ".rubocop.yml"
53
54
  - ".travis.yml"
@@ -183,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
184
  requirements:
184
185
  - - ">="
185
186
  - !ruby/object:Gem::Version
186
- version: 2.2.2
187
+ version: '2.3'
187
188
  required_rubygems_version: !ruby/object:Gem::Requirement
188
189
  requirements:
189
190
  - - ">="