actionview 5.0.7.2 → 5.1.7

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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +169 -345
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/action_view/base.rb +19 -19
  6. data/lib/action_view/buffers.rb +1 -1
  7. data/lib/action_view/context.rb +1 -1
  8. data/lib/action_view/dependency_tracker.rb +4 -5
  9. data/lib/action_view/digestor.rb +22 -13
  10. data/lib/action_view/flows.rb +5 -6
  11. data/lib/action_view/gem_version.rb +2 -2
  12. data/lib/action_view/helpers/active_model_helper.rb +8 -8
  13. data/lib/action_view/helpers/asset_tag_helper.rb +62 -36
  14. data/lib/action_view/helpers/asset_url_helper.rb +111 -49
  15. data/lib/action_view/helpers/atom_feed_helper.rb +12 -13
  16. data/lib/action_view/helpers/cache_helper.rb +32 -20
  17. data/lib/action_view/helpers/capture_helper.rb +2 -2
  18. data/lib/action_view/helpers/controller_helper.rb +2 -2
  19. data/lib/action_view/helpers/csrf_helper.rb +3 -3
  20. data/lib/action_view/helpers/date_helper.rb +119 -109
  21. data/lib/action_view/helpers/debug_helper.rb +2 -3
  22. data/lib/action_view/helpers/form_helper.rb +440 -31
  23. data/lib/action_view/helpers/form_options_helper.rb +12 -12
  24. data/lib/action_view/helpers/form_tag_helper.rb +20 -19
  25. data/lib/action_view/helpers/javascript_helper.rb +6 -6
  26. data/lib/action_view/helpers/number_helper.rb +48 -46
  27. data/lib/action_view/helpers/output_safety_helper.rb +8 -8
  28. data/lib/action_view/helpers/record_tag_helper.rb +2 -2
  29. data/lib/action_view/helpers/rendering_helper.rb +2 -3
  30. data/lib/action_view/helpers/sanitize_helper.rb +16 -12
  31. data/lib/action_view/helpers/tag_helper.rb +194 -77
  32. data/lib/action_view/helpers/tags/base.rb +121 -102
  33. data/lib/action_view/helpers/tags/check_box.rb +17 -17
  34. data/lib/action_view/helpers/tags/collection_check_boxes.rb +9 -8
  35. data/lib/action_view/helpers/tags/collection_helpers.rb +60 -60
  36. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +3 -2
  37. data/lib/action_view/helpers/tags/collection_select.rb +2 -2
  38. data/lib/action_view/helpers/tags/date_select.rb +36 -36
  39. data/lib/action_view/helpers/tags/grouped_collection_select.rb +2 -2
  40. data/lib/action_view/helpers/tags/label.rb +4 -0
  41. data/lib/action_view/helpers/tags/password_field.rb +1 -1
  42. data/lib/action_view/helpers/tags/radio_button.rb +4 -4
  43. data/lib/action_view/helpers/tags/select.rb +9 -9
  44. data/lib/action_view/helpers/tags/text_area.rb +1 -1
  45. data/lib/action_view/helpers/tags/text_field.rb +5 -5
  46. data/lib/action_view/helpers/tags/translator.rb +14 -12
  47. data/lib/action_view/helpers/text_helper.rb +20 -19
  48. data/lib/action_view/helpers/translation_helper.rb +6 -6
  49. data/lib/action_view/helpers/url_helper.rb +48 -46
  50. data/lib/action_view/helpers.rb +1 -1
  51. data/lib/action_view/layouts.rb +51 -47
  52. data/lib/action_view/log_subscriber.rb +25 -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 +13 -4
  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/collection_caching.rb +7 -1
  59. data/lib/action_view/renderer/partial_renderer.rb +188 -187
  60. data/lib/action_view/renderer/renderer.rb +4 -0
  61. data/lib/action_view/renderer/streaming_template_renderer.rb +45 -47
  62. data/lib/action_view/renderer/template_renderer.rb +64 -66
  63. data/lib/action_view/rendering.rb +4 -5
  64. data/lib/action_view/routing_url_for.rb +9 -13
  65. data/lib/action_view/tasks/cache_digests.rake +7 -7
  66. data/lib/action_view/template/error.rb +5 -15
  67. data/lib/action_view/template/handlers/builder.rb +7 -7
  68. data/lib/action_view/template/handlers/erb/deprecated_erubis.rb +9 -0
  69. data/lib/action_view/template/handlers/erb/erubi.rb +81 -0
  70. data/lib/action_view/template/handlers/erb/erubis.rb +81 -0
  71. data/lib/action_view/template/handlers/erb.rb +9 -76
  72. data/lib/action_view/template/handlers.rb +4 -4
  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/template.rb +26 -27
  78. data/lib/action_view/test_case.rb +20 -21
  79. data/lib/action_view/testing/resolvers.rb +29 -30
  80. data/lib/action_view/version.rb +1 -1
  81. data/lib/action_view/view_paths.rb +20 -8
  82. data/lib/action_view.rb +5 -5
  83. data/lib/assets/compiled/rails-ujs.js +683 -0
  84. metadata +18 -12
@@ -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
@@ -95,66 +95,62 @@ module ActionView
95
95
  scope: :'datetime.distance_in_words'
96
96
  }.merge!(options)
97
97
 
98
- from_time = from_time.to_time if from_time.respond_to?(:to_time)
99
- to_time = to_time.to_time if to_time.respond_to?(:to_time)
98
+ from_time = normalize_distance_of_time_argument_to_time(from_time)
99
+ to_time = normalize_distance_of_time_argument_to_time(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
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
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
133
+ from_year = from_time.year
134
+ from_year += 1 if from_time.month >= 3
135
+ to_year = to_time.year
136
+ to_year -= 1 if to_time.month < 3
137
+ leap_years = (from_year > to_year) ? 0 : (from_year..to_year).count { |x| Date.leap?(x) }
138
+ minute_offset_for_leap_year = leap_years * 1440
139
+ # Discount the leap year days when calculating year distance.
140
+ # e.g. if there are 20 leap year days between 2 dates having the same day
141
+ # and month then the based on 365 days calculation
142
+ # the distance in years will come out to over 80 years when in written
143
+ # English it would read better as about 80 years.
144
+ minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
145
+ remainder = (minutes_with_offset % MINUTES_IN_YEAR)
146
+ distance_in_years = (minutes_with_offset.div MINUTES_IN_YEAR)
147
+ if remainder < MINUTES_IN_QUARTER_YEAR
148
+ locale.t(:about_x_years, count: distance_in_years)
149
+ elsif remainder < MINUTES_IN_THREE_QUARTERS_YEAR
150
+ locale.t(:over_x_years, count: distance_in_years)
151
+ else
152
+ locale.t(:almost_x_years, count: distance_in_years + 1)
153
+ end
158
154
  end
159
155
  end
160
156
  end
@@ -220,7 +216,7 @@ module ActionView
220
216
  # the respective locale (e.g. [:year, :month, :day] in the en locale that ships with Rails).
221
217
  # * <tt>:include_blank</tt> - Include a blank option in every select field so it's possible to set empty
222
218
  # dates.
223
- # * <tt>:default</tt> - Set a default date if the affected date isn't set or is nil.
219
+ # * <tt>:default</tt> - Set a default date if the affected date isn't set or is +nil+.
224
220
  # * <tt>:selected</tt> - Set a date that overrides the actual value.
225
221
  # * <tt>:disabled</tt> - Set to true if you want show the select fields as disabled.
226
222
  # * <tt>:prompt</tt> - Set to true (for a generic prompt), a prompt string or a hash of prompt strings
@@ -267,7 +263,7 @@ module ActionView
267
263
  # date_select("article", "written_on", default: 3.days.from_now)
268
264
  #
269
265
  # # 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.
266
+ # # which is set in the form with today's date, regardless of the value in the Active Record object.
271
267
  # date_select("article", "written_on", selected: Date.today)
272
268
  #
273
269
  # # Generates a date select that when POSTed is stored in the credit_card variable, in the bill_due attribute
@@ -303,7 +299,7 @@ module ActionView
303
299
  # # the sunrise attribute.
304
300
  # time_select("article", "start_time", include_seconds: true)
305
301
  #
306
- # # You can set the <tt>:minute_step</tt> to 15 which will give you: 00, 15, 30 and 45.
302
+ # # You can set the <tt>:minute_step</tt> to 15 which will give you: 00, 15, 30, and 45.
307
303
  # time_select 'game', 'game_time', {minute_step: 15}
308
304
  #
309
305
  # # Creates a time select tag with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
@@ -682,19 +678,31 @@ module ActionView
682
678
  def time_tag(date_or_time, *args, &block)
683
679
  options = args.extract_options!
684
680
  format = options.delete(:format) || :long
685
- content = args.first || I18n.l(date_or_time, :format => format)
681
+ content = args.first || I18n.l(date_or_time, format: format)
686
682
  datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601
687
683
 
688
- content_tag("time".freeze, content, options.reverse_merge(:datetime => datetime), &block)
684
+ content_tag("time".freeze, content, options.reverse_merge(datetime: datetime), &block)
689
685
  end
686
+
687
+ private
688
+
689
+ def normalize_distance_of_time_argument_to_time(value)
690
+ if value.is_a?(Numeric)
691
+ Time.at(value)
692
+ elsif value.respond_to?(:to_time)
693
+ value.to_time
694
+ else
695
+ raise ArgumentError, "#{value.inspect} can't be converted to a Time value"
696
+ end
697
+ end
690
698
  end
691
699
 
692
700
  class DateTimeSelector #:nodoc:
693
701
  include ActionView::Helpers::TagHelper
694
702
 
695
- DEFAULT_PREFIX = 'date'.freeze
703
+ DEFAULT_PREFIX = "date".freeze
696
704
  POSITION = {
697
- :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6
705
+ year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6
698
706
  }.freeze
699
707
 
700
708
  AMPM_TRANSLATION = Hash[
@@ -710,8 +718,8 @@ module ActionView
710
718
  @options = options.dup
711
719
  @html_options = html_options.dup
712
720
  @datetime = datetime
713
- @options[:datetime_separator] ||= ' &mdash; '
714
- @options[:time_separator] ||= ' : '
721
+ @options[:datetime_separator] ||= " &mdash; "
722
+ @options[:time_separator] ||= " : "
715
723
  end
716
724
 
717
725
  def select_datetime
@@ -781,7 +789,7 @@ module ActionView
781
789
  if @options[:use_hidden] || @options[:discard_minute]
782
790
  build_hidden(:minute, min)
783
791
  else
784
- build_options_and_select(:minute, min, :step => @options[:minute_step])
792
+ build_options_and_select(:minute, min, step: @options[:minute_step])
785
793
  end
786
794
  end
787
795
 
@@ -801,7 +809,7 @@ module ActionView
801
809
  if @options[:use_hidden] || @options[:discard_day]
802
810
  build_hidden(:day, day || 1)
803
811
  else
804
- build_options_and_select(:day, day, :start => 1, :end => 31, :leading_zeros => false, :use_two_digit_numbers => @options[:use_two_digit_numbers])
812
+ build_options_and_select(:day, day, start: 1, end: 31, leading_zeros: false, use_two_digit_numbers: @options[:use_two_digit_numbers])
805
813
  end
806
814
  end
807
815
 
@@ -811,7 +819,7 @@ module ActionView
811
819
  else
812
820
  month_options = []
813
821
  1.upto(12) do |month_number|
814
- options = { :value => month_number }
822
+ options = { value: month_number }
815
823
  options[:selected] = "selected" if month == month_number
816
824
  month_options << content_tag("option".freeze, month_name(month_number), options) + "\n"
817
825
  end
@@ -821,7 +829,7 @@ module ActionView
821
829
 
822
830
  def select_year
823
831
  if !@datetime || @datetime == 0
824
- val = '1'
832
+ val = "1"
825
833
  middle_year = Date.today.year
826
834
  else
827
835
  val = middle_year = year
@@ -861,12 +869,12 @@ module ActionView
861
869
  # valid. Otherwise, February 31st or February 29th, 2011 can be selected, which are invalid.
862
870
  def set_day_if_discarded
863
871
  if @datetime && @options[:discard_day]
864
- @datetime = @datetime.change(:day => 1)
872
+ @datetime = @datetime.change(day: 1)
865
873
  end
866
874
  end
867
875
 
868
876
  # Returns translated month names, but also ensures that a custom month
869
- # name array has a leading nil element.
877
+ # name array has a leading +nil+ element.
870
878
  def month_names
871
879
  @month_names ||= begin
872
880
  month_names = @options[:use_month_names] || translated_month_names
@@ -886,7 +894,7 @@ module ActionView
886
894
  # "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
887
895
  def translated_month_names
888
896
  key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
889
- I18n.translate(key, :locale => @options[:locale])
897
+ I18n.translate(key, locale: @options[:locale])
890
898
  end
891
899
 
892
900
  # Looks up month names by number (1-based):
@@ -914,11 +922,11 @@ module ActionView
914
922
  if @options[:use_month_numbers]
915
923
  number
916
924
  elsif @options[:use_two_digit_numbers]
917
- '%02d' % number
925
+ "%02d" % number
918
926
  elsif @options[:add_month_numbers]
919
927
  "#{number} - #{month_names[number]}"
920
928
  elsif format_string = @options[:month_format_string]
921
- format_string % {number: number, name: month_names[number]}
929
+ format_string % { number: number, name: month_names[number] }
922
930
  else
923
931
  month_names[number]
924
932
  end
@@ -929,7 +937,7 @@ module ActionView
929
937
  end
930
938
 
931
939
  def translated_date_order
932
- date_order = I18n.translate(:'date.order', :locale => @options[:locale], :default => [])
940
+ date_order = I18n.translate(:'date.order', locale: @options[:locale], default: [])
933
941
  date_order = date_order.map(&:to_sym)
934
942
 
935
943
  forbidden_elements = date_order - [:year, :month, :day]
@@ -976,7 +984,7 @@ module ActionView
976
984
  select_options = []
977
985
  start.step(stop, step) do |i|
978
986
  value = leading_zeros ? sprintf("%02d", i) : i
979
- tag_options = { :value => value }
987
+ tag_options = { value: value }
980
988
  tag_options[:selected] = "selected" if selected == i
981
989
  text = options[:use_two_digit_numbers] ? sprintf("%02d", i) : value
982
990
  text = options[:ampm] ? AMPM_TRANSLATION[i] : text
@@ -993,14 +1001,14 @@ module ActionView
993
1001
  # </select>"
994
1002
  def build_select(type, select_options_as_html)
995
1003
  select_options = {
996
- :id => input_id_from_type(type),
997
- :name => input_name_from_type(type)
1004
+ id: input_id_from_type(type),
1005
+ name: input_name_from_type(type)
998
1006
  }.merge!(@html_options)
999
- select_options[:disabled] = 'disabled' if @options[:disabled]
1007
+ select_options[:disabled] = "disabled" if @options[:disabled]
1000
1008
  select_options[:class] = css_class_attribute(type, select_options[:class], @options[:with_css_classes]) if @options[:with_css_classes]
1001
1009
 
1002
1010
  select_html = "\n"
1003
- select_html << content_tag("option".freeze, '', :value => '') + "\n" if @options[:include_blank]
1011
+ select_html << content_tag("option".freeze, "", value: "") + "\n" if @options[:include_blank]
1004
1012
  select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt]
1005
1013
  select_html << select_options_as_html
1006
1014
 
@@ -1011,31 +1019,33 @@ module ActionView
1011
1019
  # css_class_attribute(:year, 'date optional', { year: 'my-year' })
1012
1020
  # => "date optional my-year"
1013
1021
  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(' ')
1022
+ css_class = \
1023
+ case options
1024
+ when Hash
1025
+ options[type.to_sym]
1026
+ else
1027
+ type
1028
+ end
1029
+
1030
+ [html_options_class, css_class].compact.join(" ")
1022
1031
  end
1023
1032
 
1024
1033
  # Builds a prompt option tag with supplied options or from default options.
1025
1034
  # prompt_option_tag(:month, prompt: 'Select month')
1026
1035
  # => "<option value="">Select month</option>"
1027
1036
  def prompt_option_tag(type, options)
1028
- prompt = case options
1037
+ prompt = \
1038
+ case options
1029
1039
  when Hash
1030
- default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
1040
+ default_options = { year: false, month: false, day: false, hour: false, minute: false, second: false }
1031
1041
  default_options.merge!(options)[type.to_sym]
1032
1042
  when String
1033
1043
  options
1034
1044
  else
1035
- I18n.translate(:"datetime.prompts.#{type}", :locale => @options[:locale])
1036
- end
1045
+ I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale])
1046
+ end
1037
1047
 
1038
- prompt ? content_tag("option".freeze, prompt, :value => '') : ''
1048
+ prompt ? content_tag("option".freeze, prompt, value: "") : ""
1039
1049
  end
1040
1050
 
1041
1051
  # Builds hidden input tag for date part and value.
@@ -1043,12 +1053,12 @@ module ActionView
1043
1053
  # => "<input id="post_written_on_1i" name="post[written_on(1i)]" type="hidden" value="2008" />"
1044
1054
  def build_hidden(type, value)
1045
1055
  select_options = {
1046
- :type => "hidden",
1047
- :id => input_id_from_type(type),
1048
- :name => input_name_from_type(type),
1049
- :value => value
1056
+ type: "hidden",
1057
+ id: input_id_from_type(type),
1058
+ name: input_name_from_type(type),
1059
+ value: value
1050
1060
  }.merge!(@html_options.slice(:disabled))
1051
- select_options[:disabled] = 'disabled' if @options[:disabled]
1061
+ select_options[:disabled] = "disabled" if @options[:disabled]
1052
1062
 
1053
1063
  tag(:input, select_options) + "\n".html_safe
1054
1064
  end
@@ -1059,7 +1069,7 @@ module ActionView
1059
1069
  prefix = @options[:prefix] || ActionView::Helpers::DateTimeSelector::DEFAULT_PREFIX
1060
1070
  prefix += "[#{@options[:index]}]" if @options.has_key?(:index)
1061
1071
 
1062
- field_name = @options[:field_name] || type
1072
+ field_name = @options[:field_name] || type.to_s
1063
1073
  if @options[:include_position]
1064
1074
  field_name += "(#{ActionView::Helpers::DateTimeSelector::POSITION[type]}i)"
1065
1075
  end
@@ -1070,8 +1080,8 @@ module ActionView
1070
1080
  # Returns the id attribute for the input tag.
1071
1081
  # => "post_written_on_1i"
1072
1082
  def input_id_from_type(type)
1073
- id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '')
1074
- id = @options[:namespace] + '_' + id if @options[:namespace]
1083
+ id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, "_").gsub(/[\]\)]/, "")
1084
+ id = @options[:namespace] + "_" + id if @options[:namespace]
1075
1085
 
1076
1086
  id
1077
1087
  end
@@ -1079,7 +1089,7 @@ module ActionView
1079
1089
  # Given an ordering of datetime components, create the selection HTML
1080
1090
  # and join them with their appropriate separators.
1081
1091
  def build_selects_from_types(order)
1082
- select = ''
1092
+ select = ""
1083
1093
  first_visible = order.find { |type| !@options[:"discard_#{type}"] }
1084
1094
  order.reverse_each do |type|
1085
1095
  separator = separator(type) unless type == first_visible # don't add before first visible field
@@ -1093,12 +1103,12 @@ module ActionView
1093
1103
  return "" if @options[:use_hidden]
1094
1104
 
1095
1105
  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]
1106
+ when :year, :month, :day
1107
+ @options[:"discard_#{type}"] ? "" : @options[:date_separator]
1108
+ when :hour
1109
+ (@options[:discard_year] && @options[:discard_day]) ? "" : @options[:datetime_separator]
1110
+ when :minute, :second
1111
+ @options[:"discard_#{type}"] ? "" : @options[:time_separator]
1102
1112
  end
1103
1113
  end
1104
1114
  end
@@ -4,7 +4,6 @@ module ActionView
4
4
  # Provides a set of methods for making it easier to debug Rails objects.
5
5
  module Helpers
6
6
  module DebugHelper
7
-
8
7
  include TagHelper
9
8
 
10
9
  # Returns a YAML representation of +object+ wrapped with <pre> and </pre>.
@@ -25,10 +24,10 @@ module ActionView
25
24
  def debug(object)
26
25
  Marshal::dump(object)
27
26
  object = ERB::Util.html_escape(object.to_yaml)
28
- content_tag(:pre, object, :class => "debug_dump")
27
+ content_tag(:pre, object, class: "debug_dump")
29
28
  rescue # errors from Marshal or YAML
30
29
  # Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback
31
- content_tag(:code, object.inspect, :class => "debug_dump")
30
+ content_tag(:code, object.inspect, class: "debug_dump")
32
31
  end
33
32
  end
34
33
  end