roda 3.96.0 → 3.97.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: 5cd2f1819c84a5977f70830dd6188e00a2e93ba0002a7ab13108a3ac70b8fad4
4
- data.tar.gz: 2c9ee53f9fc84598e40b33f6381e14727d568baf7f3bfb07b371565a2e439a92
3
+ metadata.gz: 5dfe0f7c2161415227cf683ae6c01eaec3b4c24356a0d30a432a22496de10419
4
+ data.tar.gz: dd942c7df38f70c0c92198382a96416e50b58bca364c40245cd0db9fc189b4ef
5
5
  SHA512:
6
- metadata.gz: 74520bc003b12e9098b05fdbe22aaa4945d0d9964827ea1e1ec26c669b9f58dff3374cad123cde2bd16de87148f4d11754ed980f79ba40d12ba413ecf83a801c
7
- data.tar.gz: 0a57700f09fb3a61b091dd9c6c4150637ac5f0f6c86d888c4426ab6e4f4f70dc809aa134368d943f41d47421d4b441048c5ef35ac33ccb47fe90095d6fa640bb
6
+ metadata.gz: 9a2a87e92a736a141ce78251ffa90f1d00ede4630541aca87188a595913f4279083a61465c9a49489c0e3aab9e53981567ba32d3d5d645dfdd6a6d93bcc5df88
7
+ data.tar.gz: 0faa213105f681e07078b94e3472563b3718a144ac0ad7ba7c39673f3cca2815f9200ce13f27d87f469ab3c132eb09a025058cf589adc9d8fcad62eb943b0c3b
@@ -7,6 +7,8 @@ class Roda
7
7
  # allows for easily defining hash matchers:
8
8
  #
9
9
  # class App < Roda
10
+ # plugin :hash_matcher
11
+ #
10
12
  # hash_matcher(:foo) do |v|
11
13
  # params['foo'] == v
12
14
  # end
@@ -0,0 +1,48 @@
1
+ # frozen-string-literal: true
2
+
3
+ #
4
+ class Roda
5
+ module RodaPlugins
6
+ # The map_matcher plugin allows you to provide a string-keyed
7
+ # hash during route matching, and match any of the keys in the hash
8
+ # as the next segment in the request path, yielding the corresponding
9
+ # value in the hash:
10
+ #
11
+ # class App < Roda
12
+ # plugin :map_matcher
13
+ #
14
+ # map = { "foo" => "bar", "baz" => "quux" }.freeze
15
+ #
16
+ # route do
17
+ # r.get map: map do |v|
18
+ # v
19
+ # # GET /foo => bar
20
+ # # GET /baz => quux
21
+ # end
22
+ # end
23
+ # end
24
+ module MapMatcher
25
+ module RequestMethods
26
+ private
27
+
28
+ # Match only if the next segment in the path is one of the keys
29
+ # in the hash, and yield the value of the hash.
30
+ def match_map(hash)
31
+ rp = @remaining_path
32
+ if key = _match_class_String
33
+ if value = hash[@captures[-1]]
34
+ @captures[-1] = value
35
+ true
36
+ else
37
+ @remaining_path = rp
38
+ @captures.pop
39
+ false
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ register_plugin(:map_matcher, MapMatcher)
47
+ end
48
+ end
@@ -11,7 +11,7 @@ class Roda
11
11
  #
12
12
  # Example:
13
13
  #
14
- # plugin :multi_route
14
+ # plugin :named_routes
15
15
  #
16
16
  # route('foo') do |r|
17
17
  # r.is 'bar' do
@@ -17,7 +17,7 @@ class Roda
17
17
  # Foo = Struct.new(:id)
18
18
  # foo = Foo.new(1)
19
19
  #
20
- # plugin :path
20
+ # plugin :redirect_path
21
21
  # path Foo do |foo|
22
22
  # "/foo/#{foo.id}"
23
23
  # end
data/lib/roda/version.rb CHANGED
@@ -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 = 96
7
+ RodaMinorVersion = 97
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.96.0
4
+ version: 3.97.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
@@ -234,6 +234,7 @@ files:
234
234
  - lib/roda/plugins/link_to.rb
235
235
  - lib/roda/plugins/mail_processor.rb
236
236
  - lib/roda/plugins/mailer.rb
237
+ - lib/roda/plugins/map_matcher.rb
237
238
  - lib/roda/plugins/match_affix.rb
238
239
  - lib/roda/plugins/match_hook.rb
239
240
  - lib/roda/plugins/match_hook_args.rb