actionpack 4.0.13 → 4.1.0.beta1

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.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +131 -1636
  3. data/README.rdoc +1 -6
  4. data/lib/abstract_controller.rb +1 -2
  5. data/lib/abstract_controller/base.rb +3 -25
  6. data/lib/abstract_controller/callbacks.rb +4 -2
  7. data/lib/abstract_controller/collector.rb +11 -1
  8. data/lib/abstract_controller/helpers.rb +18 -15
  9. data/lib/abstract_controller/rendering.rb +48 -127
  10. data/lib/action_controller.rb +1 -17
  11. data/lib/action_controller/base.rb +14 -6
  12. data/lib/action_controller/caching.rb +1 -11
  13. data/lib/action_controller/log_subscriber.rb +1 -1
  14. data/lib/action_controller/metal.rb +0 -4
  15. data/lib/action_controller/metal/flash.rb +17 -0
  16. data/lib/action_controller/metal/force_ssl.rb +1 -1
  17. data/lib/action_controller/metal/head.rb +1 -3
  18. data/lib/action_controller/metal/helpers.rb +6 -2
  19. data/lib/action_controller/metal/http_authentication.rb +7 -14
  20. data/lib/action_controller/metal/instrumentation.rb +1 -1
  21. data/lib/action_controller/metal/live.rb +74 -0
  22. data/lib/action_controller/metal/mime_responds.rb +93 -16
  23. data/lib/action_controller/metal/params_wrapper.rb +4 -11
  24. data/lib/action_controller/metal/rack_delegation.rb +1 -1
  25. data/lib/action_controller/metal/redirecting.rb +20 -20
  26. data/lib/action_controller/metal/renderers.rb +8 -5
  27. data/lib/action_controller/metal/rendering.rb +14 -11
  28. data/lib/action_controller/metal/request_forgery_protection.rb +67 -13
  29. data/lib/action_controller/metal/responder.rb +12 -2
  30. data/lib/action_controller/metal/streaming.rb +18 -20
  31. data/lib/action_controller/metal/strong_parameters.rb +22 -34
  32. data/lib/action_controller/railtie.rb +0 -1
  33. data/lib/action_controller/test_case.rb +0 -15
  34. data/lib/action_dispatch.rb +1 -0
  35. data/lib/action_dispatch/http/headers.rb +1 -3
  36. data/lib/action_dispatch/http/mime_negotiation.rb +16 -2
  37. data/lib/action_dispatch/http/mime_type.rb +4 -22
  38. data/lib/action_dispatch/http/mime_types.rb +1 -0
  39. data/lib/action_dispatch/http/parameters.rb +18 -19
  40. data/lib/action_dispatch/http/request.rb +16 -25
  41. data/lib/action_dispatch/http/response.rb +21 -8
  42. data/lib/action_dispatch/http/upload.rb +0 -13
  43. data/lib/action_dispatch/http/url.rb +10 -18
  44. data/lib/action_dispatch/journey/formatter.rb +3 -3
  45. data/lib/action_dispatch/journey/gtg/transition_table.rb +3 -5
  46. data/lib/action_dispatch/journey/parser.rb +1 -1
  47. data/lib/action_dispatch/journey/parser.y +1 -0
  48. data/lib/action_dispatch/journey/router.rb +7 -1
  49. data/lib/action_dispatch/journey/router/utils.rb +1 -1
  50. data/lib/action_dispatch/journey/visitors.rb +26 -47
  51. data/lib/action_dispatch/middleware/callbacks.rb +6 -6
  52. data/lib/action_dispatch/middleware/cookies.rb +15 -15
  53. data/lib/action_dispatch/middleware/debug_exceptions.rb +21 -13
  54. data/lib/action_dispatch/middleware/exception_wrapper.rb +1 -1
  55. data/lib/action_dispatch/middleware/flash.rb +5 -11
  56. data/lib/action_dispatch/middleware/params_parser.rb +1 -1
  57. data/lib/action_dispatch/middleware/public_exceptions.rb +1 -5
  58. data/lib/action_dispatch/middleware/session/cache_store.rb +3 -3
  59. data/lib/action_dispatch/middleware/session/cookie_store.rb +4 -3
  60. data/lib/action_dispatch/middleware/show_exceptions.rb +5 -2
  61. data/lib/action_dispatch/middleware/ssl.rb +1 -1
  62. data/lib/action_dispatch/middleware/static.rb +5 -25
  63. data/lib/action_dispatch/middleware/templates/rescues/{_request_and_response.erb → _request_and_response.html.erb} +0 -0
  64. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
  65. data/lib/action_dispatch/middleware/templates/rescues/{_trace.erb → _trace.html.erb} +0 -0
  66. data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +15 -0
  67. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +1 -1
  68. data/lib/action_dispatch/middleware/templates/rescues/{missing_template.erb → missing_template.html.erb} +1 -1
  69. data/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
  70. data/lib/action_dispatch/middleware/templates/rescues/{routing_error.erb → routing_error.html.erb} +1 -1
  71. data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
  72. data/lib/action_dispatch/middleware/templates/rescues/{template_error.erb → template_error.html.erb} +1 -1
  73. data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +8 -0
  74. data/lib/action_dispatch/middleware/templates/rescues/{unknown_action.erb → unknown_action.html.erb} +1 -1
  75. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
  76. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +3 -3
  77. data/lib/action_dispatch/railtie.rb +1 -2
  78. data/lib/action_dispatch/request/session.rb +12 -0
  79. data/lib/action_dispatch/request/utils.rb +24 -0
  80. data/lib/action_dispatch/routing.rb +7 -6
  81. data/lib/action_dispatch/routing/inspector.rb +4 -4
  82. data/lib/action_dispatch/routing/mapper.rb +81 -138
  83. data/lib/action_dispatch/routing/polymorphic_routes.rb +13 -0
  84. data/lib/action_dispatch/routing/redirection.rb +34 -27
  85. data/lib/action_dispatch/routing/route_set.rb +43 -37
  86. data/lib/action_dispatch/routing/url_for.rb +3 -1
  87. data/lib/action_dispatch/testing/assertions/response.rb +8 -15
  88. data/lib/action_dispatch/testing/assertions/selector.rb +4 -4
  89. data/lib/action_dispatch/testing/integration.rb +1 -7
  90. data/lib/action_pack/version.rb +1 -1
  91. metadata +43 -167
  92. data/lib/abstract_controller/layouts.rb +0 -423
  93. data/lib/abstract_controller/view_paths.rb +0 -96
  94. data/lib/action_controller/deprecated.rb +0 -7
  95. data/lib/action_controller/deprecated/integration_test.rb +0 -5
  96. data/lib/action_controller/record_identifier.rb +0 -31
  97. data/lib/action_controller/vendor/html-scanner.rb +0 -5
  98. data/lib/action_view.rb +0 -93
  99. data/lib/action_view/base.rb +0 -205
  100. data/lib/action_view/buffers.rb +0 -49
  101. data/lib/action_view/context.rb +0 -36
  102. data/lib/action_view/dependency_tracker.rb +0 -93
  103. data/lib/action_view/digestor.rb +0 -113
  104. data/lib/action_view/flows.rb +0 -76
  105. data/lib/action_view/helpers.rb +0 -58
  106. data/lib/action_view/helpers/active_model_helper.rb +0 -49
  107. data/lib/action_view/helpers/asset_tag_helper.rb +0 -320
  108. data/lib/action_view/helpers/asset_url_helper.rb +0 -355
  109. data/lib/action_view/helpers/atom_feed_helper.rb +0 -203
  110. data/lib/action_view/helpers/cache_helper.rb +0 -196
  111. data/lib/action_view/helpers/capture_helper.rb +0 -216
  112. data/lib/action_view/helpers/controller_helper.rb +0 -25
  113. data/lib/action_view/helpers/csrf_helper.rb +0 -32
  114. data/lib/action_view/helpers/date_helper.rb +0 -1087
  115. data/lib/action_view/helpers/debug_helper.rb +0 -39
  116. data/lib/action_view/helpers/form_helper.rb +0 -1882
  117. data/lib/action_view/helpers/form_options_helper.rb +0 -838
  118. data/lib/action_view/helpers/form_tag_helper.rb +0 -785
  119. data/lib/action_view/helpers/javascript_helper.rb +0 -117
  120. data/lib/action_view/helpers/number_helper.rb +0 -451
  121. data/lib/action_view/helpers/output_safety_helper.rb +0 -38
  122. data/lib/action_view/helpers/record_tag_helper.rb +0 -106
  123. data/lib/action_view/helpers/rendering_helper.rb +0 -90
  124. data/lib/action_view/helpers/sanitize_helper.rb +0 -256
  125. data/lib/action_view/helpers/tag_helper.rb +0 -173
  126. data/lib/action_view/helpers/tags.rb +0 -39
  127. data/lib/action_view/helpers/tags/base.rb +0 -148
  128. data/lib/action_view/helpers/tags/check_box.rb +0 -64
  129. data/lib/action_view/helpers/tags/checkable.rb +0 -16
  130. data/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -53
  131. data/lib/action_view/helpers/tags/collection_helpers.rb +0 -84
  132. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -36
  133. data/lib/action_view/helpers/tags/collection_select.rb +0 -28
  134. data/lib/action_view/helpers/tags/color_field.rb +0 -25
  135. data/lib/action_view/helpers/tags/date_field.rb +0 -13
  136. data/lib/action_view/helpers/tags/date_select.rb +0 -72
  137. data/lib/action_view/helpers/tags/datetime_field.rb +0 -22
  138. data/lib/action_view/helpers/tags/datetime_local_field.rb +0 -19
  139. data/lib/action_view/helpers/tags/datetime_select.rb +0 -8
  140. data/lib/action_view/helpers/tags/email_field.rb +0 -8
  141. data/lib/action_view/helpers/tags/file_field.rb +0 -8
  142. data/lib/action_view/helpers/tags/grouped_collection_select.rb +0 -29
  143. data/lib/action_view/helpers/tags/hidden_field.rb +0 -8
  144. data/lib/action_view/helpers/tags/label.rb +0 -65
  145. data/lib/action_view/helpers/tags/month_field.rb +0 -13
  146. data/lib/action_view/helpers/tags/number_field.rb +0 -18
  147. data/lib/action_view/helpers/tags/password_field.rb +0 -12
  148. data/lib/action_view/helpers/tags/radio_button.rb +0 -31
  149. data/lib/action_view/helpers/tags/range_field.rb +0 -8
  150. data/lib/action_view/helpers/tags/search_field.rb +0 -22
  151. data/lib/action_view/helpers/tags/select.rb +0 -40
  152. data/lib/action_view/helpers/tags/tel_field.rb +0 -8
  153. data/lib/action_view/helpers/tags/text_area.rb +0 -18
  154. data/lib/action_view/helpers/tags/text_field.rb +0 -30
  155. data/lib/action_view/helpers/tags/time_field.rb +0 -13
  156. data/lib/action_view/helpers/tags/time_select.rb +0 -8
  157. data/lib/action_view/helpers/tags/time_zone_select.rb +0 -20
  158. data/lib/action_view/helpers/tags/url_field.rb +0 -8
  159. data/lib/action_view/helpers/tags/week_field.rb +0 -13
  160. data/lib/action_view/helpers/text_helper.rb +0 -448
  161. data/lib/action_view/helpers/translation_helper.rb +0 -112
  162. data/lib/action_view/helpers/url_helper.rb +0 -635
  163. data/lib/action_view/locale/en.yml +0 -56
  164. data/lib/action_view/log_subscriber.rb +0 -30
  165. data/lib/action_view/lookup_context.rb +0 -248
  166. data/lib/action_view/model_naming.rb +0 -12
  167. data/lib/action_view/path_set.rb +0 -77
  168. data/lib/action_view/railtie.rb +0 -43
  169. data/lib/action_view/record_identifier.rb +0 -84
  170. data/lib/action_view/renderer/abstract_renderer.rb +0 -47
  171. data/lib/action_view/renderer/partial_renderer.rb +0 -500
  172. data/lib/action_view/renderer/renderer.rb +0 -50
  173. data/lib/action_view/renderer/streaming_template_renderer.rb +0 -103
  174. data/lib/action_view/renderer/template_renderer.rb +0 -96
  175. data/lib/action_view/routing_url_for.rb +0 -107
  176. data/lib/action_view/tasks/dependencies.rake +0 -17
  177. data/lib/action_view/template.rb +0 -339
  178. data/lib/action_view/template/error.rb +0 -138
  179. data/lib/action_view/template/handlers.rb +0 -53
  180. data/lib/action_view/template/handlers/builder.rb +0 -26
  181. data/lib/action_view/template/handlers/erb.rb +0 -146
  182. data/lib/action_view/template/handlers/raw.rb +0 -11
  183. data/lib/action_view/template/resolver.rb +0 -340
  184. data/lib/action_view/template/text.rb +0 -34
  185. data/lib/action_view/template/types.rb +0 -57
  186. data/lib/action_view/test_case.rb +0 -270
  187. data/lib/action_view/testing/resolvers.rb +0 -50
  188. data/lib/action_view/vendor/html-scanner.rb +0 -20
  189. data/lib/action_view/vendor/html-scanner/html/document.rb +0 -68
  190. data/lib/action_view/vendor/html-scanner/html/node.rb +0 -532
  191. data/lib/action_view/vendor/html-scanner/html/sanitizer.rb +0 -188
  192. data/lib/action_view/vendor/html-scanner/html/selector.rb +0 -830
  193. data/lib/action_view/vendor/html-scanner/html/tokenizer.rb +0 -107
  194. data/lib/action_view/vendor/html-scanner/html/version.rb +0 -11
@@ -1,56 +0,0 @@
1
- "en":
2
- # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
3
- datetime:
4
- distance_in_words:
5
- half_a_minute: "half a minute"
6
- less_than_x_seconds:
7
- one: "less than 1 second"
8
- other: "less than %{count} seconds"
9
- x_seconds:
10
- one: "1 second"
11
- other: "%{count} seconds"
12
- less_than_x_minutes:
13
- one: "less than a minute"
14
- other: "less than %{count} minutes"
15
- x_minutes:
16
- one: "1 minute"
17
- other: "%{count} minutes"
18
- about_x_hours:
19
- one: "about 1 hour"
20
- other: "about %{count} hours"
21
- x_days:
22
- one: "1 day"
23
- other: "%{count} days"
24
- about_x_months:
25
- one: "about 1 month"
26
- other: "about %{count} months"
27
- x_months:
28
- one: "1 month"
29
- other: "%{count} months"
30
- about_x_years:
31
- one: "about 1 year"
32
- other: "about %{count} years"
33
- over_x_years:
34
- one: "over 1 year"
35
- other: "over %{count} years"
36
- almost_x_years:
37
- one: "almost 1 year"
38
- other: "almost %{count} years"
39
- prompts:
40
- year: "Year"
41
- month: "Month"
42
- day: "Day"
43
- hour: "Hour"
44
- minute: "Minute"
45
- second: "Seconds"
46
-
47
- helpers:
48
- select:
49
- # Default value for :prompt => true in FormOptionsHelper
50
- prompt: "Please select"
51
-
52
- # Default translation keys for submit and button FormHelper
53
- submit:
54
- create: 'Create %{model}'
55
- update: 'Update %{model}'
56
- submit: 'Save %{model}'
@@ -1,30 +0,0 @@
1
- module ActionView
2
- # = Action View Log Subscriber
3
- #
4
- # Provides functionality so that Rails can output logs from Action View.
5
- class LogSubscriber < ActiveSupport::LogSubscriber
6
- VIEWS_PATTERN = /^app\/views\//.freeze
7
-
8
- def render_template(event)
9
- return unless logger.info?
10
- message = " Rendered #{from_rails_root(event.payload[:identifier])}"
11
- message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
12
- message << " (#{event.duration.round(1)}ms)"
13
- info(message)
14
- end
15
- alias :render_partial :render_template
16
- alias :render_collection :render_template
17
-
18
- def logger
19
- ActionView::Base.logger
20
- end
21
-
22
- protected
23
-
24
- def from_rails_root(string)
25
- string.sub("#{Rails.root}/", "").sub(VIEWS_PATTERN, "")
26
- end
27
- end
28
- end
29
-
30
- ActionView::LogSubscriber.attach_to :action_view
@@ -1,248 +0,0 @@
1
- require 'thread_safe'
2
- require 'active_support/core_ext/module/remove_method'
3
- require 'active_support/core_ext/module/attribute_accessors'
4
-
5
- module ActionView
6
- # = Action View Lookup Context
7
- #
8
- # LookupContext is the object responsible to hold all information required to lookup
9
- # templates, i.e. view paths and details. The LookupContext is also responsible to
10
- # generate a key, given to view paths, used in the resolver cache lookup. Since
11
- # this key is generated just once during the request, it speeds up all cache accesses.
12
- class LookupContext #:nodoc:
13
- attr_accessor :prefixes, :rendered_format
14
-
15
- mattr_accessor :fallbacks
16
- @@fallbacks = FallbackFileSystemResolver.instances
17
-
18
- mattr_accessor :registered_details
19
- self.registered_details = []
20
-
21
- def self.register_detail(name, options = {}, &block)
22
- self.registered_details << name
23
- initialize = registered_details.map { |n| "@details[:#{n}] = details[:#{n}] || default_#{n}" }
24
-
25
- Accessors.send :define_method, :"default_#{name}", &block
26
- Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
27
- def #{name}
28
- @details.fetch(:#{name}, [])
29
- end
30
-
31
- def #{name}=(value)
32
- value = value.present? ? Array(value) : default_#{name}
33
- _set_detail(:#{name}, value) if value != @details[:#{name}]
34
- end
35
-
36
- remove_possible_method :initialize_details
37
- def initialize_details(details)
38
- #{initialize.join("\n")}
39
- end
40
- METHOD
41
- end
42
-
43
- # Holds accessors for the registered details.
44
- module Accessors #:nodoc:
45
- end
46
-
47
- register_detail(:locale) do
48
- locales = [I18n.locale]
49
- locales.concat(I18n.fallbacks[I18n.locale]) if I18n.respond_to? :fallbacks
50
- locales << I18n.default_locale
51
- locales.uniq!
52
- locales
53
- end
54
- register_detail(:formats) { ActionView::Base.default_formats || [:html, :text, :js, :css, :xml, :json] }
55
- register_detail(:handlers){ Template::Handlers.extensions }
56
-
57
- class DetailsKey #:nodoc:
58
- alias :eql? :equal?
59
- alias :object_hash :hash
60
-
61
- attr_reader :hash
62
- @details_keys = ThreadSafe::Cache.new
63
-
64
- def self.get(details)
65
- if details[:formats]
66
- details = details.dup
67
- syms = Set.new Mime::SET.symbols
68
- details[:formats] = details[:formats].select { |v|
69
- syms.include? v
70
- }
71
- end
72
- @details_keys[details] ||= new
73
- end
74
-
75
- def self.clear
76
- @details_keys.clear
77
- end
78
-
79
- def initialize
80
- @hash = object_hash
81
- end
82
- end
83
-
84
- # Add caching behavior on top of Details.
85
- module DetailsCache
86
- attr_accessor :cache
87
-
88
- # Calculate the details key. Remove the handlers from calculation to improve performance
89
- # since the user cannot modify it explicitly.
90
- def details_key #:nodoc:
91
- @details_key ||= DetailsKey.get(@details) if @cache
92
- end
93
-
94
- # Temporary skip passing the details_key forward.
95
- def disable_cache
96
- old_value, @cache = @cache, false
97
- yield
98
- ensure
99
- @cache = old_value
100
- end
101
-
102
- protected
103
-
104
- def _set_detail(key, value)
105
- @details = @details.dup if @details_key
106
- @details_key = nil
107
- @details[key] = value
108
- end
109
- end
110
-
111
- # Helpers related to template lookup using the lookup context information.
112
- module ViewPaths
113
- attr_reader :view_paths, :html_fallback_for_js
114
-
115
- # Whenever setting view paths, makes a copy so we can manipulate then in
116
- # instance objects as we wish.
117
- def view_paths=(paths)
118
- @view_paths = ActionView::PathSet.new(Array(paths))
119
- end
120
-
121
- def find(name, prefixes = [], partial = false, keys = [], options = {})
122
- @view_paths.find(*args_for_lookup(name, prefixes, partial, keys, options))
123
- end
124
- alias :find_template :find
125
-
126
- def find_all(name, prefixes = [], partial = false, keys = [], options = {})
127
- @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys, options))
128
- end
129
-
130
- def exists?(name, prefixes = [], partial = false, keys = [], options = {})
131
- @view_paths.exists?(*args_for_lookup(name, prefixes, partial, keys, options))
132
- end
133
- alias :template_exists? :exists?
134
-
135
- # Add fallbacks to the view paths. Useful in cases you are rendering a :file.
136
- def with_fallbacks
137
- added_resolvers = 0
138
- self.class.fallbacks.each do |resolver|
139
- next if view_paths.include?(resolver)
140
- view_paths.push(resolver)
141
- added_resolvers += 1
142
- end
143
- yield
144
- ensure
145
- added_resolvers.times { view_paths.pop }
146
- end
147
-
148
- protected
149
-
150
- def args_for_lookup(name, prefixes, partial, keys, details_options) #:nodoc:
151
- name, prefixes = normalize_name(name, prefixes)
152
- details, details_key = detail_args_for(details_options)
153
- [name, prefixes, partial || false, details, details_key, keys]
154
- end
155
-
156
- # Compute details hash and key according to user options (e.g. passed from #render).
157
- def detail_args_for(options)
158
- return @details, details_key if options.empty? # most common path.
159
- user_details = @details.merge(options)
160
- [user_details, DetailsKey.get(user_details)]
161
- end
162
-
163
- # Support legacy foo.erb names even though we now ignore .erb
164
- # as well as incorrectly putting part of the path in the template
165
- # name instead of the prefix.
166
- def normalize_name(name, prefixes) #:nodoc:
167
- prefixes = prefixes.presence
168
- parts = name.to_s.split('/')
169
- parts.shift if parts.first.empty?
170
- name = parts.pop
171
-
172
- return name, prefixes || [""] if parts.empty?
173
-
174
- parts = parts.join('/')
175
- prefixes = prefixes ? prefixes.map { |p| "#{p}/#{parts}" } : [parts]
176
-
177
- return name, prefixes
178
- end
179
- end
180
-
181
- include Accessors
182
- include DetailsCache
183
- include ViewPaths
184
-
185
- def initialize(view_paths, details = {}, prefixes = [])
186
- @details, @details_key = {}, nil
187
- @skip_default_locale = false
188
- @cache = true
189
- @prefixes = prefixes
190
- @rendered_format = nil
191
-
192
- self.view_paths = view_paths
193
- initialize_details(details)
194
- end
195
-
196
- # Override formats= to expand ["*/*"] values and automatically
197
- # add :html as fallback to :js.
198
- def formats=(values)
199
- if values
200
- values.concat(default_formats) if values.delete "*/*"
201
- if values == [:js]
202
- values << :html
203
- @html_fallback_for_js = true
204
- end
205
- end
206
- super(values)
207
- end
208
-
209
- # Do not use the default locale on template lookup.
210
- def skip_default_locale!
211
- @skip_default_locale = true
212
- self.locale = nil
213
- end
214
-
215
- # Override locale to return a symbol instead of array.
216
- def locale
217
- @details[:locale].first
218
- end
219
-
220
- # Overload locale= to also set the I18n.locale. If the current I18n.config object responds
221
- # to original_config, it means that it's has a copy of the original I18n configuration and it's
222
- # acting as proxy, which we need to skip.
223
- def locale=(value)
224
- if value
225
- config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
226
- config.locale = value
227
- end
228
-
229
- super(@skip_default_locale ? I18n.locale : default_locale)
230
- end
231
-
232
- # A method which only uses the first format in the formats array for layout lookup.
233
- def with_layout_format
234
- if formats.size == 1
235
- yield
236
- else
237
- old_formats = formats
238
- _set_detail(:formats, formats[0,1])
239
-
240
- begin
241
- yield
242
- ensure
243
- _set_detail(:formats, old_formats)
244
- end
245
- end
246
- end
247
- end
248
- end
@@ -1,12 +0,0 @@
1
- module ActionView
2
- module ModelNaming
3
- # Converts the given object to an ActiveModel compliant one.
4
- def convert_to_model(object)
5
- object.respond_to?(:to_model) ? object.to_model : object
6
- end
7
-
8
- def model_name_from_record_or_class(record_or_class)
9
- (record_or_class.is_a?(Class) ? record_or_class : convert_to_model(record_or_class).class).model_name
10
- end
11
- end
12
- end
@@ -1,77 +0,0 @@
1
- module ActionView #:nodoc:
2
- # = Action View PathSet
3
- #
4
- # This class is used to store and access paths in Action View. A number of
5
- # operations are defined so that you can search among the paths in this
6
- # set and also perform operations on other +PathSet+ objects.
7
- #
8
- # A +LookupContext+ will use a +PathSet+ to store the paths in its context.
9
- class PathSet #:nodoc:
10
- include Enumerable
11
-
12
- attr_reader :paths
13
-
14
- delegate :[], :include?, :pop, :size, :each, to: :paths
15
-
16
- def initialize(paths = [])
17
- @paths = typecast paths
18
- end
19
-
20
- def initialize_copy(other)
21
- @paths = other.paths.dup
22
- self
23
- end
24
-
25
- def to_ary
26
- paths.dup
27
- end
28
-
29
- def compact
30
- PathSet.new paths.compact
31
- end
32
-
33
- def +(array)
34
- PathSet.new(paths + array)
35
- end
36
-
37
- %w(<< concat push insert unshift).each do |method|
38
- class_eval <<-METHOD, __FILE__, __LINE__ + 1
39
- def #{method}(*args)
40
- paths.#{method}(*typecast(args))
41
- end
42
- METHOD
43
- end
44
-
45
- def find(*args)
46
- find_all(*args).first || raise(MissingTemplate.new(self, *args))
47
- end
48
-
49
- def find_all(path, prefixes = [], *args)
50
- prefixes = [prefixes] if String === prefixes
51
- prefixes.each do |prefix|
52
- paths.each do |resolver|
53
- templates = resolver.find_all(path, prefix, *args)
54
- return templates unless templates.empty?
55
- end
56
- end
57
- []
58
- end
59
-
60
- def exists?(path, prefixes, *args)
61
- find_all(path, prefixes, *args).any?
62
- end
63
-
64
- private
65
-
66
- def typecast(paths)
67
- paths.map do |path|
68
- case path
69
- when Pathname, String
70
- OptimizedFileSystemResolver.new path.to_s
71
- else
72
- path
73
- end
74
- end
75
- end
76
- end
77
- end
@@ -1,43 +0,0 @@
1
- require "action_view"
2
- require "rails"
3
-
4
- module ActionView
5
- # = Action View Railtie
6
- class Railtie < Rails::Railtie # :nodoc:
7
- config.action_view = ActiveSupport::OrderedOptions.new
8
- config.action_view.embed_authenticity_token_in_remote_forms = false
9
-
10
- config.eager_load_namespaces << ActionView
11
-
12
- initializer "action_view.embed_authenticity_token_in_remote_forms" do |app|
13
- ActiveSupport.on_load(:action_view) do
14
- ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms =
15
- app.config.action_view.delete(:embed_authenticity_token_in_remote_forms)
16
- end
17
- end
18
-
19
- initializer "action_view.logger" do
20
- ActiveSupport.on_load(:action_view) { self.logger ||= Rails.logger }
21
- end
22
-
23
- initializer "action_view.set_configs" do |app|
24
- ActiveSupport.on_load(:action_view) do
25
- app.config.action_view.each do |k,v|
26
- send "#{k}=", v
27
- end
28
- end
29
- end
30
-
31
- initializer "action_view.caching" do |app|
32
- ActiveSupport.on_load(:action_view) do
33
- if app.config.action_view.cache_template_loading.nil?
34
- ActionView::Resolver.caching = app.config.cache_classes
35
- end
36
- end
37
- end
38
-
39
- rake_tasks do
40
- load "action_view/tasks/dependencies.rake"
41
- end
42
- end
43
- end