roda 3.97.0 → 3.99.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: 5dfe0f7c2161415227cf683ae6c01eaec3b4c24356a0d30a432a22496de10419
4
- data.tar.gz: dd942c7df38f70c0c92198382a96416e50b58bca364c40245cd0db9fc189b4ef
3
+ metadata.gz: 26619fe3a0b256c2615c6be17f215919c73a804609f536a3ff9f8329f14e7f9b
4
+ data.tar.gz: 550f978b06bf82356bcbefedc9d00929073549c02cb118362212527f52a6336d
5
5
  SHA512:
6
- metadata.gz: 9a2a87e92a736a141ce78251ffa90f1d00ede4630541aca87188a595913f4279083a61465c9a49489c0e3aab9e53981567ba32d3d5d645dfdd6a6d93bcc5df88
7
- data.tar.gz: 0faa213105f681e07078b94e3472563b3718a144ac0ad7ba7c39673f3cca2815f9200ce13f27d87f469ab3c132eb09a025058cf589adc9d8fcad62eb943b0c3b
6
+ metadata.gz: 244665571cdb2b400ced6494ab8210fbf12ab46b2fd799f35fd7373f675606c975b8fc7cc6a279532c8b76d9a981a339528b41567d022d353f763ee8028b4225
7
+ data.tar.gz: a30c5c61b21ff9c65c0cfdad17a1011039d44b57c498e7e833fec859a7ec6876d593eb53b950c56d6b7a8858f11e6e2edf6d3798db2288ccfa5b965be019bbe5
@@ -9,7 +9,7 @@ class Roda
9
9
  # dispatching to the application with an environment that would violate the
10
10
  # Rack SPEC.
11
11
  #
12
- # You are unlikely to want to use this plugin unless are consuming partial
12
+ # You are unlikely to want to use this plugin unless you are consuming partial
13
13
  # segments of the request path, or using the match_affix plugin to change
14
14
  # how routing is done:
15
15
  #
@@ -23,10 +23,10 @@ class Roda
23
23
  # end
24
24
  #
25
25
  # # with run_require_slash:
26
- # # GET /a/b/e => App not dispatched to
26
+ # # GET /a/b/e => Not dispatched to application
27
27
  # # GET /a/b => App gets "" as PATH_INFO
28
28
  #
29
- # # with run_require_slash:
29
+ # # without run_require_slash:
30
30
  # # GET /a/b/e => App gets "e" as PATH_INFO, violating rack SPEC
31
31
  # # GET /a/b => App gets "" as PATH_INFO
32
32
  module RunRequireSlash
@@ -65,6 +65,8 @@ class Roda
65
65
  # that. If the +:secure+ option is not present in the hash, then
66
66
  # <tt>secure: true</tt> is also set if the request is made over HTTPS. If this option is
67
67
  # given, it will be merged into the default cookie options.
68
+ # :env_key :: The key in `env` where the session should be located. Defaults to <tt>"rack.session"</tt>, the
69
+ # default key for sessions in Rack.
68
70
  # :gzip_over :: For session data over this many bytes, compress it with the deflate algorithm (default: nil,
69
71
  # so never compress). Note that compression should not be enabled if you are storing data in
70
72
  # the session derived from user input and also storing sensitive data in the session.
@@ -148,7 +150,7 @@ class Roda
148
150
  # deflate compression, this contains the deflate compressed data.
149
151
  module Sessions
150
152
  DEFAULT_COOKIE_OPTIONS = {:httponly=>true, :path=>'/'.freeze, :same_site=>:lax}.freeze
151
- DEFAULT_OPTIONS = {:key => 'roda.session'.freeze, :max_seconds=>86400*30, :max_idle_seconds=>86400*7, :pad_size=>32, :gzip_over=>nil, :skip_within=>3600}.freeze
153
+ DEFAULT_OPTIONS = {:key => 'roda.session'.freeze, :max_seconds=>86400*30, :max_idle_seconds=>86400*7, :pad_size=>32, :gzip_over=>nil, :skip_within=>3600, :env_key=>'rack.session'}.freeze
152
154
  DEFLATE_BIT = 0x1000
153
155
  PADDING_MASK = 0x0fff
154
156
  SESSION_CREATED_AT = 'roda.session.created_at'.freeze
@@ -226,7 +228,7 @@ class Roda
226
228
  # update the rack response headers to set the session cookie in
227
229
  # the response.
228
230
  def _roda_after_50__sessions(res)
229
- if res && (session = env['rack.session'])
231
+ if res && (session = env[self.class.opts[:sessions][:env_key]])
230
232
  @_request.persist_session(res[1], session)
231
233
  end
232
234
  end
@@ -240,7 +242,7 @@ class Roda
240
242
  # this method stores the session in 'rack.session' in the request environment,
241
243
  # but that does not happen until this method is called.
242
244
  def session
243
- @env['rack.session'] ||= _load_session
245
+ @env[roda_class.opts[:sessions][:env_key]] ||= _load_session
244
246
  end
245
247
 
246
248
  # The time the session was originally created. nil if there is no active session.
data/lib/roda/request.rb CHANGED
@@ -12,6 +12,7 @@ else
12
12
  end
13
13
  end
14
14
 
15
+ require 'set'
15
16
  require_relative "cache"
16
17
 
17
18
  class Roda
@@ -489,6 +490,21 @@ class Roda
489
490
  end
490
491
  end
491
492
 
493
+ # Match only if the next segment in the path is one of the
494
+ # set's elements, and yield the next segment.
495
+ def _match_set(set)
496
+ rp = @remaining_path
497
+ if key = _match_class_String
498
+ if set.include?(@captures[-1])
499
+ true
500
+ else
501
+ @remaining_path = rp
502
+ @captures.pop
503
+ false
504
+ end
505
+ end
506
+ end
507
+
492
508
  # Match the given symbol if any segment matches.
493
509
  def _match_symbol(sym=nil)
494
510
  rp = @remaining_path
@@ -629,6 +645,8 @@ class Roda
629
645
  _match_array(matcher)
630
646
  when Hash
631
647
  _match_hash(matcher)
648
+ when Set
649
+ _match_set(matcher)
632
650
  when Symbol
633
651
  _match_symbol(matcher)
634
652
  when false, nil
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 = 97
7
+ RodaMinorVersion = 99
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.97.0
4
+ version: 3.99.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans