roda 3.33.0 → 3.34.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f9ede53406b16bff69c2115f7d35e808835e300ca866a5caadde9b9fad9d206
4
- data.tar.gz: f78eb239a3d15e83879b8a7272f07959a00b6d94e93595f6871841144d3d718b
3
+ metadata.gz: 4ea0324d5667f9dcde48ff8fd1025b15e0e06861eea776019c0be9be8c46b097
4
+ data.tar.gz: 1712241233e21e7863101192227797976a79f6a3f0895da907a9e2b19242e1ed
5
5
  SHA512:
6
- metadata.gz: 45e3020a3509bacc5f39107659fca5e64ba25c322c18af6a62b976308f5bac2ac44a18d54bc82d9b1d4260e260883208ce8210ac2fb660e09b63b65401abfed6
7
- data.tar.gz: 5a00af14f4d6e01c472a23b59f5a51eec66fc55c2d8d34069de869d7ff487913ff6ab1d21023b8207f5fdf18ad6354f30520b3cf89d2491de4b330c1ae30f10a
6
+ metadata.gz: 6b8d1b37ed94ee40c0b1f12cc20ab9f734b276805044b059c9ea10375cc64d7d2cc8b0b36049bd21e29d3e45eeefcc8aeaffe0b4bbaf2d36043c16838270e2eb
7
+ data.tar.gz: 1670e3cde892c8cd42e2856d4e938e6da359d0818ee09f7c28e8ec5f4bc4bd627f3aaa8c48aeac8f6d03ab80994078a5cbce69d99595214f288eb9ab1f860c23
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ = 3.34.0 (2020-07-14)
2
+
3
+ * Remove unnecessary conditionals (jeremyevans)
4
+
5
+ * Allow loading the match_affix plugin with a single argument (jeremyevans)
6
+
7
+ * Do not include pre/post context sections if empty in the exception_page plugin (jeremyevans)
8
+
1
9
  = 3.33.0 (2020-06-16)
2
10
 
3
11
  * Add :brotli option to public plugin to supplement it to serve brotli-compressed files like :gzip does for gzipped files (hmdne) (#194)
@@ -0,0 +1,17 @@
1
+ = Improvements
2
+
3
+ * Multiple unneeded conditionals have been removed.
4
+
5
+ * pre_content and post_context sections in backtraces are no longer
6
+ included in the exception_page plugin output if they would be
7
+ empty.
8
+
9
+ * The match_affix plugin can be loaded again with a single argument.
10
+ It was originally designed to accept a single argument, but a bug
11
+ introduced in 2.29.0 made it require two arguments.
12
+
13
+ * Core Roda and all plugins that ship with Roda now have 100% branch
14
+ coverage.
15
+
16
+ * The sinatra_helpers plugin no longer emits statement not reached
17
+ warnings in verbose mode.
@@ -34,7 +34,9 @@ class Roda
34
34
  module AllVerbs
35
35
  module RequestMethods
36
36
  %w'delete head options link patch put trace unlink'.each do |verb|
37
+ # :nocov:
37
38
  if ::Rack::Request.method_defined?("#{verb}?")
39
+ # :nocov:
38
40
  class_eval(<<-END, __FILE__, __LINE__+1)
39
41
  def #{verb}(*args, &block)
40
42
  _verb(args, &block) if #{verb}?
@@ -33,9 +33,7 @@ class Roda
33
33
  # elements. If the remaining elements could not be
34
34
  # matched, reset the state and continue to the next
35
35
  # entry in the array.
36
- def _match_array(arg, rest=nil)
37
- return super unless rest
38
-
36
+ def _match_array(arg, rest)
39
37
  path = @remaining_path
40
38
  captures = @captures
41
39
  caps = captures.dup
@@ -56,7 +56,6 @@ class Roda
56
56
  # currently have a routing block, setup an empty routing block so that things will still work if
57
57
  # a routing block isn't added.
58
58
  def self.configure(app)
59
- app.route{} unless app.route_block
60
59
  app.opts[:class_level_routes] ||= []
61
60
  end
62
61
 
@@ -1,6 +1,8 @@
1
1
  # frozen-string-literal: true
2
2
 
3
+ # :nocov:
3
4
  raise LoadError, "disallow_file_uploads plugin not supported on Rack <1.6" if Rack.release < '1.6'
5
+ # :nocov:
4
6
 
5
7
  #
6
8
  class Roda
@@ -252,11 +252,21 @@ END
252
252
  begin
253
253
  lineno -= 1
254
254
  lines = ::File.readlines(filename)
255
- pre_lineno = frame[:pre_context_lineno] = [lineno-context, 0].max
256
- frame[:pre_context] = lines[pre_lineno...lineno]
257
- frame[:context_line] = lines[lineno].chomp
258
- post_lineno = frame[:post_context_lineno] = [lineno+context, lines.size].min
259
- frame[:post_context] = lines[lineno+1..post_lineno]
255
+ if line = lines[lineno]
256
+ pre_lineno = [lineno-context, 0].max
257
+ if (pre_context = lines[pre_lineno...lineno]) && !pre_context.empty?
258
+ frame[:pre_context_lineno] = pre_lineno
259
+ frame[:pre_context] = pre_context
260
+ end
261
+
262
+ post_lineno = [lineno+context, lines.size].min
263
+ if (post_context = lines[lineno+1..post_lineno]) && !post_context.empty?
264
+ frame[:post_context_lineno] = post_lineno
265
+ frame[:post_context] = post_context
266
+ end
267
+
268
+ frame[:context_line] = line.chomp
269
+ end
260
270
  rescue
261
271
  end
262
272
 
@@ -28,7 +28,7 @@ class Roda
28
28
  #
29
29
  # This plugin automatically loads the placeholder_string_matchers plugin.
30
30
  module MatchAffix
31
- def self.load_dependencies(app, _prefix, _suffix)
31
+ def self.load_dependencies(app, _prefix, _suffix=nil)
32
32
  app.plugin :placeholder_string_matchers
33
33
  end
34
34
 
@@ -104,7 +104,9 @@ class Roda
104
104
  # arguments, record the verb used. If given an argument, add an is
105
105
  # check with the arguments.
106
106
  %w'get post delete head options link patch put trace unlink'.each do |verb|
107
+ # :nocov:
107
108
  if ::Rack::Request.method_defined?("#{verb}?")
109
+ # :nocov:
108
110
  class_eval(<<-END, __FILE__, __LINE__+1)
109
111
  def #{verb}(*args, &block)
110
112
  if (empty = args.empty?) && @_is_verbs
@@ -110,9 +110,7 @@ class Roda
110
110
  headers = res[1]
111
111
 
112
112
  unless res[0] == 304
113
- if mime_type = ::Rack::Mime.mime_type(::File.extname(path), 'text/plain')
114
- headers['Content-Type'] = mime_type
115
- end
113
+ headers['Content-Type'] = ::Rack::Mime.mime_type(::File.extname(path), 'text/plain')
116
114
  headers['Content-Encoding'] = encoding
117
115
  end
118
116
 
@@ -287,7 +287,9 @@ class Roda
287
287
  false
288
288
  end
289
289
 
290
+ # :nocov:
290
291
  if COMPILED_METHOD_SUPPORT
292
+ # :nocov:
291
293
  # Compile a method in the given module with the given name that will
292
294
  # call the compiled template method, updating the compiled template method
293
295
  def define_compiled_method(roda_class, method_name, locals_keys=EMPTY_ARRAY)
@@ -337,7 +339,9 @@ class Roda
337
339
  def inherited(subclass)
338
340
  super
339
341
  opts = subclass.opts[:render] = subclass.opts[:render].dup
342
+ # :nocov:
340
343
  if COMPILED_METHOD_SUPPORT
344
+ # :nocov:
341
345
  opts[:template_method_cache] = (opts[:cache_class] || RodaCache).new
342
346
  end
343
347
  opts[:cache] = opts[:cache].dup
@@ -43,7 +43,9 @@ class Roda
43
43
  module InstanceMethods
44
44
  private
45
45
 
46
+ # :nocov:
46
47
  if Render::COMPILED_METHOD_SUPPORT
48
+ # :nocov:
47
49
  # Disable use of cached templates, since it assumes a render/view call with no
48
50
  # options will have no locals.
49
51
  def _cached_template_method(template)
@@ -374,7 +374,7 @@ class Roda
374
374
 
375
375
  module ResponseMethods
376
376
  # Set or retrieve the response status code.
377
- def status(value = (return @status; nil))
377
+ def status(value = nil || (return @status))
378
378
  @status = value
379
379
  end
380
380
 
@@ -401,7 +401,7 @@ class Roda
401
401
 
402
402
  # Set multiple response headers with Hash, or return the headers if no
403
403
  # argument is given.
404
- def headers(hash = (return @headers; nil))
404
+ def headers(hash = nil || (return @headers))
405
405
  @headers.merge!(hash)
406
406
  end
407
407
 
@@ -412,7 +412,7 @@ class Roda
412
412
 
413
413
  # Set the Content-Type of the response body given a media type or file
414
414
  # extension. See plugin documentation for options.
415
- def content_type(type = (return @headers["Content-Type"]; nil), opts = OPTS)
415
+ def content_type(type = nil || (return @headers["Content-Type"]), opts = OPTS)
416
416
  unless (mime_type = mime_type(type) || opts[:default])
417
417
  raise RodaError, "Unknown media type: #{type}"
418
418
  end
@@ -478,7 +478,7 @@ class Roda
478
478
  # If a type and value are given, set the value in Rack's MIME registry.
479
479
  # If only a type is given, lookup the type in Rack's MIME registry and
480
480
  # return it.
481
- def mime_type(type=(return; nil), value = nil)
481
+ def mime_type(type=nil || (return), value = nil)
482
482
  return type.to_s if type.to_s.include?('/')
483
483
  type = ".#{type}" unless type.to_s[0] == ?.
484
484
  if value
@@ -742,9 +742,7 @@ class Roda
742
742
  return
743
743
  end
744
744
 
745
- if v = self[key]
746
- v.subkey(keys, do_raise)
747
- end
745
+ self[key].subkey(keys, do_raise)
748
746
  rescue => e
749
747
  handle_error(key, reason, e)
750
748
  end
@@ -808,10 +806,10 @@ class Roda
808
806
  @nested_params = nil
809
807
 
810
808
  if capturing_started
811
- # Unset capturing if capturing was not already started.
809
+ # Unset capturing if capturing was already started.
812
810
  @capture = nil
813
811
  else
814
- # If capturing was already started, update cached nested params
812
+ # If capturing was not already started, update cached nested params
815
813
  # before resetting symbolize setting.
816
814
  @nested_params = nested_params
817
815
  end
@@ -878,7 +876,7 @@ class Roda
878
876
  def handle_error(key, reason, e, do_raise=false)
879
877
  case e
880
878
  when String
881
- handle_error(key, reason, Error.new(e), do_raise=false)
879
+ handle_error(key, reason, Error.new(e), do_raise)
882
880
  when Error, ArgumentError
883
881
  if @capture && (le = @capture.last) && le == e
884
882
  raise e if do_raise
@@ -126,7 +126,9 @@ class Roda
126
126
 
127
127
  private
128
128
 
129
+ # :nocov:
129
130
  if Render::COMPILED_METHOD_SUPPORT
131
+ # :nocov:
130
132
  # Return nil if using custom view or layout options.
131
133
  # If using a view subdir, prefix the template key with the subdir.
132
134
  def _cached_template_method_key(template)
@@ -466,10 +466,8 @@ class Roda
466
466
  rp = @remaining_path
467
467
  if rp.getbyte(0) == 47
468
468
  if last = rp.index('/', 1)
469
- if last > 1
470
- @captures << rp[1, last-1]
471
- @remaining_path = rp[last, rp.length]
472
- end
469
+ @captures << rp[1, last-1]
470
+ @remaining_path = rp[last, rp.length]
473
471
  elsif rp.length > 1
474
472
  @captures << rp[1,rp.length]
475
473
  @remaining_path = ""
@@ -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 = 33
7
+ RodaMinorVersion = 34
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.33.0
4
+ version: 3.34.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-06-16 00:00:00.000000000 Z
11
+ date: 2020-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -209,6 +209,7 @@ extra_rdoc_files:
209
209
  - doc/release_notes/3.31.0.txt
210
210
  - doc/release_notes/3.32.0.txt
211
211
  - doc/release_notes/3.33.0.txt
212
+ - doc/release_notes/3.34.0.txt
212
213
  files:
213
214
  - CHANGELOG
214
215
  - MIT-LICENSE
@@ -243,6 +244,7 @@ files:
243
244
  - doc/release_notes/3.31.0.txt
244
245
  - doc/release_notes/3.32.0.txt
245
246
  - doc/release_notes/3.33.0.txt
247
+ - doc/release_notes/3.34.0.txt
246
248
  - doc/release_notes/3.4.0.txt
247
249
  - doc/release_notes/3.5.0.txt
248
250
  - doc/release_notes/3.6.0.txt