bootstrap_form 4.0.0 → 4.1.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.
@@ -1,8 +1,7 @@
1
1
  module BootstrapForm
2
2
  module Helper
3
-
4
- def bootstrap_form_for(object, options = {}, &block)
5
- options.reverse_merge!({builder: BootstrapForm::FormBuilder})
3
+ def bootstrap_form_for(object, options={}, &block)
4
+ options.reverse_merge!(builder: BootstrapForm::FormBuilder)
6
5
 
7
6
  options = process_options(options)
8
7
 
@@ -11,13 +10,13 @@ module BootstrapForm
11
10
  end
12
11
  end
13
12
 
14
- def bootstrap_form_tag(options = {}, &block)
13
+ def bootstrap_form_tag(options={}, &block)
15
14
  options[:acts_like_form_tag] = true
16
15
 
17
16
  bootstrap_form_for("", options, &block)
18
17
  end
19
18
 
20
- def bootstrap_form_with(options = {}, &block)
19
+ def bootstrap_form_with(options={}, &block)
21
20
  options.reverse_merge!(builder: BootstrapForm::FormBuilder)
22
21
 
23
22
  options = process_options(options)
@@ -31,10 +30,10 @@ module BootstrapForm
31
30
 
32
31
  def process_options(options)
33
32
  options[:html] ||= {}
34
- options[:html][:role] ||= 'form'
33
+ options[:html][:role] ||= "form"
35
34
 
36
35
  if options[:layout] == :inline
37
- options[:html][:class] = [options[:html][:class], 'form-inline'].compact.join(' ')
36
+ options[:html][:class] = [options[:html][:class], "form-inline"].compact.join(" ")
38
37
  end
39
38
 
40
39
  options
@@ -44,7 +43,7 @@ module BootstrapForm
44
43
 
45
44
  def temporarily_disable_field_error_proc
46
45
  original_proc = ActionView::Base.field_error_proc
47
- ActionView::Base.field_error_proc = proc { |input, instance| input }
46
+ ActionView::Base.field_error_proc = proc { |input, _instance| input }
48
47
  yield
49
48
  ensure
50
49
  ActionView::Base.field_error_proc = original_proc
@@ -1,19 +1,18 @@
1
1
  module BootstrapForm
2
2
  module Helpers
3
3
  module Bootstrap
4
-
5
- def button(value = nil, options = {}, &block)
6
- setup_css_class 'btn btn-secondary', options
4
+ def button(value=nil, options={}, &block)
5
+ setup_css_class "btn btn-secondary", options
7
6
  super
8
7
  end
9
8
 
10
- def submit(name = nil, options = {})
11
- setup_css_class 'btn btn-secondary', options
9
+ def submit(name=nil, options={})
10
+ setup_css_class "btn btn-secondary", options
12
11
  super
13
12
  end
14
13
 
15
- def primary(name = nil, options = {}, &block)
16
- setup_css_class 'btn btn-primary', options
14
+ def primary(name=nil, options={}, &block)
15
+ setup_css_class "btn btn-primary", options
17
16
 
18
17
  if options[:render_as_button] || block_given?
19
18
  options.except! :render_as_button
@@ -23,8 +22,8 @@ module BootstrapForm
23
22
  end
24
23
  end
25
24
 
26
- def alert_message(title, options = {})
27
- css = options[:class] || 'alert alert-danger'
25
+ def alert_message(title, options={})
26
+ css = options[:class] || "alert alert-danger"
28
27
 
29
28
  if object.respond_to?(:errors) && object.errors.full_messages.any?
30
29
  content_tag :div, class: css do
@@ -36,7 +35,7 @@ module BootstrapForm
36
35
 
37
36
  def error_summary
38
37
  if object.errors.any?
39
- content_tag :ul, class: 'rails-bootstrap-forms-error-summary' do
38
+ content_tag :ul, class: "rails-bootstrap-forms-error-summary" do
40
39
  object.errors.full_messages.each do |error|
41
40
  concat content_tag(:li, error)
42
41
  end
@@ -44,7 +43,7 @@ module BootstrapForm
44
43
  end
45
44
  end
46
45
 
47
- def errors_on(name, options = {})
46
+ def errors_on(name, options={})
48
47
  if has_error?(name)
49
48
  hide_attribute_name = options[:hide_attribute_name] || false
50
49
 
@@ -62,12 +61,12 @@ module BootstrapForm
62
61
  options = args.extract_options!
63
62
  name = args.first
64
63
 
65
- static_options = options.merge({
64
+ static_options = options.merge(
66
65
  readonly: true,
67
66
  control_class: [options[:control_class], static_class].compact.join(" ")
68
- })
67
+ )
69
68
 
70
- static_options[:value] = object.send(name) unless static_options.has_key?(:value)
69
+ static_options[:value] = object.send(name) unless static_options.key?(:value)
71
70
 
72
71
  text_field_with_bootstrap(name, static_options)
73
72
  end
@@ -81,12 +80,12 @@ module BootstrapForm
81
80
 
82
81
  def prepend_and_append_input(name, options, &block)
83
82
  options = options.extract!(:prepend, :append, :input_group_class)
84
- input_group_class = ["input-group", options[:input_group_class]].compact.join(' ')
83
+ input_group_class = ["input-group", options[:input_group_class]].compact.join(" ")
85
84
 
86
85
  input = capture(&block) || "".html_safe
87
86
 
88
- input = content_tag(:div, input_group_content(options[:prepend]), class: 'input-group-prepend') + input if options[:prepend]
89
- input << content_tag(:div, input_group_content(options[:append]), class: 'input-group-append') if options[:append]
87
+ input = content_tag(:div, input_group_content(options[:prepend]), class: "input-group-prepend") + input if options[:prepend]
88
+ input << content_tag(:div, input_group_content(options[:append]), class: "input-group-append") if options[:append]
90
89
  input << generate_error(name)
91
90
  input = content_tag(:div, input, class: input_group_class) unless options.empty?
92
91
  input
@@ -98,26 +97,25 @@ module BootstrapForm
98
97
  end
99
98
 
100
99
  def input_group_content(content)
101
- return content if content.match(/btn/)
102
- content_tag(:span, content, class: 'input-group-text')
100
+ return content if content =~ /btn/
101
+
102
+ content_tag(:span, content, class: "input-group-text")
103
103
  end
104
104
 
105
105
  def static_class
106
106
  "form-control-plaintext"
107
107
  end
108
108
 
109
-
110
109
  private
111
110
 
112
- def setup_css_class(the_class, options = {})
113
- unless options.has_key? :class
114
- if extra_class = options.delete(:extra_class)
115
- the_class = "#{the_class} #{extra_class}"
116
- end
117
- options[:class] = the_class
111
+ def setup_css_class(the_class, options={})
112
+ unless options.key? :class
113
+ if (extra_class = options.delete(:extra_class))
114
+ the_class = "#{the_class} #{extra_class}"
118
115
  end
116
+ options[:class] = the_class
119
117
  end
120
-
118
+ end
121
119
  end
122
120
  end
123
121
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapForm
2
- VERSION = "4.0.0".freeze
2
+ VERSION = "4.1.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.0.0
4
+ version: 4.1.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: 2018-10-27 00:00:00.000000000 Z
12
+ date: 2019-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -35,8 +35,11 @@ extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
37
  - ".gitignore"
38
+ - ".rubocop.yml"
39
+ - ".rubocop_todo.yml"
38
40
  - ".travis.yml"
39
41
  - CHANGELOG.md
42
+ - CODE_OF_CONDUCT.md
40
43
  - CONTRIBUTING.md
41
44
  - Dangerfile
42
45
  - Gemfile