actionpack 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 actionpack might be problematic. Click here for more details.

Files changed (128) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +189 -1002
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/abstract_controller.rb +3 -3
  6. data/lib/abstract_controller/base.rb +10 -12
  7. data/lib/abstract_controller/caching.rb +6 -3
  8. data/lib/abstract_controller/caching/fragments.rb +1 -1
  9. data/lib/abstract_controller/callbacks.rb +2 -43
  10. data/lib/abstract_controller/collector.rb +2 -2
  11. data/lib/abstract_controller/helpers.rb +19 -19
  12. data/lib/abstract_controller/rendering.rb +9 -11
  13. data/lib/abstract_controller/translation.rb +3 -3
  14. data/lib/action_controller.rb +15 -13
  15. data/lib/action_controller/api.rb +3 -3
  16. data/lib/action_controller/base.rb +7 -12
  17. data/lib/action_controller/caching.rb +1 -1
  18. data/lib/action_controller/log_subscriber.rb +2 -2
  19. data/lib/action_controller/metal.rb +34 -43
  20. data/lib/action_controller/metal/conditional_get.rb +10 -9
  21. data/lib/action_controller/metal/data_streaming.rb +8 -9
  22. data/lib/action_controller/metal/etag_with_flash.rb +16 -0
  23. data/lib/action_controller/metal/etag_with_template_digest.rb +15 -15
  24. data/lib/action_controller/metal/exceptions.rb +4 -14
  25. data/lib/action_controller/metal/flash.rb +1 -1
  26. data/lib/action_controller/metal/force_ssl.rb +6 -6
  27. data/lib/action_controller/metal/head.rb +13 -19
  28. data/lib/action_controller/metal/helpers.rb +6 -6
  29. data/lib/action_controller/metal/http_authentication.rb +22 -23
  30. data/lib/action_controller/metal/implicit_render.rb +2 -5
  31. data/lib/action_controller/metal/instrumentation.rb +14 -14
  32. data/lib/action_controller/metal/live.rb +15 -16
  33. data/lib/action_controller/metal/mime_responds.rb +3 -3
  34. data/lib/action_controller/metal/parameter_encoding.rb +49 -0
  35. data/lib/action_controller/metal/params_wrapper.rb +32 -32
  36. data/lib/action_controller/metal/redirecting.rb +8 -24
  37. data/lib/action_controller/metal/renderers.rb +2 -3
  38. data/lib/action_controller/metal/rendering.rb +50 -60
  39. data/lib/action_controller/metal/request_forgery_protection.rb +51 -49
  40. data/lib/action_controller/metal/rescue.rb +1 -1
  41. data/lib/action_controller/metal/streaming.rb +4 -4
  42. data/lib/action_controller/metal/strong_parameters.rb +117 -250
  43. data/lib/action_controller/metal/testing.rb +1 -1
  44. data/lib/action_controller/metal/url_for.rb +4 -4
  45. data/lib/action_controller/railtie.rb +9 -13
  46. data/lib/action_controller/renderer.rb +17 -16
  47. data/lib/action_controller/test_case.rb +75 -148
  48. data/lib/action_dispatch.rb +20 -19
  49. data/lib/action_dispatch/http/cache.rb +9 -10
  50. data/lib/action_dispatch/http/filter_parameters.rb +8 -8
  51. data/lib/action_dispatch/http/filter_redirect.rb +2 -4
  52. data/lib/action_dispatch/http/headers.rb +10 -10
  53. data/lib/action_dispatch/http/mime_negotiation.rb +17 -22
  54. data/lib/action_dispatch/http/mime_type.rb +27 -52
  55. data/lib/action_dispatch/http/parameter_filter.rb +8 -6
  56. data/lib/action_dispatch/http/parameters.rb +40 -17
  57. data/lib/action_dispatch/http/request.rb +38 -34
  58. data/lib/action_dispatch/http/response.rb +16 -16
  59. data/lib/action_dispatch/http/upload.rb +6 -10
  60. data/lib/action_dispatch/http/url.rb +48 -74
  61. data/lib/action_dispatch/journey.rb +5 -5
  62. data/lib/action_dispatch/journey/formatter.rb +8 -4
  63. data/lib/action_dispatch/journey/gtg/builder.rb +5 -5
  64. data/lib/action_dispatch/journey/gtg/simulator.rb +1 -1
  65. data/lib/action_dispatch/journey/gtg/transition_table.rb +15 -15
  66. data/lib/action_dispatch/journey/nfa/builder.rb +3 -3
  67. data/lib/action_dispatch/journey/nfa/dot.rb +2 -2
  68. data/lib/action_dispatch/journey/nfa/simulator.rb +1 -1
  69. data/lib/action_dispatch/journey/nfa/transition_table.rb +2 -2
  70. data/lib/action_dispatch/journey/nodes/node.rb +5 -5
  71. data/lib/action_dispatch/journey/parser.rb +23 -24
  72. data/lib/action_dispatch/journey/parser.y +3 -2
  73. data/lib/action_dispatch/journey/parser_extras.rb +2 -2
  74. data/lib/action_dispatch/journey/path/pattern.rb +10 -3
  75. data/lib/action_dispatch/journey/route.rb +19 -12
  76. data/lib/action_dispatch/journey/router.rb +19 -12
  77. data/lib/action_dispatch/journey/router/utils.rb +9 -9
  78. data/lib/action_dispatch/journey/scanner.rb +17 -15
  79. data/lib/action_dispatch/journey/visitors.rb +23 -23
  80. data/lib/action_dispatch/middleware/callbacks.rb +0 -12
  81. data/lib/action_dispatch/middleware/cookies.rb +39 -39
  82. data/lib/action_dispatch/middleware/debug_exceptions.rb +126 -112
  83. data/lib/action_dispatch/middleware/debug_locks.rb +8 -8
  84. data/lib/action_dispatch/middleware/exception_wrapper.rb +55 -55
  85. data/lib/action_dispatch/middleware/executor.rb +1 -1
  86. data/lib/action_dispatch/middleware/flash.rb +17 -16
  87. data/lib/action_dispatch/middleware/public_exceptions.rb +20 -20
  88. data/lib/action_dispatch/middleware/reloader.rb +3 -47
  89. data/lib/action_dispatch/middleware/remote_ip.rb +6 -8
  90. data/lib/action_dispatch/middleware/request_id.rb +6 -5
  91. data/lib/action_dispatch/middleware/session/abstract_store.rb +14 -26
  92. data/lib/action_dispatch/middleware/session/cache_store.rb +3 -3
  93. data/lib/action_dispatch/middleware/session/cookie_store.rb +35 -35
  94. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +2 -2
  95. data/lib/action_dispatch/middleware/show_exceptions.rb +19 -19
  96. data/lib/action_dispatch/middleware/ssl.rb +9 -27
  97. data/lib/action_dispatch/middleware/stack.rb +7 -26
  98. data/lib/action_dispatch/middleware/static.rb +13 -24
  99. data/lib/action_dispatch/railtie.rb +9 -11
  100. data/lib/action_dispatch/request/session.rb +22 -22
  101. data/lib/action_dispatch/request/utils.rb +11 -2
  102. data/lib/action_dispatch/routing.rb +8 -6
  103. data/lib/action_dispatch/routing/inspector.rb +37 -37
  104. data/lib/action_dispatch/routing/mapper.rb +296 -203
  105. data/lib/action_dispatch/routing/polymorphic_routes.rb +160 -134
  106. data/lib/action_dispatch/routing/redirection.rb +27 -22
  107. data/lib/action_dispatch/routing/route_set.rb +206 -92
  108. data/lib/action_dispatch/routing/routes_proxy.rb +2 -2
  109. data/lib/action_dispatch/routing/url_for.rb +14 -12
  110. data/lib/action_dispatch/system_test_case.rb +119 -0
  111. data/lib/action_dispatch/system_testing/browser.rb +28 -0
  112. data/lib/action_dispatch/system_testing/driver.rb +18 -0
  113. data/lib/action_dispatch/system_testing/server.rb +32 -0
  114. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +61 -0
  115. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +20 -0
  116. data/lib/action_dispatch/testing/assertion_response.rb +6 -6
  117. data/lib/action_dispatch/testing/assertions.rb +4 -4
  118. data/lib/action_dispatch/testing/assertions/response.rb +8 -3
  119. data/lib/action_dispatch/testing/assertions/routing.rb +11 -11
  120. data/lib/action_dispatch/testing/integration.rb +47 -138
  121. data/lib/action_dispatch/testing/test_process.rb +2 -2
  122. data/lib/action_dispatch/testing/test_request.rb +16 -16
  123. data/lib/action_dispatch/testing/test_response.rb +1 -1
  124. data/lib/action_pack.rb +2 -2
  125. data/lib/action_pack/gem_version.rb +3 -3
  126. data/lib/action_pack/version.rb +1 -1
  127. metadata +20 -12
  128. data/lib/action_dispatch/middleware/params_parser.rb +0 -46
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2016 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2017 David Heinemeier Hansson
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -21,15 +21,15 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- require 'active_support'
25
- require 'active_support/rails'
26
- require 'active_support/core_ext/module/attribute_accessors'
24
+ require "active_support"
25
+ require "active_support/rails"
26
+ require "active_support/core_ext/module/attribute_accessors"
27
27
 
28
- require 'action_pack'
29
- require 'rack'
28
+ require "action_pack"
29
+ require "rack"
30
30
 
31
31
  module Rack
32
- autoload :Test, 'rack/test'
32
+ autoload :Test, "rack/test"
33
33
  end
34
34
 
35
35
  module ActionDispatch
@@ -39,13 +39,13 @@ module ActionDispatch
39
39
  end
40
40
 
41
41
  eager_autoload do
42
- autoload_under 'http' do
42
+ autoload_under "http" do
43
43
  autoload :Request
44
44
  autoload :Response
45
45
  end
46
46
  end
47
47
 
48
- autoload_under 'middleware' do
48
+ autoload_under "middleware" do
49
49
  autoload :RequestId
50
50
  autoload :Callbacks
51
51
  autoload :Cookies
@@ -54,7 +54,6 @@ module ActionDispatch
54
54
  autoload :ExceptionWrapper
55
55
  autoload :Executor
56
56
  autoload :Flash
57
- autoload :ParamsParser
58
57
  autoload :PublicExceptions
59
58
  autoload :Reloader
60
59
  autoload :RemoteIp
@@ -64,7 +63,7 @@ module ActionDispatch
64
63
  end
65
64
 
66
65
  autoload :Journey
67
- autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
66
+ autoload :MiddlewareStack, "action_dispatch/middleware/stack"
68
67
  autoload :Routing
69
68
 
70
69
  module Http
@@ -76,31 +75,33 @@ module ActionDispatch
76
75
  autoload :Parameters
77
76
  autoload :ParameterFilter
78
77
  autoload :Upload
79
- autoload :UploadedFile, 'action_dispatch/http/upload'
78
+ autoload :UploadedFile, "action_dispatch/http/upload"
80
79
  autoload :URL
81
80
  end
82
81
 
83
82
  module Session
84
- autoload :AbstractStore, 'action_dispatch/middleware/session/abstract_store'
85
- autoload :CookieStore, 'action_dispatch/middleware/session/cookie_store'
86
- autoload :MemCacheStore, 'action_dispatch/middleware/session/mem_cache_store'
87
- autoload :CacheStore, 'action_dispatch/middleware/session/cache_store'
83
+ autoload :AbstractStore, "action_dispatch/middleware/session/abstract_store"
84
+ autoload :CookieStore, "action_dispatch/middleware/session/cookie_store"
85
+ autoload :MemCacheStore, "action_dispatch/middleware/session/mem_cache_store"
86
+ autoload :CacheStore, "action_dispatch/middleware/session/cache_store"
88
87
  end
89
88
 
90
89
  mattr_accessor :test_app
91
90
 
92
- autoload_under 'testing' do
91
+ autoload_under "testing" do
93
92
  autoload :Assertions
94
93
  autoload :Integration
95
- autoload :IntegrationTest, 'action_dispatch/testing/integration'
94
+ autoload :IntegrationTest, "action_dispatch/testing/integration"
96
95
  autoload :TestProcess
97
96
  autoload :TestRequest
98
97
  autoload :TestResponse
99
98
  autoload :AssertionResponse
100
99
  end
100
+
101
+ autoload :SystemTestCase, "action_dispatch/system_test_case"
101
102
  end
102
103
 
103
- autoload :Mime, 'action_dispatch/http/mime_type'
104
+ autoload :Mime, "action_dispatch/http/mime_type"
104
105
 
105
106
  ActiveSupport.on_load(:action_view) do
106
107
  ActionView::Base.default_formats ||= Mime::SET.symbols
@@ -2,9 +2,8 @@ module ActionDispatch
2
2
  module Http
3
3
  module Cache
4
4
  module Request
5
-
6
- HTTP_IF_MODIFIED_SINCE = 'HTTP_IF_MODIFIED_SINCE'.freeze
7
- HTTP_IF_NONE_MATCH = 'HTTP_IF_NONE_MATCH'.freeze
5
+ HTTP_IF_MODIFIED_SINCE = "HTTP_IF_MODIFIED_SINCE".freeze
6
+ HTTP_IF_NONE_MATCH = "HTTP_IF_NONE_MATCH".freeze
8
7
 
9
8
  def if_modified_since
10
9
  if since = get_header(HTTP_IF_MODIFIED_SINCE)
@@ -27,7 +26,7 @@ module ActionDispatch
27
26
  def etag_matches?(etag)
28
27
  if etag
29
28
  validators = if_none_match_etags
30
- validators.include?(etag) || validators.include?('*')
29
+ validators.include?(etag) || validators.include?("*")
31
30
  end
32
31
  end
33
32
 
@@ -102,11 +101,11 @@ module ActionDispatch
102
101
  end
103
102
 
104
103
  def weak_etag=(weak_validators)
105
- set_header 'ETag', generate_weak_etag(weak_validators)
104
+ set_header "ETag", generate_weak_etag(weak_validators)
106
105
  end
107
106
 
108
107
  def strong_etag=(strong_validators)
109
- set_header 'ETag', generate_strong_etag(strong_validators)
108
+ set_header "ETag", generate_strong_etag(strong_validators)
110
109
  end
111
110
 
112
111
  def etag?; etag; end
@@ -123,7 +122,7 @@ module ActionDispatch
123
122
 
124
123
  private
125
124
 
126
- DATE = 'Date'.freeze
125
+ DATE = "Date".freeze
127
126
  LAST_MODIFIED = "Last-Modified".freeze
128
127
  SPECIAL_KEYS = Set.new(%w[extras no-cache max-age public private must-revalidate])
129
128
 
@@ -137,7 +136,7 @@ module ActionDispatch
137
136
 
138
137
  def cache_control_segments
139
138
  if cache_control = _cache_control
140
- cache_control.delete(' ').split(',')
139
+ cache_control.delete(" ").split(",")
141
140
  else
142
141
  []
143
142
  end
@@ -147,10 +146,10 @@ module ActionDispatch
147
146
  cache_control = {}
148
147
 
149
148
  cache_control_segments.each do |segment|
150
- directive, argument = segment.split('=', 2)
149
+ directive, argument = segment.split("=", 2)
151
150
 
152
151
  if SPECIAL_KEYS.include? directive
153
- key = directive.tr('-', '_')
152
+ key = directive.tr("-", "_")
154
153
  cache_control[key.to_sym] = argument || true
155
154
  else
156
155
  cache_control[:extras] ||= []
@@ -1,4 +1,4 @@
1
- require 'action_dispatch/http/parameter_filter'
1
+ require "action_dispatch/http/parameter_filter"
2
2
 
3
3
  module ActionDispatch
4
4
  module Http
@@ -51,30 +51,30 @@ module ActionDispatch
51
51
  @filtered_path ||= query_string.empty? ? path : "#{path}?#{filtered_query_string}"
52
52
  end
53
53
 
54
- protected
54
+ private
55
55
 
56
- def parameter_filter
56
+ def parameter_filter # :doc:
57
57
  parameter_filter_for fetch_header("action_dispatch.parameter_filter") {
58
58
  return NULL_PARAM_FILTER
59
59
  }
60
60
  end
61
61
 
62
- def env_filter
62
+ def env_filter # :doc:
63
63
  user_key = fetch_header("action_dispatch.parameter_filter") {
64
64
  return NULL_ENV_FILTER
65
65
  }
66
66
  parameter_filter_for(Array(user_key) + ENV_MATCH)
67
67
  end
68
68
 
69
- def parameter_filter_for(filters)
69
+ def parameter_filter_for(filters) # :doc:
70
70
  ParameterFilter.new(filters)
71
71
  end
72
72
 
73
- KV_RE = '[^&;=]+'
73
+ KV_RE = "[^&;=]+"
74
74
  PAIR_RE = %r{(#{KV_RE})=(#{KV_RE})}
75
- def filtered_query_string
75
+ def filtered_query_string # :doc:
76
76
  query_string.gsub(PAIR_RE) do |_|
77
- parameter_filter.filter($1 => $2).first.join("=")
77
+ parameter_filter.filter([[$1, $2]]).first.join("=")
78
78
  end
79
79
  end
80
80
  end
@@ -1,8 +1,7 @@
1
1
  module ActionDispatch
2
2
  module Http
3
3
  module FilterRedirect
4
-
5
- FILTERED = '[FILTERED]'.freeze # :nodoc:
4
+ FILTERED = "[FILTERED]".freeze # :nodoc:
6
5
 
7
6
  def filtered_location # :nodoc:
8
7
  if location_filter_match?
@@ -16,7 +15,7 @@ module ActionDispatch
16
15
 
17
16
  def location_filters
18
17
  if request
19
- request.get_header('action_dispatch.redirect_filter') || []
18
+ request.get_header("action_dispatch.redirect_filter") || []
20
19
  else
21
20
  []
22
21
  end
@@ -31,7 +30,6 @@ module ActionDispatch
31
30
  end
32
31
  end
33
32
  end
34
-
35
33
  end
36
34
  end
37
35
  end
@@ -86,7 +86,7 @@ module ActionDispatch
86
86
  @req.fetch_header(env_name(key)) do
87
87
  return default unless default == DEFAULT
88
88
  return yield if block_given?
89
- raise NameError, key
89
+ raise KeyError, key
90
90
  end
91
91
  end
92
92
 
@@ -115,16 +115,16 @@ module ActionDispatch
115
115
 
116
116
  private
117
117
 
118
- # Converts an HTTP header name to an environment variable name if it is
119
- # not contained within the headers hash.
120
- def env_name(key)
121
- key = key.to_s
122
- if key =~ HTTP_HEADER
123
- key = key.upcase.tr('-', '_')
124
- key = "HTTP_" + key unless CGI_VARIABLES.include?(key)
118
+ # Converts an HTTP header name to an environment variable name if it is
119
+ # not contained within the headers hash.
120
+ def env_name(key)
121
+ key = key.to_s
122
+ if key =~ HTTP_HEADER
123
+ key = key.upcase.tr("-", "_")
124
+ key = "HTTP_" + key unless CGI_VARIABLES.include?(key)
125
+ end
126
+ key
125
127
  end
126
- key
127
- end
128
128
  end
129
129
  end
130
130
  end
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/module/attribute_accessors'
1
+ require "active_support/core_ext/module/attribute_accessors"
2
2
 
3
3
  module ActionDispatch
4
4
  module Http
@@ -16,7 +16,7 @@ module ActionDispatch
16
16
  # X-Post-Data-Format HTTP header if present.
17
17
  def content_mime_type
18
18
  fetch_header("action_dispatch.request.content_type") do |k|
19
- v = if get_header('CONTENT_TYPE') =~ /^([^,\;]*)/
19
+ v = if get_header("CONTENT_TYPE") =~ /^([^,\;]*)/
20
20
  Mime::Type.lookup($1.strip.downcase)
21
21
  else
22
22
  nil
@@ -36,7 +36,7 @@ module ActionDispatch
36
36
  # Returns the accepted MIME type for the request.
37
37
  def accepts
38
38
  fetch_header("action_dispatch.request.accepts") do |k|
39
- header = get_header('HTTP_ACCEPT').to_s.strip
39
+ header = get_header("HTTP_ACCEPT").to_s.strip
40
40
 
41
41
  v = if header.empty?
42
42
  [content_mime_type]
@@ -76,11 +76,6 @@ module ActionDispatch
76
76
  else
77
77
  [Mime[:html]]
78
78
  end
79
-
80
- v = v.select do |format|
81
- format.symbol || format.ref == "*/*"
82
- end
83
-
84
79
  set_header k, v
85
80
  end
86
81
  end
@@ -155,25 +150,25 @@ module ActionDispatch
155
150
  order.include?(Mime::ALL) ? format : nil
156
151
  end
157
152
 
158
- protected
153
+ private
159
154
 
160
- BROWSER_LIKE_ACCEPTS = /,\s*\*\/\*|\*\/\*\s*,/
155
+ BROWSER_LIKE_ACCEPTS = /,\s*\*\/\*|\*\/\*\s*,/
161
156
 
162
- def valid_accept_header
163
- (xhr? && (accept.present? || content_mime_type)) ||
164
- (accept.present? && accept !~ BROWSER_LIKE_ACCEPTS)
165
- end
157
+ def valid_accept_header # :doc:
158
+ (xhr? && (accept.present? || content_mime_type)) ||
159
+ (accept.present? && accept !~ BROWSER_LIKE_ACCEPTS)
160
+ end
166
161
 
167
- def use_accept_header
168
- !self.class.ignore_accept_header
169
- end
162
+ def use_accept_header # :doc:
163
+ !self.class.ignore_accept_header
164
+ end
170
165
 
171
- def format_from_path_extension
172
- path = get_header('action_dispatch.original_path') || get_header('PATH_INFO')
173
- if match = path && path.match(/\.(\w+)\z/)
174
- Mime[match.captures.first]
166
+ def format_from_path_extension # :doc:
167
+ path = get_header("action_dispatch.original_path") || get_header("PATH_INFO")
168
+ if match = path && path.match(/\.(\w+)\z/)
169
+ Mime[match.captures.first]
170
+ end
175
171
  end
176
- end
177
172
  end
178
173
  end
179
174
  end
@@ -1,8 +1,7 @@
1
1
  # -*- frozen-string-literal: true -*-
2
2
 
3
- require 'singleton'
4
- require 'active_support/core_ext/module/attribute_accessors'
5
- require 'active_support/core_ext/string/starts_ends_with'
3
+ require "singleton"
4
+ require "active_support/core_ext/string/starts_ends_with"
6
5
 
7
6
  module Mime
8
7
  class Mimes
@@ -45,32 +44,6 @@ module Mime
45
44
  return type if type.is_a?(Type)
46
45
  EXTENSION_LOOKUP.fetch(type.to_s) { |k| yield k }
47
46
  end
48
-
49
- def const_missing(sym)
50
- ext = sym.downcase
51
- if Mime[ext]
52
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
53
- Accessing mime types via constants is deprecated.
54
- Please change `Mime::#{sym}` to `Mime[:#{ext}]`.
55
- MSG
56
- Mime[ext]
57
- else
58
- super
59
- end
60
- end
61
-
62
- def const_defined?(sym, inherit = true)
63
- ext = sym.downcase
64
- if Mime[ext]
65
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
66
- Accessing mime types via constants is deprecated.
67
- Please change `Mime.const_defined?(#{sym})` to `Mime[:#{ext}]`.
68
- MSG
69
- true
70
- else
71
- super
72
- end
73
- end
74
47
  end
75
48
 
76
49
  # Encapsulates the notion of a mime type. Can be used at render time, for example, with:
@@ -99,7 +72,7 @@ module Mime
99
72
  def initialize(index, name, q = nil)
100
73
  @index = index
101
74
  @name = name
102
- q ||= 0.0 if @name == '*/*'.freeze # default wildcard match to end of list
75
+ q ||= 0.0 if @name == "*/*".freeze # default wildcard match to end of list
103
76
  @q = ((q || 1.0).to_f * 100).to_i
104
77
  end
105
78
 
@@ -114,7 +87,7 @@ module Mime
114
87
  def self.sort!(list)
115
88
  list.sort!
116
89
 
117
- text_xml_idx = find_item_by_name list, 'text/xml'
90
+ text_xml_idx = find_item_by_name list, "text/xml"
118
91
  app_xml_idx = find_item_by_name list, Mime[:xml].to_s
119
92
 
120
93
  # Take care of the broken text/xml entry by renaming or deleting it
@@ -141,7 +114,7 @@ module Mime
141
114
  type = list[idx]
142
115
  break if type.q < app_xml.q
143
116
 
144
- if type.name.ends_with? '+xml'
117
+ if type.name.ends_with? "+xml"
145
118
  list[app_xml_idx], list[idx] = list[idx], app_xml
146
119
  app_xml_idx = idx
147
120
  end
@@ -195,12 +168,12 @@ module Mime
195
168
  end
196
169
 
197
170
  def parse(accept_header)
198
- if !accept_header.include?(',')
171
+ if !accept_header.include?(",")
199
172
  accept_header = accept_header.split(PARAMETER_SEPARATOR_REGEXP).first
200
173
  parse_trailing_star(accept_header) || [Mime::Type.lookup(accept_header)].compact
201
174
  else
202
175
  list, index = [], 0
203
- accept_header.split(',').each do |header|
176
+ accept_header.split(",").each do |header|
204
177
  params, q = header.split(PARAMETER_SEPARATOR_REGEXP)
205
178
 
206
179
  next unless params
@@ -304,33 +277,35 @@ module Mime
304
277
 
305
278
  def all?; false; end
306
279
 
280
+ # TODO Change this to private once we've dropped Ruby 2.2 support.
281
+ # Workaround for Ruby 2.2 "private attribute?" warning.
307
282
  protected
308
283
 
309
- attr_reader :string, :synonyms
284
+ attr_reader :string, :synonyms
310
285
 
311
286
  private
312
287
 
313
- def to_ary; end
314
- def to_a; end
288
+ def to_ary; end
289
+ def to_a; end
315
290
 
316
- def method_missing(method, *args)
317
- if method.to_s.ends_with? '?'
318
- method[0..-2].downcase.to_sym == to_sym
319
- else
320
- super
291
+ def method_missing(method, *args)
292
+ if method.to_s.ends_with? "?"
293
+ method[0..-2].downcase.to_sym == to_sym
294
+ else
295
+ super
296
+ end
321
297
  end
322
- end
323
298
 
324
- def respond_to_missing?(method, include_private = false) #:nodoc:
325
- method.to_s.ends_with? '?'
326
- end
299
+ def respond_to_missing?(method, include_private = false)
300
+ (method.to_s.ends_with? "?") || super
301
+ end
327
302
  end
328
303
 
329
304
  class AllType < Type
330
305
  include Singleton
331
306
 
332
307
  def initialize
333
- super '*/*', :all
308
+ super "*/*", :all
334
309
  end
335
310
 
336
311
  def all?; true; end
@@ -352,14 +327,14 @@ module Mime
352
327
  def ref; end
353
328
 
354
329
  def respond_to_missing?(method, include_private = false)
355
- method.to_s.ends_with? '?'
330
+ method.to_s.ends_with? "?"
356
331
  end
357
332
 
358
333
  private
359
- def method_missing(method, *args)
360
- false if method.to_s.ends_with? '?'
361
- end
334
+ def method_missing(method, *args)
335
+ false if method.to_s.ends_with? "?"
336
+ end
362
337
  end
363
338
  end
364
339
 
365
- require 'action_dispatch/http/mime_types'
340
+ require "action_dispatch/http/mime_types"