rack-mount 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack/mount/analysis/frequency.rb +2 -2
- data/lib/rack/mount/analysis/splitting.rb +11 -11
- data/lib/rack/mount/generatable_regexp.rb +4 -4
- data/lib/rack/mount/regexp_with_named_groups.rb +1 -1
- data/lib/rack/mount/strexp/parser.rb +0 -0
- data/lib/rack/mount/strexp/parser.y +1 -1
- data/lib/rack/mount/utils.rb +8 -8
- data/lib/rack/mount/vendor/{reginald/reginald.rb → regin/regin.rb} +12 -12
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/alternation.rb +3 -3
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/anchor.rb +1 -1
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/atom.rb +2 -2
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/character.rb +1 -1
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/character_class.rb +1 -1
- data/lib/rack/mount/vendor/regin/regin/collection.rb +81 -0
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/expression.rb +3 -3
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/group.rb +1 -1
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/options.rb +1 -1
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/parser.rb +3 -3
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/tokenizer.rb +2 -2
- data/lib/rack/mount/vendor/{reginald/reginald → regin/regin}/version.rb +1 -1
- metadata +16 -16
- data/lib/rack/mount/vendor/reginald/reginald/collection.rb +0 -44
@@ -35,8 +35,8 @@ module Rack::Mount
|
|
35
35
|
if requirement.is_a?(Regexp)
|
36
36
|
expression = Utils.parse_regexp(requirement)
|
37
37
|
|
38
|
-
if expression.is_a?(
|
39
|
-
expression = expression.reject { |e| e.is_a?(
|
38
|
+
if expression.is_a?(Regin::Expression) && expression.anchored_to_line?
|
39
|
+
expression = Regin::Expression.new(expression.reject { |e| e.is_a?(Regin::Anchor) })
|
40
40
|
return requirements[method] = expression.to_s if expression.literal?
|
41
41
|
end
|
42
42
|
end
|
@@ -59,23 +59,23 @@ module Rack::Mount
|
|
59
59
|
|
60
60
|
parts = Utils.parse_regexp(regexp)
|
61
61
|
parts.each_with_index do |part, index|
|
62
|
-
if part.is_a?(
|
62
|
+
if part.is_a?(Regin::Group)
|
63
63
|
if index > 0
|
64
64
|
previous = parts[index-1]
|
65
|
-
if previous.is_a?(
|
65
|
+
if previous.is_a?(Regin::Character) && previous.literal?
|
66
66
|
boundaries << previous.to_s
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
if inside = part.expression[0]
|
71
|
-
if inside.is_a?(
|
71
|
+
if inside.is_a?(Regin::Character) && inside.literal?
|
72
72
|
boundaries << inside.to_s
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
if index < parts.length
|
77
77
|
following = parts[index+1]
|
78
|
-
if following.is_a?(
|
78
|
+
if following.is_a?(Regin::Character) && following.literal?
|
79
79
|
boundaries << following.to_s
|
80
80
|
end
|
81
81
|
end
|
@@ -91,30 +91,30 @@ module Rack::Mount
|
|
91
91
|
parts = Utils.parse_regexp(regexp)
|
92
92
|
parts.each_with_index do |part, index|
|
93
93
|
case part
|
94
|
-
when
|
94
|
+
when Regin::Anchor
|
95
95
|
if part.value == '$' || part.value == '\Z'
|
96
96
|
segments << join_buffer(buf, regexp) if buf
|
97
97
|
segments << NULL
|
98
98
|
buf = nil
|
99
99
|
break
|
100
100
|
end
|
101
|
-
when
|
101
|
+
when Regin::CharacterClass
|
102
102
|
break if separators.any? { |s| part.include?(s) }
|
103
103
|
buf = nil
|
104
104
|
segments << part.to_regexp
|
105
|
-
when
|
105
|
+
when Regin::Character
|
106
106
|
if separators.any? { |s| part.include?(s) }
|
107
107
|
segments << join_buffer(buf, regexp) if buf
|
108
108
|
peek = parts[index+1]
|
109
|
-
if peek.is_a?(
|
109
|
+
if peek.is_a?(Regin::Character) && separators.include?(peek.value)
|
110
110
|
segments << ''
|
111
111
|
end
|
112
112
|
buf = nil
|
113
113
|
else
|
114
|
-
buf ||=
|
115
|
-
buf
|
114
|
+
buf ||= Regin::Expression.new([])
|
115
|
+
buf += [part]
|
116
116
|
end
|
117
|
-
when
|
117
|
+
when Regin::Group
|
118
118
|
if part.quantifier == '?'
|
119
119
|
value = part.expression.first
|
120
120
|
if separators.any? { |s| value.include?(s) }
|
@@ -107,9 +107,9 @@ module Rack::Mount
|
|
107
107
|
s = []
|
108
108
|
segments.each_with_index do |part, index|
|
109
109
|
case part
|
110
|
-
when
|
110
|
+
when Regin::Anchor
|
111
111
|
# ignore
|
112
|
-
when
|
112
|
+
when Regin::Character
|
113
113
|
throw :halt unless part.literal?
|
114
114
|
|
115
115
|
if s.last.is_a?(String)
|
@@ -117,13 +117,13 @@ module Rack::Mount
|
|
117
117
|
else
|
118
118
|
s << part.value.dup
|
119
119
|
end
|
120
|
-
when
|
120
|
+
when Regin::Group
|
121
121
|
if part.name
|
122
122
|
s << DynamicSegment.new(part.name, part.expression.to_regexp)
|
123
123
|
else
|
124
124
|
s << parse_segments(part.expression)
|
125
125
|
end
|
126
|
-
when
|
126
|
+
when Regin::Expression
|
127
127
|
return parse_segments(part)
|
128
128
|
else
|
129
129
|
throw :halt
|
Binary file
|
data/lib/rack/mount/utils.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
begin
|
2
|
-
require '
|
2
|
+
require 'regin'
|
3
3
|
rescue LoadError
|
4
|
-
$: << File.expand_path(File.join(File.dirname(__FILE__), 'vendor/
|
5
|
-
require '
|
4
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), 'vendor/regin'))
|
5
|
+
require 'regin'
|
6
6
|
end
|
7
7
|
|
8
8
|
require 'uri'
|
@@ -122,16 +122,16 @@ module Rack::Mount
|
|
122
122
|
regexp = RegexpWithNamedGroups.new(regexp)
|
123
123
|
end
|
124
124
|
|
125
|
-
expression =
|
125
|
+
expression = Regin.parse(regexp)
|
126
126
|
|
127
|
-
unless
|
127
|
+
unless Regin.regexp_supports_named_captures?
|
128
128
|
tag_captures = Proc.new do |group|
|
129
129
|
case group
|
130
|
-
when
|
130
|
+
when Regin::Group
|
131
131
|
# TODO: dup instead of mutating
|
132
132
|
group.instance_variable_set('@name', regexp.names[group.index]) if group.index
|
133
133
|
tag_captures.call(group.expression)
|
134
|
-
when
|
134
|
+
when Regin::Expression
|
135
135
|
group.each { |child| tag_captures.call(child) }
|
136
136
|
end
|
137
137
|
end
|
@@ -140,7 +140,7 @@ module Rack::Mount
|
|
140
140
|
|
141
141
|
cache[regexp] = expression.freeze
|
142
142
|
expression
|
143
|
-
rescue Racc::ParseError,
|
143
|
+
rescue Racc::ParseError, Regin::Parser::ScanError
|
144
144
|
[]
|
145
145
|
end
|
146
146
|
module_function :parse_regexp
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module
|
2
|
-
autoload :Alternation, '
|
3
|
-
autoload :Anchor, '
|
4
|
-
autoload :Atom, '
|
5
|
-
autoload :Character, '
|
6
|
-
autoload :CharacterClass, '
|
7
|
-
autoload :Collection, '
|
8
|
-
autoload :Expression, '
|
9
|
-
autoload :Group, '
|
10
|
-
autoload :Options, '
|
11
|
-
autoload :Parser, '
|
1
|
+
module Regin
|
2
|
+
autoload :Alternation, 'regin/alternation'
|
3
|
+
autoload :Anchor, 'regin/anchor'
|
4
|
+
autoload :Atom, 'regin/atom'
|
5
|
+
autoload :Character, 'regin/character'
|
6
|
+
autoload :CharacterClass, 'regin/character_class'
|
7
|
+
autoload :Collection, 'regin/collection'
|
8
|
+
autoload :Expression, 'regin/expression'
|
9
|
+
autoload :Group, 'regin/group'
|
10
|
+
autoload :Options, 'regin/options'
|
11
|
+
autoload :Parser, 'regin/parser'
|
12
12
|
|
13
13
|
class << self
|
14
14
|
begin
|
@@ -34,7 +34,7 @@ module Reginald
|
|
34
34
|
|
35
35
|
# Recompiles Regexp by parsing it and turning it back into a Regexp.
|
36
36
|
#
|
37
|
-
# (In the future
|
37
|
+
# (In the future Regin will perform some Regexp optimizations
|
38
38
|
# such as removing unnecessary captures and options)
|
39
39
|
def compile(source)
|
40
40
|
regexp = Regexp.compile(source)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module Regin
|
2
2
|
class Alternation < Collection
|
3
3
|
def self.reduce(alternation_or_expression, expression) #:nodoc:
|
4
4
|
if alternation_or_expression.first.is_a?(Alternation)
|
5
5
|
alternation_or_expression = alternation_or_expression.first
|
6
|
-
alternation_or_expression
|
6
|
+
alternation_or_expression += [expression]
|
7
7
|
new(*alternation_or_expression)
|
8
8
|
else
|
9
9
|
new(alternation_or_expression, expression)
|
@@ -20,7 +20,7 @@ module Reginald
|
|
20
20
|
end
|
21
21
|
|
22
22
|
if options.key?(:ignorecase)
|
23
|
-
map! { |e| e.dup(:ignorecase => options[:ignorecase]) }
|
23
|
+
@array.map! { |e| e.dup(:ignorecase => options[:ignorecase]) }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Regin
|
2
2
|
class Atom
|
3
3
|
attr_reader :value, :ignorecase
|
4
4
|
|
@@ -33,7 +33,7 @@ module Reginald
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def inspect #:nodoc:
|
36
|
-
"#<#{self.class.to_s.sub('
|
36
|
+
"#<#{self.class.to_s.sub('Regin::', '')} #{to_s.inspect}>"
|
37
37
|
end
|
38
38
|
|
39
39
|
def ==(other) #:nodoc:
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Regin
|
2
|
+
class Collection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
@array = Array.new(*args)
|
7
|
+
end
|
8
|
+
|
9
|
+
def each(&block)
|
10
|
+
@array.each(&block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](i)
|
14
|
+
@array[i]
|
15
|
+
end
|
16
|
+
|
17
|
+
def length
|
18
|
+
@array.length
|
19
|
+
end
|
20
|
+
alias_method :size, :length
|
21
|
+
|
22
|
+
def first
|
23
|
+
@array.first
|
24
|
+
end
|
25
|
+
|
26
|
+
def last
|
27
|
+
@array.last
|
28
|
+
end
|
29
|
+
|
30
|
+
def +(other)
|
31
|
+
ary = other.is_a?(Collection) ? other.internal_array : other
|
32
|
+
self.class.new(@array + ary)
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_regexp
|
36
|
+
Regexp.compile("\\A#{to_s(true)}\\Z", flags)
|
37
|
+
end
|
38
|
+
|
39
|
+
def match(char)
|
40
|
+
to_regexp.match(char)
|
41
|
+
end
|
42
|
+
|
43
|
+
def include?(char)
|
44
|
+
any? { |e| e.include?(char) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def ==(other) #:nodoc:
|
48
|
+
case other
|
49
|
+
when String
|
50
|
+
other == to_s
|
51
|
+
when Array
|
52
|
+
other == @array
|
53
|
+
else
|
54
|
+
eql?(other)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def eql?(other) #:nodoc:
|
59
|
+
other.instance_of?(self.class) && @array.eql?(other.internal_array)
|
60
|
+
end
|
61
|
+
|
62
|
+
def freeze #:nodoc:
|
63
|
+
each { |e| e.freeze }
|
64
|
+
@array.freeze
|
65
|
+
super
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
def internal_array #:nodoc:
|
70
|
+
@array
|
71
|
+
end
|
72
|
+
|
73
|
+
def extract_options(args)
|
74
|
+
if args.last.is_a?(Hash)
|
75
|
+
return args[0..-2], args.last
|
76
|
+
else
|
77
|
+
return args, {}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module
|
1
|
+
module Regin
|
2
2
|
class Expression < Collection
|
3
3
|
attr_reader :ignorecase
|
4
4
|
attr_accessor :multiline, :extended
|
5
5
|
|
6
6
|
def self.reduce(expression_or_atom, atom = nil) #:nodoc:
|
7
7
|
if expression_or_atom.is_a?(Expression)
|
8
|
-
expression_or_atom
|
8
|
+
expression_or_atom += [atom] if atom
|
9
9
|
new(*expression_or_atom)
|
10
10
|
elsif atom.nil?
|
11
11
|
new(expression_or_atom)
|
@@ -116,7 +116,7 @@ module Reginald
|
|
116
116
|
|
117
117
|
def ignorecase=(ignorecase)
|
118
118
|
if @ignorecase.nil?
|
119
|
-
map! { |e| e.dup(:ignorecase => ignorecase) }
|
119
|
+
@array.map! { |e| e.dup(:ignorecase => ignorecase) }
|
120
120
|
@ignorecase = ignorecase
|
121
121
|
end
|
122
122
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
require 'racc/parser.rb'
|
8
|
-
module
|
8
|
+
module Regin
|
9
9
|
class Parser < Racc::Parser #:nodoc: all
|
10
10
|
|
11
11
|
def self.parse_regexp(regexp)
|
@@ -399,7 +399,7 @@ def _reduce_none(val, _values, result)
|
|
399
399
|
end
|
400
400
|
|
401
401
|
end # class Parser
|
402
|
-
end # module
|
402
|
+
end # module Regin
|
403
403
|
|
404
|
-
require '
|
404
|
+
require 'regin/tokenizer'
|
405
405
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#--
|
2
2
|
# DO NOT MODIFY!!!!
|
3
3
|
# This file is automatically generated by rex 1.0.5.beta1
|
4
|
-
# from lexical definition file "lib/
|
4
|
+
# from lexical definition file "lib/regin/tokenizer.rex".
|
5
5
|
#++
|
6
6
|
|
7
7
|
require 'racc/parser'
|
8
|
-
class
|
8
|
+
class Regin::Parser < Racc::Parser
|
9
9
|
require 'strscan'
|
10
10
|
|
11
11
|
class ScanError < StandardError ; end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mount
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 6
|
10
|
+
version: 0.6.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Peek
|
@@ -90,19 +90,19 @@ files:
|
|
90
90
|
- lib/rack/mount/vendor/multimap/multimap.rb
|
91
91
|
- lib/rack/mount/vendor/multimap/multiset.rb
|
92
92
|
- lib/rack/mount/vendor/multimap/nested_multimap.rb
|
93
|
-
- lib/rack/mount/vendor/
|
94
|
-
- lib/rack/mount/vendor/
|
95
|
-
- lib/rack/mount/vendor/
|
96
|
-
- lib/rack/mount/vendor/
|
97
|
-
- lib/rack/mount/vendor/
|
98
|
-
- lib/rack/mount/vendor/
|
99
|
-
- lib/rack/mount/vendor/
|
100
|
-
- lib/rack/mount/vendor/
|
101
|
-
- lib/rack/mount/vendor/
|
102
|
-
- lib/rack/mount/vendor/
|
103
|
-
- lib/rack/mount/vendor/
|
104
|
-
- lib/rack/mount/vendor/
|
105
|
-
- lib/rack/mount/vendor/
|
93
|
+
- lib/rack/mount/vendor/regin/regin.rb
|
94
|
+
- lib/rack/mount/vendor/regin/regin/alternation.rb
|
95
|
+
- lib/rack/mount/vendor/regin/regin/anchor.rb
|
96
|
+
- lib/rack/mount/vendor/regin/regin/atom.rb
|
97
|
+
- lib/rack/mount/vendor/regin/regin/character.rb
|
98
|
+
- lib/rack/mount/vendor/regin/regin/character_class.rb
|
99
|
+
- lib/rack/mount/vendor/regin/regin/collection.rb
|
100
|
+
- lib/rack/mount/vendor/regin/regin/expression.rb
|
101
|
+
- lib/rack/mount/vendor/regin/regin/group.rb
|
102
|
+
- lib/rack/mount/vendor/regin/regin/options.rb
|
103
|
+
- lib/rack/mount/vendor/regin/regin/parser.rb
|
104
|
+
- lib/rack/mount/vendor/regin/regin/tokenizer.rb
|
105
|
+
- lib/rack/mount/vendor/regin/regin/version.rb
|
106
106
|
- lib/rack/mount/version.rb
|
107
107
|
has_rdoc: true
|
108
108
|
homepage: http://github.com/josh/rack-mount
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Reginald
|
2
|
-
class Collection < Array
|
3
|
-
def to_regexp
|
4
|
-
Regexp.compile("\\A#{to_s(true)}\\Z", flags)
|
5
|
-
end
|
6
|
-
|
7
|
-
def match(char)
|
8
|
-
to_regexp.match(char)
|
9
|
-
end
|
10
|
-
|
11
|
-
def include?(char)
|
12
|
-
any? { |e| e.include?(char) }
|
13
|
-
end
|
14
|
-
|
15
|
-
def ==(other) #:nodoc:
|
16
|
-
case other
|
17
|
-
when String
|
18
|
-
other == to_s
|
19
|
-
when Array
|
20
|
-
super
|
21
|
-
else
|
22
|
-
eql?(other)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def eql?(other) #:nodoc:
|
27
|
-
other.instance_of?(self.class) && super
|
28
|
-
end
|
29
|
-
|
30
|
-
def freeze #:nodoc:
|
31
|
-
each { |e| e.freeze }
|
32
|
-
super
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
def extract_options(args)
|
37
|
-
if args.last.is_a?(Hash)
|
38
|
-
return args[0..-2], args.last
|
39
|
-
else
|
40
|
-
return args, {}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|