actionview 5.0.7.2 → 5.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +92 -384
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/action_view.rb +5 -5
  6. data/lib/action_view/base.rb +19 -19
  7. data/lib/action_view/buffers.rb +1 -1
  8. data/lib/action_view/context.rb +1 -1
  9. data/lib/action_view/dependency_tracker.rb +4 -5
  10. data/lib/action_view/digestor.rb +6 -7
  11. data/lib/action_view/flows.rb +5 -6
  12. data/lib/action_view/gem_version.rb +3 -3
  13. data/lib/action_view/helpers.rb +1 -1
  14. data/lib/action_view/helpers/active_model_helper.rb +8 -8
  15. data/lib/action_view/helpers/asset_tag_helper.rb +62 -36
  16. data/lib/action_view/helpers/asset_url_helper.rb +111 -49
  17. data/lib/action_view/helpers/atom_feed_helper.rb +12 -13
  18. data/lib/action_view/helpers/cache_helper.rb +34 -20
  19. data/lib/action_view/helpers/capture_helper.rb +2 -2
  20. data/lib/action_view/helpers/controller_helper.rb +3 -11
  21. data/lib/action_view/helpers/csrf_helper.rb +3 -3
  22. data/lib/action_view/helpers/date_helper.rb +109 -107
  23. data/lib/action_view/helpers/debug_helper.rb +2 -3
  24. data/lib/action_view/helpers/form_helper.rb +406 -31
  25. data/lib/action_view/helpers/form_options_helper.rb +12 -12
  26. data/lib/action_view/helpers/form_tag_helper.rb +19 -18
  27. data/lib/action_view/helpers/javascript_helper.rb +6 -6
  28. data/lib/action_view/helpers/number_helper.rb +48 -46
  29. data/lib/action_view/helpers/output_safety_helper.rb +8 -8
  30. data/lib/action_view/helpers/rendering_helper.rb +2 -2
  31. data/lib/action_view/helpers/sanitize_helper.rb +6 -8
  32. data/lib/action_view/helpers/tag_helper.rb +194 -77
  33. data/lib/action_view/helpers/tags/base.rb +121 -102
  34. data/lib/action_view/helpers/tags/check_box.rb +17 -17
  35. data/lib/action_view/helpers/tags/collection_check_boxes.rb +8 -8
  36. data/lib/action_view/helpers/tags/collection_helpers.rb +60 -60
  37. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +2 -2
  38. data/lib/action_view/helpers/tags/collection_select.rb +2 -2
  39. data/lib/action_view/helpers/tags/date_select.rb +36 -36
  40. data/lib/action_view/helpers/tags/grouped_collection_select.rb +2 -2
  41. data/lib/action_view/helpers/tags/label.rb +4 -0
  42. data/lib/action_view/helpers/tags/password_field.rb +1 -1
  43. data/lib/action_view/helpers/tags/radio_button.rb +4 -4
  44. data/lib/action_view/helpers/tags/select.rb +9 -9
  45. data/lib/action_view/helpers/tags/text_area.rb +1 -1
  46. data/lib/action_view/helpers/tags/text_field.rb +5 -5
  47. data/lib/action_view/helpers/tags/translator.rb +14 -12
  48. data/lib/action_view/helpers/text_helper.rb +20 -19
  49. data/lib/action_view/helpers/translation_helper.rb +6 -6
  50. data/lib/action_view/helpers/url_helper.rb +42 -38
  51. data/lib/action_view/layouts.rb +51 -47
  52. data/lib/action_view/log_subscriber.rb +24 -9
  53. data/lib/action_view/lookup_context.rb +19 -25
  54. data/lib/action_view/path_set.rb +19 -19
  55. data/lib/action_view/railtie.rb +3 -3
  56. data/lib/action_view/record_identifier.rb +6 -6
  57. data/lib/action_view/renderer/abstract_renderer.rb +17 -17
  58. data/lib/action_view/renderer/partial_renderer.rb +188 -187
  59. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +7 -1
  60. data/lib/action_view/renderer/streaming_template_renderer.rb +45 -47
  61. data/lib/action_view/renderer/template_renderer.rb +64 -66
  62. data/lib/action_view/rendering.rb +4 -5
  63. data/lib/action_view/routing_url_for.rb +9 -13
  64. data/lib/action_view/tasks/cache_digests.rake +7 -7
  65. data/lib/action_view/template.rb +26 -27
  66. data/lib/action_view/template/error.rb +5 -15
  67. data/lib/action_view/template/handlers.rb +4 -4
  68. data/lib/action_view/template/handlers/builder.rb +7 -7
  69. data/lib/action_view/template/handlers/erb.rb +9 -76
  70. data/lib/action_view/template/handlers/erb/deprecated_erubis.rb +9 -0
  71. data/lib/action_view/template/handlers/erb/erubi.rb +81 -0
  72. data/lib/action_view/template/handlers/erb/erubis.rb +81 -0
  73. data/lib/action_view/template/html.rb +2 -4
  74. data/lib/action_view/template/resolver.rb +107 -90
  75. data/lib/action_view/template/text.rb +5 -8
  76. data/lib/action_view/template/types.rb +1 -1
  77. data/lib/action_view/test_case.rb +20 -21
  78. data/lib/action_view/testing/resolvers.rb +29 -30
  79. data/lib/action_view/version.rb +1 -1
  80. data/lib/action_view/view_paths.rb +20 -8
  81. data/lib/assets/compiled/rails-ujs.js +648 -0
  82. metadata +19 -14
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/string/output_safety'
1
+ require "active_support/core_ext/string/output_safety"
2
2
 
3
3
  module ActionView
4
4
  # = Action View Capture Helper
@@ -37,7 +37,7 @@ module ActionView
37
37
  def capture(*args)
38
38
  value = nil
39
39
  buffer = with_output_buffer { value = yield(*args) }
40
- if string = buffer.presence || value and string.is_a?(String)
40
+ if (string = buffer.presence || value) && string.is_a?(String)
41
41
  ERB::Util.html_escape string
42
42
  end
43
43
  end
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/module/attr_internal'
1
+ require "active_support/core_ext/module/attr_internal"
2
2
 
3
3
  module ActionView
4
4
  module Helpers
@@ -7,11 +7,8 @@ module ActionView
7
7
  module ControllerHelper #:nodoc:
8
8
  attr_internal :controller, :request
9
9
 
10
- CONTROLLER_DELEGATES = [:request_forgery_protection_token, :params,
11
- :session, :cookies, :response, :headers, :flash, :action_name,
12
- :controller_name, :controller_path]
13
-
14
- delegate *CONTROLLER_DELEGATES, to: :controller
10
+ delegate :request_forgery_protection_token, :params, :session, :cookies, :response, :headers,
11
+ :flash, :action_name, :controller_name, :controller_path, to: :controller
15
12
 
16
13
  def assign_controller(controller)
17
14
  if @_controller = controller
@@ -24,11 +21,6 @@ module ActionView
24
21
  def logger
25
22
  controller.logger if controller.respond_to?(:logger)
26
23
  end
27
-
28
- def respond_to?(method_name, include_private = false)
29
- return controller.respond_to?(method_name) if CONTROLLER_DELEGATES.include?(method_name.to_sym)
30
- super
31
- end
32
24
  end
33
25
  end
34
26
  end
@@ -14,14 +14,14 @@ module ActionView
14
14
  #
15
15
  # You don't need to use these tags for regular forms as they generate their own hidden fields.
16
16
  #
17
- # For AJAX requests other than GETs, extract the "csrf-token" from the meta-tag and send as the
17
+ # For AJAX requests other than GETs, extract the "csrf-token" from the meta-tag and send as the
18
18
  # "X-CSRF-Token" HTTP header. If you are using jQuery with jquery-rails this happens automatically.
19
19
  #
20
20
  def csrf_meta_tags
21
21
  if protect_against_forgery?
22
22
  [
23
- tag('meta', :name => 'csrf-param', :content => request_forgery_protection_token),
24
- tag('meta', :name => 'csrf-token', :content => form_authenticity_token)
23
+ tag("meta", name: "csrf-param", content: request_forgery_protection_token),
24
+ tag("meta", name: "csrf-token", content: form_authenticity_token)
25
25
  ].join("\n").html_safe
26
26
  end
27
27
  end
@@ -1,10 +1,10 @@
1
- require 'date'
2
- require 'action_view/helpers/tag_helper'
3
- require 'active_support/core_ext/array/extract_options'
4
- require 'active_support/core_ext/date/conversions'
5
- require 'active_support/core_ext/hash/slice'
6
- require 'active_support/core_ext/object/acts_like'
7
- require 'active_support/core_ext/object/with_options'
1
+ require "date"
2
+ require "action_view/helpers/tag_helper"
3
+ require "active_support/core_ext/array/extract_options"
4
+ require "active_support/core_ext/date/conversions"
5
+ require "active_support/core_ext/hash/slice"
6
+ require "active_support/core_ext/object/acts_like"
7
+ require "active_support/core_ext/object/with_options"
8
8
 
9
9
  module ActionView
10
10
  module Helpers
@@ -98,63 +98,63 @@ module ActionView
98
98
  from_time = from_time.to_time if from_time.respond_to?(:to_time)
99
99
  to_time = to_time.to_time if to_time.respond_to?(:to_time)
100
100
  from_time, to_time = to_time, from_time if from_time > to_time
101
- distance_in_minutes = ((to_time - from_time)/60.0).round
101
+ distance_in_minutes = ((to_time - from_time) / 60.0).round
102
102
  distance_in_seconds = (to_time - from_time).round
103
103
 
104
- I18n.with_options :locale => options[:locale], :scope => options[:scope] do |locale|
104
+ I18n.with_options locale: options[:locale], scope: options[:scope] do |locale|
105
105
  case distance_in_minutes
106
- when 0..1
107
- return distance_in_minutes == 0 ?
108
- locale.t(:less_than_x_minutes, :count => 1) :
109
- locale.t(:x_minutes, :count => distance_in_minutes) unless options[:include_seconds]
110
-
111
- case distance_in_seconds
112
- when 0..4 then locale.t :less_than_x_seconds, :count => 5
113
- when 5..9 then locale.t :less_than_x_seconds, :count => 10
114
- when 10..19 then locale.t :less_than_x_seconds, :count => 20
115
- when 20..39 then locale.t :half_a_minute
116
- when 40..59 then locale.t :less_than_x_minutes, :count => 1
117
- else locale.t :x_minutes, :count => 1
118
- end
119
-
120
- when 2...45 then locale.t :x_minutes, :count => distance_in_minutes
121
- when 45...90 then locale.t :about_x_hours, :count => 1
106
+ when 0..1
107
+ return distance_in_minutes == 0 ?
108
+ locale.t(:less_than_x_minutes, count: 1) :
109
+ locale.t(:x_minutes, count: distance_in_minutes) unless options[:include_seconds]
110
+
111
+ case distance_in_seconds
112
+ when 0..4 then locale.t :less_than_x_seconds, count: 5
113
+ when 5..9 then locale.t :less_than_x_seconds, count: 10
114
+ when 10..19 then locale.t :less_than_x_seconds, count: 20
115
+ when 20..39 then locale.t :half_a_minute
116
+ when 40..59 then locale.t :less_than_x_minutes, count: 1
117
+ else locale.t :x_minutes, count: 1
118
+ end
119
+
120
+ when 2...45 then locale.t :x_minutes, count: distance_in_minutes
121
+ when 45...90 then locale.t :about_x_hours, count: 1
122
122
  # 90 mins up to 24 hours
123
- when 90...1440 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round
123
+ when 90...1440 then locale.t :about_x_hours, count: (distance_in_minutes.to_f / 60.0).round
124
124
  # 24 hours up to 42 hours
125
- when 1440...2520 then locale.t :x_days, :count => 1
125
+ when 1440...2520 then locale.t :x_days, count: 1
126
126
  # 42 hours up to 30 days
127
- when 2520...43200 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round
127
+ when 2520...43200 then locale.t :x_days, count: (distance_in_minutes.to_f / 1440.0).round
128
128
  # 30 days up to 60 days
129
- when 43200...86400 then locale.t :about_x_months, :count => (distance_in_minutes.to_f / 43200.0).round
129
+ when 43200...86400 then locale.t :about_x_months, count: (distance_in_minutes.to_f / 43200.0).round
130
130
  # 60 days up to 365 days
131
- when 86400...525600 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round
131
+ when 86400...525600 then locale.t :x_months, count: (distance_in_minutes.to_f / 43200.0).round
132
+ else
133
+ if from_time.acts_like?(:time) && to_time.acts_like?(:time)
134
+ fyear = from_time.year
135
+ fyear += 1 if from_time.month >= 3
136
+ tyear = to_time.year
137
+ tyear -= 1 if to_time.month < 3
138
+ leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count { |x| Date.leap?(x) }
139
+ minute_offset_for_leap_year = leap_years * 1440
140
+ # Discount the leap year days when calculating year distance.
141
+ # e.g. if there are 20 leap year days between 2 dates having the same day
142
+ # and month then the based on 365 days calculation
143
+ # the distance in years will come out to over 80 years when in written
144
+ # English it would read better as about 80 years.
145
+ minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
132
146
  else
133
- if from_time.acts_like?(:time) && to_time.acts_like?(:time)
134
- fyear = from_time.year
135
- fyear += 1 if from_time.month >= 3
136
- tyear = to_time.year
137
- tyear -= 1 if to_time.month < 3
138
- leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count{|x| Date.leap?(x)}
139
- minute_offset_for_leap_year = leap_years * 1440
140
- # Discount the leap year days when calculating year distance.
141
- # e.g. if there are 20 leap year days between 2 dates having the same day
142
- # and month then the based on 365 days calculation
143
- # the distance in years will come out to over 80 years when in written
144
- # English it would read better as about 80 years.
145
- minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
146
- else
147
- minutes_with_offset = distance_in_minutes
148
- end
149
- remainder = (minutes_with_offset % MINUTES_IN_YEAR)
150
- distance_in_years = (minutes_with_offset.div MINUTES_IN_YEAR)
151
- if remainder < MINUTES_IN_QUARTER_YEAR
152
- locale.t(:about_x_years, :count => distance_in_years)
153
- elsif remainder < MINUTES_IN_THREE_QUARTERS_YEAR
154
- locale.t(:over_x_years, :count => distance_in_years)
155
- else
156
- locale.t(:almost_x_years, :count => distance_in_years + 1)
157
- end
147
+ minutes_with_offset = distance_in_minutes
148
+ end
149
+ remainder = (minutes_with_offset % MINUTES_IN_YEAR)
150
+ distance_in_years = (minutes_with_offset.div MINUTES_IN_YEAR)
151
+ if remainder < MINUTES_IN_QUARTER_YEAR
152
+ locale.t(:about_x_years, count: distance_in_years)
153
+ elsif remainder < MINUTES_IN_THREE_QUARTERS_YEAR
154
+ locale.t(:over_x_years, count: distance_in_years)
155
+ else
156
+ locale.t(:almost_x_years, count: distance_in_years + 1)
157
+ end
158
158
  end
159
159
  end
160
160
  end
@@ -220,7 +220,7 @@ module ActionView
220
220
  # the respective locale (e.g. [:year, :month, :day] in the en locale that ships with Rails).
221
221
  # * <tt>:include_blank</tt> - Include a blank option in every select field so it's possible to set empty
222
222
  # dates.
223
- # * <tt>:default</tt> - Set a default date if the affected date isn't set or is nil.
223
+ # * <tt>:default</tt> - Set a default date if the affected date isn't set or is +nil+.
224
224
  # * <tt>:selected</tt> - Set a date that overrides the actual value.
225
225
  # * <tt>:disabled</tt> - Set to true if you want show the select fields as disabled.
226
226
  # * <tt>:prompt</tt> - Set to true (for a generic prompt), a prompt string or a hash of prompt strings
@@ -267,7 +267,7 @@ module ActionView
267
267
  # date_select("article", "written_on", default: 3.days.from_now)
268
268
  #
269
269
  # # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute
270
- # # which is set in the form with todays date, regardless of the value in the Active Record object.
270
+ # # which is set in the form with today's date, regardless of the value in the Active Record object.
271
271
  # date_select("article", "written_on", selected: Date.today)
272
272
  #
273
273
  # # Generates a date select that when POSTed is stored in the credit_card variable, in the bill_due attribute
@@ -303,7 +303,7 @@ module ActionView
303
303
  # # the sunrise attribute.
304
304
  # time_select("article", "start_time", include_seconds: true)
305
305
  #
306
- # # You can set the <tt>:minute_step</tt> to 15 which will give you: 00, 15, 30 and 45.
306
+ # # You can set the <tt>:minute_step</tt> to 15 which will give you: 00, 15, 30, and 45.
307
307
  # time_select 'game', 'game_time', {minute_step: 15}
308
308
  #
309
309
  # # Creates a time select tag with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
@@ -682,19 +682,19 @@ module ActionView
682
682
  def time_tag(date_or_time, *args, &block)
683
683
  options = args.extract_options!
684
684
  format = options.delete(:format) || :long
685
- content = args.first || I18n.l(date_or_time, :format => format)
685
+ content = args.first || I18n.l(date_or_time, format: format)
686
686
  datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601
687
687
 
688
- content_tag("time".freeze, content, options.reverse_merge(:datetime => datetime), &block)
688
+ content_tag("time".freeze, content, options.reverse_merge(datetime: datetime), &block)
689
689
  end
690
690
  end
691
691
 
692
692
  class DateTimeSelector #:nodoc:
693
693
  include ActionView::Helpers::TagHelper
694
694
 
695
- DEFAULT_PREFIX = 'date'.freeze
695
+ DEFAULT_PREFIX = "date".freeze
696
696
  POSITION = {
697
- :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6
697
+ year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6
698
698
  }.freeze
699
699
 
700
700
  AMPM_TRANSLATION = Hash[
@@ -710,8 +710,8 @@ module ActionView
710
710
  @options = options.dup
711
711
  @html_options = html_options.dup
712
712
  @datetime = datetime
713
- @options[:datetime_separator] ||= ' &mdash; '
714
- @options[:time_separator] ||= ' : '
713
+ @options[:datetime_separator] ||= " &mdash; "
714
+ @options[:time_separator] ||= " : "
715
715
  end
716
716
 
717
717
  def select_datetime
@@ -781,7 +781,7 @@ module ActionView
781
781
  if @options[:use_hidden] || @options[:discard_minute]
782
782
  build_hidden(:minute, min)
783
783
  else
784
- build_options_and_select(:minute, min, :step => @options[:minute_step])
784
+ build_options_and_select(:minute, min, step: @options[:minute_step])
785
785
  end
786
786
  end
787
787
 
@@ -801,7 +801,7 @@ module ActionView
801
801
  if @options[:use_hidden] || @options[:discard_day]
802
802
  build_hidden(:day, day || 1)
803
803
  else
804
- build_options_and_select(:day, day, :start => 1, :end => 31, :leading_zeros => false, :use_two_digit_numbers => @options[:use_two_digit_numbers])
804
+ build_options_and_select(:day, day, start: 1, end: 31, leading_zeros: false, use_two_digit_numbers: @options[:use_two_digit_numbers])
805
805
  end
806
806
  end
807
807
 
@@ -811,7 +811,7 @@ module ActionView
811
811
  else
812
812
  month_options = []
813
813
  1.upto(12) do |month_number|
814
- options = { :value => month_number }
814
+ options = { value: month_number }
815
815
  options[:selected] = "selected" if month == month_number
816
816
  month_options << content_tag("option".freeze, month_name(month_number), options) + "\n"
817
817
  end
@@ -821,7 +821,7 @@ module ActionView
821
821
 
822
822
  def select_year
823
823
  if !@datetime || @datetime == 0
824
- val = '1'
824
+ val = "1"
825
825
  middle_year = Date.today.year
826
826
  else
827
827
  val = middle_year = year
@@ -861,12 +861,12 @@ module ActionView
861
861
  # valid. Otherwise, February 31st or February 29th, 2011 can be selected, which are invalid.
862
862
  def set_day_if_discarded
863
863
  if @datetime && @options[:discard_day]
864
- @datetime = @datetime.change(:day => 1)
864
+ @datetime = @datetime.change(day: 1)
865
865
  end
866
866
  end
867
867
 
868
868
  # Returns translated month names, but also ensures that a custom month
869
- # name array has a leading nil element.
869
+ # name array has a leading +nil+ element.
870
870
  def month_names
871
871
  @month_names ||= begin
872
872
  month_names = @options[:use_month_names] || translated_month_names
@@ -886,7 +886,7 @@ module ActionView
886
886
  # "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
887
887
  def translated_month_names
888
888
  key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
889
- I18n.translate(key, :locale => @options[:locale])
889
+ I18n.translate(key, locale: @options[:locale])
890
890
  end
891
891
 
892
892
  # Looks up month names by number (1-based):
@@ -914,11 +914,11 @@ module ActionView
914
914
  if @options[:use_month_numbers]
915
915
  number
916
916
  elsif @options[:use_two_digit_numbers]
917
- '%02d' % number
917
+ "%02d" % number
918
918
  elsif @options[:add_month_numbers]
919
919
  "#{number} - #{month_names[number]}"
920
920
  elsif format_string = @options[:month_format_string]
921
- format_string % {number: number, name: month_names[number]}
921
+ format_string % { number: number, name: month_names[number] }
922
922
  else
923
923
  month_names[number]
924
924
  end
@@ -929,7 +929,7 @@ module ActionView
929
929
  end
930
930
 
931
931
  def translated_date_order
932
- date_order = I18n.translate(:'date.order', :locale => @options[:locale], :default => [])
932
+ date_order = I18n.translate(:'date.order', locale: @options[:locale], default: [])
933
933
  date_order = date_order.map(&:to_sym)
934
934
 
935
935
  forbidden_elements = date_order - [:year, :month, :day]
@@ -976,7 +976,7 @@ module ActionView
976
976
  select_options = []
977
977
  start.step(stop, step) do |i|
978
978
  value = leading_zeros ? sprintf("%02d", i) : i
979
- tag_options = { :value => value }
979
+ tag_options = { value: value }
980
980
  tag_options[:selected] = "selected" if selected == i
981
981
  text = options[:use_two_digit_numbers] ? sprintf("%02d", i) : value
982
982
  text = options[:ampm] ? AMPM_TRANSLATION[i] : text
@@ -993,14 +993,14 @@ module ActionView
993
993
  # </select>"
994
994
  def build_select(type, select_options_as_html)
995
995
  select_options = {
996
- :id => input_id_from_type(type),
997
- :name => input_name_from_type(type)
996
+ id: input_id_from_type(type),
997
+ name: input_name_from_type(type)
998
998
  }.merge!(@html_options)
999
- select_options[:disabled] = 'disabled' if @options[:disabled]
999
+ select_options[:disabled] = "disabled" if @options[:disabled]
1000
1000
  select_options[:class] = css_class_attribute(type, select_options[:class], @options[:with_css_classes]) if @options[:with_css_classes]
1001
1001
 
1002
1002
  select_html = "\n"
1003
- select_html << content_tag("option".freeze, '', :value => '') + "\n" if @options[:include_blank]
1003
+ select_html << content_tag("option".freeze, "", value: "") + "\n" if @options[:include_blank]
1004
1004
  select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt]
1005
1005
  select_html << select_options_as_html
1006
1006
 
@@ -1011,31 +1011,33 @@ module ActionView
1011
1011
  # css_class_attribute(:year, 'date optional', { year: 'my-year' })
1012
1012
  # => "date optional my-year"
1013
1013
  def css_class_attribute(type, html_options_class, options) # :nodoc:
1014
- css_class = case options
1015
- when Hash
1016
- options[type.to_sym]
1017
- else
1018
- type
1019
- end
1020
-
1021
- [html_options_class, css_class].compact.join(' ')
1014
+ css_class = \
1015
+ case options
1016
+ when Hash
1017
+ options[type.to_sym]
1018
+ else
1019
+ type
1020
+ end
1021
+
1022
+ [html_options_class, css_class].compact.join(" ")
1022
1023
  end
1023
1024
 
1024
1025
  # Builds a prompt option tag with supplied options or from default options.
1025
1026
  # prompt_option_tag(:month, prompt: 'Select month')
1026
1027
  # => "<option value="">Select month</option>"
1027
1028
  def prompt_option_tag(type, options)
1028
- prompt = case options
1029
+ prompt = \
1030
+ case options
1029
1031
  when Hash
1030
- default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
1032
+ default_options = { year: false, month: false, day: false, hour: false, minute: false, second: false }
1031
1033
  default_options.merge!(options)[type.to_sym]
1032
1034
  when String
1033
1035
  options
1034
1036
  else
1035
- I18n.translate(:"datetime.prompts.#{type}", :locale => @options[:locale])
1036
- end
1037
+ I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale])
1038
+ end
1037
1039
 
1038
- prompt ? content_tag("option".freeze, prompt, :value => '') : ''
1040
+ prompt ? content_tag("option".freeze, prompt, value: "") : ""
1039
1041
  end
1040
1042
 
1041
1043
  # Builds hidden input tag for date part and value.
@@ -1043,12 +1045,12 @@ module ActionView
1043
1045
  # => "<input id="post_written_on_1i" name="post[written_on(1i)]" type="hidden" value="2008" />"
1044
1046
  def build_hidden(type, value)
1045
1047
  select_options = {
1046
- :type => "hidden",
1047
- :id => input_id_from_type(type),
1048
- :name => input_name_from_type(type),
1049
- :value => value
1048
+ type: "hidden",
1049
+ id: input_id_from_type(type),
1050
+ name: input_name_from_type(type),
1051
+ value: value
1050
1052
  }.merge!(@html_options.slice(:disabled))
1051
- select_options[:disabled] = 'disabled' if @options[:disabled]
1053
+ select_options[:disabled] = "disabled" if @options[:disabled]
1052
1054
 
1053
1055
  tag(:input, select_options) + "\n".html_safe
1054
1056
  end
@@ -1059,7 +1061,7 @@ module ActionView
1059
1061
  prefix = @options[:prefix] || ActionView::Helpers::DateTimeSelector::DEFAULT_PREFIX
1060
1062
  prefix += "[#{@options[:index]}]" if @options.has_key?(:index)
1061
1063
 
1062
- field_name = @options[:field_name] || type
1064
+ field_name = @options[:field_name] || type.to_s
1063
1065
  if @options[:include_position]
1064
1066
  field_name += "(#{ActionView::Helpers::DateTimeSelector::POSITION[type]}i)"
1065
1067
  end
@@ -1070,8 +1072,8 @@ module ActionView
1070
1072
  # Returns the id attribute for the input tag.
1071
1073
  # => "post_written_on_1i"
1072
1074
  def input_id_from_type(type)
1073
- id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '')
1074
- id = @options[:namespace] + '_' + id if @options[:namespace]
1075
+ id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, "_").gsub(/[\]\)]/, "")
1076
+ id = @options[:namespace] + "_" + id if @options[:namespace]
1075
1077
 
1076
1078
  id
1077
1079
  end
@@ -1079,7 +1081,7 @@ module ActionView
1079
1081
  # Given an ordering of datetime components, create the selection HTML
1080
1082
  # and join them with their appropriate separators.
1081
1083
  def build_selects_from_types(order)
1082
- select = ''
1084
+ select = ""
1083
1085
  first_visible = order.find { |type| !@options[:"discard_#{type}"] }
1084
1086
  order.reverse_each do |type|
1085
1087
  separator = separator(type) unless type == first_visible # don't add before first visible field
@@ -1093,12 +1095,12 @@ module ActionView
1093
1095
  return "" if @options[:use_hidden]
1094
1096
 
1095
1097
  case type
1096
- when :year, :month, :day
1097
- @options[:"discard_#{type}"] ? "" : @options[:date_separator]
1098
- when :hour
1099
- (@options[:discard_year] && @options[:discard_day]) ? "" : @options[:datetime_separator]
1100
- when :minute, :second
1101
- @options[:"discard_#{type}"] ? "" : @options[:time_separator]
1098
+ when :year, :month, :day
1099
+ @options[:"discard_#{type}"] ? "" : @options[:date_separator]
1100
+ when :hour
1101
+ (@options[:discard_year] && @options[:discard_day]) ? "" : @options[:datetime_separator]
1102
+ when :minute, :second
1103
+ @options[:"discard_#{type}"] ? "" : @options[:time_separator]
1102
1104
  end
1103
1105
  end
1104
1106
  end