roda 3.34.0 → 3.35.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: 4ea0324d5667f9dcde48ff8fd1025b15e0e06861eea776019c0be9be8c46b097
4
- data.tar.gz: 1712241233e21e7863101192227797976a79f6a3f0895da907a9e2b19242e1ed
3
+ metadata.gz: 370e18bb1d1cfb9fb8b0c10fda1a4f57161a39c6d733b628ddd60058d231f896
4
+ data.tar.gz: fe0c8ddb499cdbafb0f047d9445fca726f742e38674f90731f3421132c373365
5
5
  SHA512:
6
- metadata.gz: 6b8d1b37ed94ee40c0b1f12cc20ab9f734b276805044b059c9ea10375cc64d7d2cc8b0b36049bd21e29d3e45eeefcc8aeaffe0b4bbaf2d36043c16838270e2eb
7
- data.tar.gz: 1670e3cde892c8cd42e2856d4e938e6da359d0818ee09f7c28e8ec5f4bc4bd627f3aaa8c48aeac8f6d03ab80994078a5cbce69d99595214f288eb9ab1f860c23
6
+ metadata.gz: 60db0b47d97ae40437e0396bc795ac360194bd88067e6611cf277888d054e3c41786eb062f4ab31d6683cb4755a3a27d148a576236c77a4d46db67fc2accc7e1
7
+ data.tar.gz: 44745afaa29ccee2d51a132f7b7be4da6818191814a9ff8a2afd52f34636789cb0e4d22eb63ade49ea0411470a73b05a1996c7bb70cc7edf04264fb2fddadb83
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ = 3.35.0 (2020-08-14)
2
+
3
+ * Add r plugin for r method for accessing request, useful when r local variable is not in scope (jeremyevans)
4
+
5
+ * Warn when loading a plugin with arguments or a block if the plugin does not accept arguments or block (jeremyevans)
6
+
1
7
  = 3.34.0 (2020-07-14)
2
8
 
3
9
  * Remove unnecessary conditionals (jeremyevans)
@@ -0,0 +1,12 @@
1
+ = New Features
2
+
3
+ * An r plugin has been added. This plugin adds an r method for the
4
+ request, useful for allowing the use of r.halt and r.redirect even
5
+ in methods where the r local variable is not in scope.
6
+
7
+ = Other Improvements
8
+
9
+ * Attempting to load a plugin with an argument or block when the plugin
10
+ does not accept arguments or a block now warns. This is because a
11
+ future update to support a block or an optional argument could break
12
+ the call.
@@ -272,6 +272,12 @@ class Roda
272
272
  raise RodaError, "Cannot add a plugin to a frozen Roda class" if frozen?
273
273
  plugin = RodaPlugins.load_plugin(plugin) if plugin.is_a?(Symbol)
274
274
  raise RodaError, "Invalid plugin type: #{plugin.class.inspect}" unless plugin.is_a?(Module)
275
+
276
+ if !plugin.respond_to?(:load_dependencies) && !plugin.respond_to?(:configure) && (!args.empty? || block)
277
+ # RODA4: switch from warning to error
278
+ RodaPlugins.warn("Plugin #{plugin} does not accept arguments or a block, but arguments or a block was passed when loading this. This will raise an error in Roda 4.")
279
+ end
280
+
275
281
  plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
276
282
  include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
277
283
  extend(plugin::ClassMethods) if defined?(plugin::ClassMethods)
@@ -0,0 +1,35 @@
1
+ # frozen-string-literal: true
2
+
3
+ #
4
+ class Roda
5
+ module RodaPlugins
6
+ # The r plugin adds an +r+ instance method that will return the request.
7
+ # This allows you to use common Roda idioms such as +r.halt+ and
8
+ # +r.redirect+ even when +r+ isn't a local variable in scope. Example:
9
+ #
10
+ # plugin :r
11
+ #
12
+ # def foo
13
+ # r.redirect "/bar"
14
+ # end
15
+ #
16
+ # route do |r|
17
+ # r.get "foo" do
18
+ # foo
19
+ # end
20
+ # r.get "bar" do
21
+ # "bar"
22
+ # end
23
+ # end
24
+ module R
25
+ module InstanceMethods
26
+ # The request object.
27
+ def r
28
+ @_request
29
+ end
30
+ end
31
+ end
32
+
33
+ register_plugin(:r, R)
34
+ end
35
+ end
@@ -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 = 34
7
+ RodaMinorVersion = 35
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.34.0
4
+ version: 3.35.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-07-14 00:00:00.000000000 Z
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -210,6 +210,7 @@ extra_rdoc_files:
210
210
  - doc/release_notes/3.32.0.txt
211
211
  - doc/release_notes/3.33.0.txt
212
212
  - doc/release_notes/3.34.0.txt
213
+ - doc/release_notes/3.35.0.txt
213
214
  files:
214
215
  - CHANGELOG
215
216
  - MIT-LICENSE
@@ -245,6 +246,7 @@ files:
245
246
  - doc/release_notes/3.32.0.txt
246
247
  - doc/release_notes/3.33.0.txt
247
248
  - doc/release_notes/3.34.0.txt
249
+ - doc/release_notes/3.35.0.txt
248
250
  - doc/release_notes/3.4.0.txt
249
251
  - doc/release_notes/3.5.0.txt
250
252
  - doc/release_notes/3.6.0.txt
@@ -324,6 +326,7 @@ files:
324
326
  - lib/roda/plugins/placeholder_string_matchers.rb
325
327
  - lib/roda/plugins/precompile_templates.rb
326
328
  - lib/roda/plugins/public.rb
329
+ - lib/roda/plugins/r.rb
327
330
  - lib/roda/plugins/relative_path.rb
328
331
  - lib/roda/plugins/render.rb
329
332
  - lib/roda/plugins/render_each.rb