roda 3.38.0 → 3.39.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b28900f838d40c98d868225a5d2f0e1fcfd24ccf0bdbf770f0ccb79ac2ba2fe
4
- data.tar.gz: 8f2c37b04485af74a1e8c2c68f5eeb31b0531d82b4f55c6df4145cfe344cf86f
3
+ metadata.gz: 4f01105e24f4eae80a69f5734f93d3dfe54b5f6be2489521f1d886053c569102
4
+ data.tar.gz: 2aebf30460c7d5352ee15baf3f884e59dac972e0aadd63aa7ab81445a8a29f65
5
5
  SHA512:
6
- metadata.gz: e2cb67bbc5509acba608530dc8641059cb4aa450f8cf0bdca82f57dabba48c751a50e770f902b0ed64da63d2988c89884e074991a49956d03188ea8efaab7793
7
- data.tar.gz: 66a2ad67a5f4abd5e275f77eddde74f4dd6430c222cf208d9aafc01577fbfae548367f8b71864834cb4067ae530ece68df66165c4352bfc151b35bee8c5e2041
6
+ metadata.gz: d3fd374b3d700106ca814fff8f2dd0c66a3295955f27a453ef5d9fb2ba7fdea583d76ce82f91efb8e2ebcbb97a07e664f3f008689d51eb67ae39aebdd86a5d0e
7
+ data.tar.gz: 59c34c88ab1e5a5bc5017d46707a530c7cd002f4262c30751ba6429983b32477b813d83ada45a19873be711d1d2bd0abd95fe2a5c44c01038ad4a32dbb8f276d
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ = 3.39.0 (2020-12-15)
2
+
3
+ * Speed up relative_path plugin if relative_path or relative_prefix is called more than once (jeremyevans)
4
+
5
+ * Avoid method redefinition warnings in verbose warning mode (jeremyevans)
6
+
7
+ * Make typecast_params.convert! handle explicit nil values the same as missing values (jeremyevans)
8
+
1
9
  = 3.38.0 (2020-11-16)
2
10
 
3
11
  * Make error_email and error_mail plugins rescue invalid parameter errors when preparing the email body (jeremyevans)
@@ -248,7 +248,7 @@
248
248
  Note that if there are multiple conversion errors raised inside a
249
249
  convert! or convert_each! block, they are recorded and a single
250
250
  Roda::RodaPlugins::TypecastParams::Error instance is raised after
251
- processing the block. TypecastParams::Error#params_names can be
251
+ processing the block. TypecastParams::Error#param_names can be
252
252
  called on the exception to get an array of all parameter names
253
253
  with conversion issues, and TypecastParams::Error#all_errors
254
254
  can be used to get an array of all Error instances.
@@ -0,0 +1,16 @@
1
+ = Improvements
2
+
3
+ * The relative_path plugin is now faster if you are calling
4
+ relative_path or relative_prefix more than once when handling a
5
+ request.
6
+
7
+ * The typecast_params.convert! method in the typecast_params plugin
8
+ now handles explicit nil values the same as missing values.
9
+ Explicit nil values do not generally occur in normal Rack parameter
10
+ parsing, but they can occur when using the json_parser plugin to
11
+ parse JSON requests.
12
+
13
+ * Roda now avoids method redefinition warnings in verbose mode by
14
+ using a self alias. As Ruby 3 is dropping uninitialized instance
15
+ variable warnings, Roda will be verbose warning free if you are
16
+ using Ruby 3.
@@ -114,6 +114,7 @@ class Roda
114
114
  alias_method meth, temp_method
115
115
  undef_method temp_method
116
116
  private meth
117
+ alias_method meth, meth
117
118
  meth = :"#{meth}_arity"
118
119
  elsif required_args > 1
119
120
  b = block
@@ -144,6 +145,7 @@ class Roda
144
145
 
145
146
  define_method(meth, &block)
146
147
  private meth
148
+ alias_method meth, meth
147
149
 
148
150
  if arity_meth
149
151
  required_args, optional_args, rest, keyword = _define_roda_method_arg_numbers(instance_method(meth))
@@ -167,6 +169,7 @@ class Roda
167
169
  send(meth, *a)
168
170
  end
169
171
  private arity_meth
172
+ alias_method arity_meth, arity_meth
170
173
  end
171
174
 
172
175
  call_meth
@@ -199,6 +202,7 @@ class Roda
199
202
 
200
203
  private
201
204
 
205
+ alias set_default_headers set_default_headers
202
206
  def set_default_headers
203
207
  @headers['Content-Type'] ||= 'text/html'
204
208
  end
@@ -403,6 +407,7 @@ class Roda
403
407
  class_eval("def _roda_before; #{meths.join(';')} end", __FILE__, __LINE__)
404
408
  end
405
409
  private :_roda_before
410
+ alias_method :_roda_before, :_roda_before
406
411
  end
407
412
  end
408
413
 
@@ -419,6 +424,7 @@ class Roda
419
424
  class_eval("def _roda_after(res); #{meths.map{|s| "#{s}(res)"}.join(';')} end", __FILE__, __LINE__)
420
425
  end
421
426
  private :_roda_after
427
+ alias_method :_roda_after, :_roda_after
422
428
  end
423
429
  end
424
430
 
@@ -33,6 +33,7 @@ class Roda
33
33
  response_class.class_eval(<<-END, __FILE__, __LINE__+1)
34
34
  private
35
35
 
36
+ alias set_default_headers set_default_headers
36
37
  def set_default_headers
37
38
  h = @headers
38
39
  #{headers.map{|k,v| "h[#{k.inspect}] ||= #{v.inspect}"}.join('; ')}
@@ -476,6 +476,8 @@ class Roda
476
476
 
477
477
  undef_method :match_rcpt
478
478
  undef_method :match_text
479
+ undef_method :match_body
480
+ undef_method :match_subject
479
481
 
480
482
  # Same as +header+, but also mark the message as being handled.
481
483
  def handle_header(key, value=nil)
@@ -41,6 +41,7 @@ class Roda
41
41
  # Return a relative prefix to append to an absolute path to a relative path
42
42
  # based on the current path of the request.
43
43
  def relative_prefix
44
+ return @_relative_prefix if @_relative_prefix
44
45
  env = @_request.env
45
46
  script_name = env["SCRIPT_NAME"]
46
47
  path_info = env["PATH_INFO"]
@@ -50,16 +51,16 @@ class Roda
50
51
  case script_name.getbyte(0)
51
52
  when nil # SCRIPT_NAME empty
52
53
  unless path_info.getbyte(0) == 47 # PATH_INFO starts with /
53
- return ''
54
+ return(@_relative_prefix = '')
54
55
  end
55
56
  when 47 # SCRIPT_NAME starts with /
56
57
  # nothing
57
58
  else
58
- return ''
59
+ return(@_relative_prefix = '')
59
60
  end
60
61
 
61
62
  slash_count = script_name.count('/') + path_info.count('/')
62
- if slash_count > 1
63
+ @_relative_prefix = if slash_count > 1
63
64
  ("../" * (slash_count - 2)) << ".."
64
65
  else
65
66
  "."
@@ -106,7 +106,7 @@ class Roda
106
106
  # :template_block :: Pass this block when creating the underlying template,
107
107
  # ignored when using :inline. Disables caching of the
108
108
  # template by default.
109
- # :template_class :: Provides the template class to use, inside of using
109
+ # :template_class :: Provides the template class to use, instead of using
110
110
  # Tilt or <tt>Tilt[:engine]</tt>.
111
111
  #
112
112
  # Here's an example of using these options:
@@ -141,6 +141,7 @@ class Roda
141
141
  app::RodaRequest.send(:define_method, type) do |&block|
142
142
  on_type(type, &block)
143
143
  end
144
+ app::RodaRequest.send(:alias_method, type, type)
144
145
  end
145
146
 
146
147
  app.opts[:type_routing] = config.freeze
@@ -229,7 +229,7 @@ class Roda
229
229
  #
230
230
  # Note that if there are multiple conversion Error raised inside a +convert!+ or +convert_each!+
231
231
  # block, they are recorded and a single TypecastParams::Error instance is raised after
232
- # processing the block. TypecastParams::Error#params_names can be called on the exception to
232
+ # processing the block. TypecastParams::Error#param_names can be called on the exception to
233
233
  # get an array of all parameter names with conversion issues, and TypecastParams::Error#all_errors
234
234
  # can be used to get an array of all Error instances.
235
235
  #
@@ -724,7 +724,7 @@ class Roda
724
724
  raise Error, "parameter #{param_name(nil)} is not a hash" if do_raise
725
725
  return
726
726
  end
727
- present = @obj.has_key?(key)
727
+ present = !@obj[key].nil?
728
728
  when Integer
729
729
  unless @obj.is_a?(Array)
730
730
  raise Error, "parameter #{param_name(nil)} is not an array" if do_raise
@@ -4,7 +4,7 @@ class Roda
4
4
  RodaMajorVersion = 3
5
5
 
6
6
  # The minor version of Roda, updated for new feature releases of Roda.
7
- RodaMinorVersion = 38
7
+ RodaMinorVersion = 39
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.38.0
4
+ version: 3.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2020-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -214,6 +214,7 @@ extra_rdoc_files:
214
214
  - doc/release_notes/3.36.0.txt
215
215
  - doc/release_notes/3.37.0.txt
216
216
  - doc/release_notes/3.38.0.txt
217
+ - doc/release_notes/3.39.0.txt
217
218
  files:
218
219
  - CHANGELOG
219
220
  - MIT-LICENSE
@@ -253,6 +254,7 @@ files:
253
254
  - doc/release_notes/3.36.0.txt
254
255
  - doc/release_notes/3.37.0.txt
255
256
  - doc/release_notes/3.38.0.txt
257
+ - doc/release_notes/3.39.0.txt
256
258
  - doc/release_notes/3.4.0.txt
257
259
  - doc/release_notes/3.5.0.txt
258
260
  - doc/release_notes/3.6.0.txt