roda 2.29.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +52 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +51 -109
  5. data/Rakefile +7 -14
  6. data/doc/conventions.rdoc +4 -4
  7. data/doc/release_notes/1.2.0.txt +1 -1
  8. data/doc/release_notes/3.0.0.txt +84 -0
  9. data/lib/roda.rb +25 -79
  10. data/lib/roda/plugins/assets.rb +25 -58
  11. data/lib/roda/plugins/assets_preloading.rb +0 -5
  12. data/lib/roda/plugins/backtracking_array.rb +0 -5
  13. data/lib/roda/plugins/branch_locals.rb +3 -3
  14. data/lib/roda/plugins/caching.rb +5 -38
  15. data/lib/roda/plugins/chunked.rb +7 -25
  16. data/lib/roda/plugins/class_level_routing.rb +2 -2
  17. data/lib/roda/plugins/content_for.rb +7 -10
  18. data/lib/roda/plugins/cookies.rb +3 -3
  19. data/lib/roda/plugins/csrf.rb +2 -2
  20. data/lib/roda/plugins/delegate.rb +3 -3
  21. data/lib/roda/plugins/drop_body.rb +0 -7
  22. data/lib/roda/plugins/empty_root.rb +0 -3
  23. data/lib/roda/plugins/error_email.rb +4 -6
  24. data/lib/roda/plugins/error_handler.rb +1 -2
  25. data/lib/roda/plugins/error_mail.rb +3 -6
  26. data/lib/roda/plugins/flash.rb +0 -4
  27. data/lib/roda/plugins/h.rb +5 -0
  28. data/lib/roda/plugins/hash_matcher.rb +4 -2
  29. data/lib/roda/plugins/head.rb +5 -7
  30. data/lib/roda/plugins/header_matchers.rb +12 -33
  31. data/lib/roda/plugins/heartbeat.rb +2 -7
  32. data/lib/roda/plugins/indifferent_params.rb +2 -2
  33. data/lib/roda/plugins/json.rb +6 -14
  34. data/lib/roda/plugins/json_parser.rb +2 -13
  35. data/lib/roda/plugins/mailer.rb +29 -39
  36. data/lib/roda/plugins/match_affix.rb +0 -5
  37. data/lib/roda/plugins/middleware.rb +10 -15
  38. data/lib/roda/plugins/multi_route.rb +8 -5
  39. data/lib/roda/plugins/multi_run.rb +1 -0
  40. data/lib/roda/plugins/named_templates.rb +2 -2
  41. data/lib/roda/plugins/optimized_string_matchers.rb +0 -3
  42. data/lib/roda/plugins/padrino_render.rb +6 -9
  43. data/lib/roda/plugins/param_matchers.rb +6 -6
  44. data/lib/roda/plugins/params_capturing.rb +15 -35
  45. data/lib/roda/plugins/partials.rb +3 -8
  46. data/lib/roda/plugins/path.rb +5 -5
  47. data/lib/roda/plugins/path_matchers.rb +3 -3
  48. data/lib/roda/plugins/path_rewriter.rb +4 -9
  49. data/lib/roda/plugins/placeholder_string_matchers.rb +1 -1
  50. data/lib/roda/plugins/precompile_templates.rb +10 -20
  51. data/lib/roda/plugins/public.rb +6 -9
  52. data/lib/roda/plugins/render.rb +50 -171
  53. data/lib/roda/plugins/render_each.rb +4 -7
  54. data/lib/roda/plugins/render_locals.rb +6 -20
  55. data/lib/roda/plugins/request_headers.rb +2 -4
  56. data/lib/roda/plugins/run_append_slash.rb +1 -4
  57. data/lib/roda/plugins/run_handler.rb +4 -7
  58. data/lib/roda/plugins/shared_vars.rb +3 -6
  59. data/lib/roda/plugins/sinatra_helpers.rb +11 -40
  60. data/lib/roda/plugins/slash_path_empty.rb +0 -3
  61. data/lib/roda/plugins/static.rb +2 -2
  62. data/lib/roda/plugins/static_routing.rb +2 -3
  63. data/lib/roda/plugins/streaming.rb +15 -108
  64. data/lib/roda/plugins/strip_path_prefix.rb +1 -1
  65. data/lib/roda/plugins/symbol_matchers.rb +7 -23
  66. data/lib/roda/plugins/type_routing.rb +4 -9
  67. data/lib/roda/plugins/view_options.rb +10 -66
  68. data/lib/roda/version.rb +2 -2
  69. data/spec/all.rb +0 -2
  70. data/spec/composition_spec.rb +1 -1
  71. data/spec/env_spec.rb +1 -1
  72. data/spec/freeze_spec.rb +1 -1
  73. data/spec/integration_spec.rb +1 -1
  74. data/spec/matchers_spec.rb +26 -70
  75. data/spec/opts_spec.rb +1 -1
  76. data/spec/plugin/all_verbs_spec.rb +1 -1
  77. data/spec/plugin/assets_preloading_spec.rb +1 -1
  78. data/spec/plugin/assets_spec.rb +43 -27
  79. data/spec/plugin/backtracking_array_spec.rb +1 -1
  80. data/spec/plugin/branch_locals_spec.rb +1 -1
  81. data/spec/plugin/caching_spec.rb +1 -1
  82. data/spec/plugin/chunked_spec.rb +1 -1
  83. data/spec/plugin/class_level_routing_spec.rb +1 -1
  84. data/spec/plugin/class_matchers_spec.rb +1 -1
  85. data/spec/plugin/content_for_spec.rb +2 -7
  86. data/spec/plugin/cookies_spec.rb +1 -1
  87. data/spec/plugin/csrf_spec.rb +1 -1
  88. data/spec/plugin/default_headers_spec.rb +1 -1
  89. data/spec/plugin/default_status_spec.rb +1 -1
  90. data/spec/plugin/delay_build_spec.rb +1 -1
  91. data/spec/plugin/delegate_spec.rb +1 -1
  92. data/spec/plugin/delete_empty_headers_spec.rb +1 -1
  93. data/spec/plugin/disallow_file_uploads_spec.rb +2 -2
  94. data/spec/plugin/drop_body_spec.rb +1 -1
  95. data/spec/plugin/empty_root_spec.rb +1 -1
  96. data/spec/plugin/environments_spec.rb +1 -1
  97. data/spec/plugin/error_email_spec.rb +1 -1
  98. data/spec/plugin/error_handler_spec.rb +1 -1
  99. data/spec/plugin/error_mail_spec.rb +2 -2
  100. data/spec/plugin/flash_spec.rb +1 -1
  101. data/spec/plugin/h_spec.rb +1 -1
  102. data/spec/plugin/halt_spec.rb +2 -2
  103. data/spec/plugin/hash_matcher_spec.rb +1 -1
  104. data/spec/plugin/head_spec.rb +1 -1
  105. data/spec/plugin/header_matchers_spec.rb +4 -47
  106. data/spec/plugin/heartbeat_spec.rb +1 -1
  107. data/spec/plugin/hooks_spec.rb +1 -1
  108. data/spec/plugin/indifferent_params_spec.rb +1 -1
  109. data/spec/plugin/json_parser_spec.rb +12 -1
  110. data/spec/plugin/json_spec.rb +8 -1
  111. data/spec/plugin/mailer_spec.rb +1 -1
  112. data/spec/plugin/match_affix_spec.rb +1 -1
  113. data/spec/plugin/middleware_spec.rb +15 -1
  114. data/spec/plugin/module_include_spec.rb +1 -1
  115. data/spec/plugin/multi_route_spec.rb +5 -3
  116. data/spec/plugin/multi_run_spec.rb +1 -1
  117. data/spec/plugin/multi_view_spec.rb +1 -1
  118. data/spec/plugin/named_templates_spec.rb +1 -1
  119. data/spec/plugin/not_allowed_spec.rb +1 -1
  120. data/spec/plugin/not_found_spec.rb +1 -1
  121. data/spec/plugin/optimized_string_matchers_spec.rb +1 -1
  122. data/spec/plugin/padrino_render_spec.rb +1 -1
  123. data/spec/plugin/param_matchers_spec.rb +1 -1
  124. data/spec/plugin/params_capturing_spec.rb +6 -22
  125. data/spec/plugin/partials_spec.rb +1 -1
  126. data/spec/plugin/pass_spec.rb +1 -1
  127. data/spec/plugin/path_matchers_spec.rb +1 -1
  128. data/spec/plugin/path_rewriter_spec.rb +1 -1
  129. data/spec/plugin/path_spec.rb +1 -1
  130. data/spec/plugin/placeholder_string_matchers_spec.rb +3 -36
  131. data/spec/plugin/precompile_templates_spec.rb +1 -17
  132. data/spec/plugin/public_spec.rb +3 -4
  133. data/spec/plugin/render_each_spec.rb +1 -1
  134. data/spec/plugin/render_locals_spec.rb +1 -1
  135. data/spec/plugin/render_spec.rb +28 -114
  136. data/spec/plugin/request_headers_spec.rb +1 -1
  137. data/spec/plugin/response_request_spec.rb +1 -1
  138. data/spec/plugin/run_append_slash_spec.rb +1 -1
  139. data/spec/plugin/run_handler_spec.rb +1 -1
  140. data/spec/plugin/shared_vars_spec.rb +1 -1
  141. data/spec/plugin/sinatra_helpers_spec.rb +1 -1
  142. data/spec/plugin/slash_path_empty_spec.rb +1 -1
  143. data/spec/plugin/static_routing_spec.rb +1 -1
  144. data/spec/plugin/static_spec.rb +1 -1
  145. data/spec/plugin/status_303_spec.rb +1 -1
  146. data/spec/plugin/status_handler_spec.rb +1 -1
  147. data/spec/plugin/streaming_spec.rb +1 -106
  148. data/spec/plugin/strip_path_prefix_spec.rb +1 -1
  149. data/spec/plugin/symbol_matchers_spec.rb +1 -77
  150. data/spec/plugin/symbol_status_spec.rb +1 -1
  151. data/spec/plugin/symbol_views_spec.rb +1 -1
  152. data/spec/plugin/type_routing_spec.rb +1 -1
  153. data/spec/plugin/unescape_path_spec.rb +1 -1
  154. data/spec/plugin/view_options_spec.rb +16 -110
  155. data/spec/plugin_spec.rb +1 -1
  156. data/spec/redirect_spec.rb +1 -1
  157. data/spec/request_spec.rb +1 -1
  158. data/spec/response_spec.rb +1 -1
  159. data/spec/session_spec.rb +1 -1
  160. data/spec/spec_helper.rb +1 -3
  161. data/spec/version_spec.rb +1 -1
  162. metadata +6 -26
  163. data/lib/roda/plugins/_erubis_escaping.rb +0 -59
  164. data/lib/roda/plugins/per_thread_caching.rb +0 -71
  165. data/lib/roda/plugins/static_path_info.rb +0 -12
  166. data/lib/roda/plugins/view_subdirs.rb +0 -7
  167. data/lib/roda/plugins/websockets.rb +0 -107
  168. data/spec/plugin/_erubis_escaping_spec.rb +0 -97
  169. data/spec/plugin/per_thread_caching_spec.rb +0 -28
  170. data/spec/plugin/websockets_spec.rb +0 -84
@@ -50,11 +50,6 @@ class Roda
50
50
  :js => 'script'.freeze,
51
51
  }.freeze
52
52
 
53
- COMMA = ",".freeze
54
- RodaPlugins.deprecate_constant(self, :COMMA)
55
- NEWLINE= "\n".freeze
56
- RodaPlugins.deprecate_constant(self, :NEWLINE)
57
-
58
53
  # Depend on the assets plugin, as we'll be calling some functions in it.
59
54
  def self.load_dependencies(app)
60
55
  app.plugin :assets
@@ -26,11 +26,6 @@ class Roda
26
26
  # and the match block yields.
27
27
  module BacktrackingArray
28
28
  module RequestMethods
29
- PATH_INFO = "PATH_INFO".freeze
30
- RodaPlugins.deprecate_constant(self, :PATH_INFO)
31
- SCRIPT_NAME = "SCRIPT_NAME".freeze
32
- RodaPlugins.deprecate_constant(self, :SCRIPT_NAME)
33
-
34
29
  private
35
30
 
36
31
  # When matching for a single array, after a successful
@@ -7,13 +7,13 @@ class Roda
7
7
  # locals for specific branches and routes.
8
8
  #
9
9
  # plugin :render
10
- # plugin :render_locals, :render=>{:footer=>'Default'}, :layout=>{:title=>'Main'}
10
+ # plugin :render_locals, render: {footer: 'Default'}, layout: {title: 'Main'}
11
11
  # plugin :branch_locals
12
12
  #
13
13
  # route do |r|
14
14
  # r.on "users" do
15
- # set_layout_locals :title=>'Users'
16
- # set_view_locals :footer=>'(c) Roda'
15
+ # set_layout_locals title: 'Users'
16
+ # set_view_locals footer: '(c) Roda'
17
17
  # end
18
18
  # end
19
19
  #
@@ -31,14 +31,14 @@ class Roda
31
31
  # response methods. The +cache_control+ method sets the
32
32
  # Cache-Control header using the given hash:
33
33
  #
34
- # response.cache_control :public=>true, :max_age=>60
34
+ # response.cache_control public: true, max_age: 60
35
35
  # # Cache-Control: public, max-age=60
36
36
  #
37
37
  # The +expires+ method is similar, but in addition
38
38
  # to setting the HTTP 1.1 Cache-Control header, it also sets
39
39
  # the HTTP 1.0 Expires header:
40
40
  #
41
- # response.expires 60, :public=>true
41
+ # response.expires 60, public: true
42
42
  # # Cache-Control: public, max-age=60
43
43
  # # Expires: Mon, 29 Sep 2014 21:25:47 GMT
44
44
  #
@@ -69,25 +69,7 @@ class Roda
69
69
  # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
70
70
  # OTHER DEALINGS IN THE SOFTWARE.
71
71
  module Caching
72
- OPTS = {}.freeze
73
- RodaPlugins.deprecate_constant(self, :OPTS)
74
-
75
72
  module RequestMethods
76
- LAST_MODIFIED = 'Last-Modified'.freeze
77
- RodaPlugins.deprecate_constant(self, :LAST_MODIFIED)
78
- HTTP_IF_NONE_MATCH = 'HTTP_IF_NONE_MATCH'.freeze
79
- RodaPlugins.deprecate_constant(self, :HTTP_IF_NONE_MATCH)
80
- HTTP_IF_MATCH = 'HTTP_IF_MATCH'.freeze
81
- RodaPlugins.deprecate_constant(self, :HTTP_IF_MATCH)
82
- HTTP_IF_MODIFIED_SINCE = 'HTTP_IF_MODIFIED_SINCE'.freeze
83
- RodaPlugins.deprecate_constant(self, :HTTP_IF_MODIFIED_SINCE)
84
- HTTP_IF_UNMODIFIED_SINCE = 'HTTP_IF_UNMODIFIED_SINCE'.freeze
85
- RodaPlugins.deprecate_constant(self, :HTTP_IF_UNMODIFIED_SINCE)
86
- ETAG = 'ETag'.freeze
87
- RodaPlugins.deprecate_constant(self, :ETAG)
88
- STAR = '*'.freeze
89
- RodaPlugins.deprecate_constant(self, :STAR)
90
-
91
73
  # Set the last modified time of the resource using the Last-Modified header.
92
74
  # The +time+ argument should be a Time instance.
93
75
  #
@@ -131,7 +113,7 @@ class Roda
131
113
  #
132
114
  # When the current request includes an If-Match header with a
133
115
  # etag that doesn't match, immediately returns a response with a 412 status.
134
- def etag(value, opts=RodaPlugins::OPTS)
116
+ def etag(value, opts=OPTS)
135
117
  # Before touching this code, please double check RFC 2616 14.24 and 14.26.
136
118
  weak = opts[:weak]
137
119
  new_resource = opts.fetch(:new_resource){post?}
@@ -174,27 +156,12 @@ class Roda
174
156
  end
175
157
 
176
158
  module ResponseMethods
177
- UNDERSCORE = '_'.freeze
178
- RodaPlugins.deprecate_constant(self, :UNDERSCORE)
179
- DASH = '-'.freeze
180
- RodaPlugins.deprecate_constant(self, :DASH)
181
- COMMA = ', '.freeze
182
- RodaPlugins.deprecate_constant(self, :COMMA)
183
- CACHE_CONTROL = 'Cache-Control'.freeze
184
- RodaPlugins.deprecate_constant(self, :CACHE_CONTROL)
185
- EXPIRES = 'Expires'.freeze
186
- RodaPlugins.deprecate_constant(self, :EXPIRES)
187
- CONTENT_TYPE = 'Content-Type'.freeze
188
- RodaPlugins.deprecate_constant(self, :CONTENT_TYPE)
189
- CONTENT_LENGTH = 'Content-Length'.freeze
190
- RodaPlugins.deprecate_constant(self, :CONTENT_LENGTH)
191
-
192
159
  # Specify response freshness policy for using the Cache-Control header.
193
160
  # Options can can any non-value directives (:public, :private, :no_cache,
194
161
  # :no_store, :must_revalidate, :proxy_revalidate), with true as the value.
195
162
  # Options can also contain value directives (:max_age, :s_maxage).
196
163
  #
197
- # response.cache_control :public=>true, :max_age => 60
164
+ # response.cache_control public: true, max_age: 60
198
165
  # # => Cache-Control: public, max-age=60
199
166
  #
200
167
  # See RFC 2616 / 14.9 for more on standard cache control directives:
@@ -214,7 +181,7 @@ class Roda
214
181
  # be an integer number of seconds that the current request should be
215
182
  # cached for. Also sets the Expires header, useful if you have
216
183
  # HTTP 1.0 clients (Cache-Control is an HTTP 1.1 header).
217
- def expires(max_age, opts=RodaPlugins::OPTS)
184
+ def expires(max_age, opts=OPTS)
218
185
  cache_control(Hash[opts].merge!(:max_age=>max_age))
219
186
  self['Expires'] = (Time.now + max_age).httpdate
220
187
  end
@@ -60,7 +60,7 @@ class Roda
60
60
  # If you want to chunk all responses, pass the :chunk_by_default option
61
61
  # when loading the plugin:
62
62
  #
63
- # plugin :chunked, :chunk_by_default => true
63
+ # plugin :chunked, chunk_by_default: true
64
64
  #
65
65
  # then you can just use the normal view method:
66
66
  #
@@ -104,10 +104,10 @@ class Roda
104
104
  # <% flush %><%= render(:subtemplate) %>
105
105
  #
106
106
  # If you want to use chunked encoding when rendering a template, but don't
107
- # want to use a layout, pass the :layout=>false option to chunked.
107
+ # want to use a layout, pass the <tt>layout: false</tt> option to chunked.
108
108
  #
109
109
  # r.root do
110
- # chunked(:index, :layout=>false)
110
+ # chunked(:index, layout: false)
111
111
  # end
112
112
  #
113
113
  # In order to handle errors in chunked responses, you can override the
@@ -133,7 +133,7 @@ class Roda
133
133
  # X-Accel-Buffering header. To set this header or similar headers for
134
134
  # all chunked responses, pass a :headers option when loading the plugin:
135
135
  #
136
- # plugin :chunked, :headers=>{'X-Accel-Buffering'=>'no'}
136
+ # plugin :chunked, headers: {'X-Accel-Buffering'=>'no'}
137
137
  #
138
138
  # The chunked plugin requires the render plugin, and only works for
139
139
  # template engines that store their template output variable in
@@ -145,26 +145,15 @@ class Roda
145
145
  # method is not called until template rendering, the flash may not be
146
146
  # rotated.
147
147
  module Chunked
148
- OPTS = {}.freeze
149
- RodaPlugins.deprecate_constant(self, :OPTS)
150
- HTTP_VERSION = 'HTTP_VERSION'.freeze
151
- RodaPlugins.deprecate_constant(self, :HTTP_VERSION)
152
- HTTP11 = "HTTP/1.1".freeze
153
- RodaPlugins.deprecate_constant(self, :HTTP11)
154
- TRANSFER_ENCODING = 'Transfer-Encoding'.freeze
155
- RodaPlugins.deprecate_constant(self, :TRANSFER_ENCODING)
156
- CHUNKED = 'chunked'.freeze
157
- RodaPlugins.deprecate_constant(self, :CHUNKED)
158
-
159
148
  # Depend on the render plugin
160
- def self.load_dependencies(app, opts=RodaPlugins::OPTS)
149
+ def self.load_dependencies(app, opts=OPTS)
161
150
  app.plugin :render
162
151
  end
163
152
 
164
153
  # Set plugin specific options. Options:
165
154
  # :chunk_by_default :: chunk all calls to view by default
166
155
  # :headers :: Set default additional headers to use when calling view
167
- def self.configure(app, opts=RodaPlugins::OPTS)
156
+ def self.configure(app, opts=OPTS)
168
157
  app.opts[:chunk_by_default] = opts[:chunk_by_default]
169
158
  if opts[:headers]
170
159
  app.opts[:chunk_headers] = (app.opts[:chunk_headers] || {}).merge(opts[:headers]).freeze
@@ -173,13 +162,6 @@ class Roda
173
162
 
174
163
  # Rack response body instance for chunked responses
175
164
  class Body
176
- CHUNK_SIZE = "%x\r\n".freeze
177
- RodaPlugins.deprecate_constant(self, :CHUNK_SIZE)
178
- CRLF = "\r\n".freeze
179
- RodaPlugins.deprecate_constant(self, :CRLF)
180
- FINISH = "0\r\n\r\n".freeze
181
- RodaPlugins.deprecate_constant(self, :FINISH)
182
-
183
165
  # Save the scope of the current request handling.
184
166
  def initialize(scope)
185
167
  @scope = scope
@@ -221,7 +203,7 @@ class Roda
221
203
 
222
204
  # Render a response to the user in chunks. See Chunked for
223
205
  # an overview. If a block is given, it is passed to #delay.
224
- def chunked(template, opts=RodaPlugins::OPTS, &block)
206
+ def chunked(template, opts=OPTS, &block)
225
207
  unless defined?(@_chunked)
226
208
  @_chunked = env['HTTP_VERSION'] == "HTTP/1.1"
227
209
  end
@@ -43,7 +43,7 @@ class Roda
43
43
  # end
44
44
  # end
45
45
  #
46
- # When using the the class_level_routing plugin with nested routes, you may also want to use the
46
+ # When using the class_level_routing plugin with nested routes, you may also want to use the
47
47
  # delegate plugin to delegate certain instance methods to the request object, so you don't have
48
48
  # to continually use +request.+ in your routing blocks.
49
49
  #
@@ -90,7 +90,7 @@ class Roda
90
90
  super do |r|
91
91
  opts[:class_level_routes].each do |meth, args, blk|
92
92
  req.instance_variable_set(:@remaining_path, rp)
93
- r.send(meth, *args) do |*a|
93
+ r.public_send(meth, *args) do |*a|
94
94
  instance_exec(*a, &blk)
95
95
  end
96
96
  end
@@ -28,23 +28,23 @@ class Roda
28
28
  # <%= content_for :foo %>
29
29
  #
30
30
  # If content_for is used multiple times with the same key,
31
- # by default, the last call will override previous calls.
32
- # If you want to append to the content, pass the :append
33
- # option when loading the plugin:
31
+ # by default, the last call will append previous calls.
32
+ # If you want to overwrite the previous content, pass the
33
+ # <tt>append: false</tt> option when loading the plugin:
34
34
  #
35
- # plugin :content_for, :append=>true
35
+ # plugin :content_for, append: false
36
36
  module ContentFor
37
37
  # Depend on the render plugin, since this plugin only makes
38
38
  # sense when the render plugin is used.
39
- def self.load_dependencies(app, _opts = {})
39
+ def self.load_dependencies(app, _opts = OPTS)
40
40
  app.plugin :render
41
41
  end
42
42
 
43
43
  # Configure whether to append or overwrite if content_for
44
44
  # is called multiple times to set data. Overwrite is default, use
45
45
  # the :append option to append.
46
- def self.configure(app, opts = {})
47
- app.opts[:append_content_for] = opts.fetch(:append, nil)
46
+ def self.configure(app, opts = OPTS)
47
+ app.opts[:append_content_for] = opts.fetch(:append, true)
48
48
  end
49
49
 
50
50
  module InstanceMethods
@@ -71,9 +71,6 @@ class Roda
71
71
  if append
72
72
  (@_content_for[key] ||= []) << value
73
73
  else
74
- if @_content_for[key] && append.nil?
75
- RodaPlugins.warn "Attempt to set content_for with same key. This currently overwrites the existing content_for for #{key}. In Roda 3, it will start appending to the existing content_for by default. Use the :append => false option to the content_for plugin to keep the existing behavior."
76
- end
77
74
  @_content_for[key] = value
78
75
  end
79
76
  elsif @_content_for && (value = @_content_for[key])
@@ -14,7 +14,7 @@ class Roda
14
14
  # defaults for all cookies upon setting and deleting. This is particularly
15
15
  # useful for configuring the +domain+ and +path+ of all cookies.
16
16
  #
17
- # plugin :cookies, :domain=>'example.com', :path=>'/api'
17
+ # plugin :cookies, domain: 'example.com', path: '/api'
18
18
  module Cookies
19
19
  # Allow setting default cookie options when loading the cookies plugin.
20
20
  def self.configure(app, opts={})
@@ -28,7 +28,7 @@ class Roda
28
28
  # Example:
29
29
  #
30
30
  # response.delete_cookie('foo')
31
- # response.delete_cookie('foo', :domain=>'example.org')
31
+ # response.delete_cookie('foo', domain: 'example.org')
32
32
  def delete_cookie(key, value = {})
33
33
  ::Rack::Utils.delete_cookie_header!(@headers, key, roda_class.opts[:cookies_opts].merge(value))
34
34
  end
@@ -36,7 +36,7 @@ class Roda
36
36
  # Set the cookie with the given key in the headers.
37
37
  #
38
38
  # response.set_cookie('foo', 'bar')
39
- # response.set_cookie('foo', :value=>'bar', :domain=>'example.org')
39
+ # response.set_cookie('foo', value: 'bar', domain: 'example.org')
40
40
  def set_cookie(key, value)
41
41
  value = { :value=>value } unless value.respond_to?(:keys)
42
42
  ::Rack::Utils.set_cookie_header!(@headers, key, roda_class.opts[:cookies_opts].merge(value))
@@ -8,12 +8,12 @@ class Roda
8
8
  # some csrf helper methods to use in your views. To use it, load
9
9
  # the plugin, with the options hash passed to Rack::Csrf:
10
10
  #
11
- # plugin :csrf, :raise=>true
11
+ # plugin :csrf, raise: true
12
12
  #
13
13
  # Optionally you can choose not to setup rack_csrf middleware on the
14
14
  # roda app if you already have one configured:
15
15
  #
16
- # plugin :csrf, :skip_middleware=>true
16
+ # plugin :csrf, skip_middleware: true
17
17
  #
18
18
  # This adds the following instance methods:
19
19
  #
@@ -52,21 +52,21 @@ class Roda
52
52
  # Delegate the given methods to the class
53
53
  def class_delegate(*meths)
54
54
  meths.each do |meth|
55
- define_method(meth){|*a, &block| self.class.send(meth, *a, &block)}
55
+ define_method(meth){|*a, &block| self.class.public_send(meth, *a, &block)}
56
56
  end
57
57
  end
58
58
 
59
59
  # Delegate the given methods to the request
60
60
  def request_delegate(*meths)
61
61
  meths.each do |meth|
62
- define_method(meth){|*a, &block| @_request.send(meth, *a, &block)}
62
+ define_method(meth){|*a, &block| @_request.public_send(meth, *a, &block)}
63
63
  end
64
64
  end
65
65
 
66
66
  # Delegate the given methods to the response
67
67
  def response_delegate(*meths)
68
68
  meths.each do |meth|
69
- define_method(meth){|*a, &block| @_response.send(meth, *a, &block)}
69
+ define_method(meth){|*a, &block| @_response.public_send(meth, *a, &block)}
70
70
  end
71
71
  end
72
72
  end
@@ -12,13 +12,6 @@ class Roda
12
12
  module ResponseMethods
13
13
  DROP_BODY_STATUSES = [100, 101, 102, 204, 205, 304].freeze
14
14
 
15
- EMPTY_BODY = [].freeze
16
- RodaPlugins.deprecate_constant(self, :EMPTY_BODY)
17
- CONTENT_LENGTH = "Content-Length".freeze
18
- RodaPlugins.deprecate_constant(self, :CONTENT_LENGTH)
19
- CONTENT_TYPE = "Content-Type".freeze
20
- RodaPlugins.deprecate_constant(self, :CONTENT_TYPE)
21
-
22
15
  # If the response status indicates a body should not be
23
16
  # returned, use an empty body and remove the Content-Length
24
17
  # and Content-Type headers.
@@ -31,9 +31,6 @@ class Roda
31
31
  # matches only when the current PATH_INFO is +/+ and not when
32
32
  # it is empty.
33
33
  module EmptyRoot
34
- EMPTY_STRING = ''.freeze
35
- RodaPlugins.deprecate_constant(self, :EMPTY_STRING)
36
-
37
34
  module RequestMethods
38
35
  # Match when the remaining path is the empty string,
39
36
  # in addition to the default behavior of matching when
@@ -8,7 +8,7 @@ class Roda
8
8
  # send an email related to the exception. This is most useful if you are
9
9
  # also using the error_handler plugin:
10
10
  #
11
- # plugin :error_email, :to=>'to@example.com', :from=>'from@example.com'
11
+ # plugin :error_email, to: 'to@example.com', from: 'from@example.com'
12
12
  # plugin :error_handler do |e|
13
13
  # error_email(e)
14
14
  # 'Internal Server Error'
@@ -37,10 +37,8 @@ class Roda
37
37
  # for low traffic web applications. For high traffic web applications,
38
38
  # use an error reporting service instead of this plugin.
39
39
  module ErrorEmail
40
- OPTS = {}.freeze
41
- RodaPlugins.deprecate_constant(self, :OPTS)
42
40
  DEFAULTS = {
43
- :headers=>RodaPlugins::OPTS,
41
+ :headers=>OPTS,
44
42
  :host=>'localhost',
45
43
  # :nocov:
46
44
  :emailer=>lambda{|h| Net::SMTP.start(h[:host]){|s| s.send_message(h[:message], h[:from], h[:to])}},
@@ -95,10 +93,10 @@ END
95
93
 
96
94
  message
97
95
  end
98
- }#.freeze # RODA3
96
+ }.freeze
99
97
 
100
98
  # Set default opts for plugin. See ErrorEmail module RDoc for options.
101
- def self.configure(app, opts=RodaPlugins::OPTS)
99
+ def self.configure(app, opts=OPTS)
102
100
  email_opts = app.opts[:error_email] ||= DEFAULTS
103
101
  email_opts = email_opts.merge(opts)
104
102
  email_opts[:headers] = email_opts[:headers].dup
@@ -30,12 +30,11 @@ class Roda
30
30
  # as well set headers and/or write to the body, just like a regular
31
31
  # request.
32
32
  #
33
- #
34
33
  # By default, this plugin handles StandardError and ScriptError.
35
34
  # To override the exception classes it will handle, pass a :classes
36
35
  # option to the plugin:
37
36
  #
38
- # plugin :error_handler, :classes=>[StandardError, ScriptError, NoMemoryError]
37
+ # plugin :error_handler, classes: [StandardError, ScriptError, NoMemoryError]
39
38
  module ErrorHandler
40
39
  DEFAULT_ERROR_HANDLER_CLASSES = [StandardError, ScriptError].freeze
41
40
 
@@ -8,7 +8,7 @@ class Roda
8
8
  # send an email related to the exception. This is most useful if you are
9
9
  # also using the error_handler plugin:
10
10
  #
11
- # plugin :error_mail, :to=>'to@example.com', :from=>'from@example.com'
11
+ # plugin :error_mail, to: 'to@example.com', from: 'from@example.com'
12
12
  # plugin :error_handler do |e|
13
13
  # error_mail(e)
14
14
  # 'Internal Server Error'
@@ -36,12 +36,9 @@ class Roda
36
36
  # for low traffic web applications. For high traffic web applications,
37
37
  # use an error reporting service instead of this plugin.
38
38
  module ErrorMail
39
- OPTS = {}.freeze
40
- RodaPlugins.deprecate_constant(self, :OPTS)
41
-
42
39
  # Set default opts for plugin. See ErrorEmail module RDoc for options.
43
- def self.configure(app, opts=RodaPlugins::OPTS)
44
- app.opts[:error_mail] = email_opts = (app.opts[:error_mail] || RodaPlugins::OPTS).merge(opts).freeze
40
+ def self.configure(app, opts=OPTS)
41
+ app.opts[:error_mail] = email_opts = (app.opts[:error_mail] || OPTS).merge(opts).freeze
45
42
  unless email_opts[:to] && email_opts[:from]
46
43
  raise RodaError, "must provide :to and :from options to error_mail plugin"
47
44
  end
@@ -36,10 +36,6 @@ class Roda
36
36
  # flash['a'] # = >'b'
37
37
  # end
38
38
  module Flash
39
- # The internal session key used to store the flash.
40
- KEY = :_flash
41
- RodaPlugins.deprecate_constant(self, :KEY)
42
-
43
39
  # Simple flash hash, where assiging to the hash updates the flash
44
40
  # used in the following request.
45
41
  class FlashHash < DelegateClass(Hash)