rack-mount 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/README.rdoc +1 -1
  2. data/lib/rack/mount.rb +0 -2
  3. data/lib/rack/mount/analysis/frequency.rb +10 -3
  4. data/lib/rack/mount/analysis/splitting.rb +79 -62
  5. data/lib/rack/mount/generatable_regexp.rb +48 -45
  6. data/lib/rack/mount/generation/route.rb +10 -5
  7. data/lib/rack/mount/generation/route_set.rb +23 -31
  8. data/lib/rack/mount/prefix.rb +14 -15
  9. data/lib/rack/mount/recognition/code_generation.rb +51 -61
  10. data/lib/rack/mount/recognition/route.rb +7 -22
  11. data/lib/rack/mount/recognition/route_set.rb +40 -16
  12. data/lib/rack/mount/regexp_with_named_groups.rb +33 -7
  13. data/lib/rack/mount/route_set.rb +7 -5
  14. data/lib/rack/mount/strexp.rb +11 -40
  15. data/lib/rack/mount/strexp/parser.rb +158 -0
  16. data/lib/rack/mount/strexp/tokenizer.rb +84 -0
  17. data/lib/rack/mount/utils.rb +26 -163
  18. data/lib/rack/mount/vendor/multimap/multimap.rb +1 -0
  19. data/lib/rack/mount/vendor/reginald/reginald.rb +55 -0
  20. data/lib/rack/mount/vendor/reginald/reginald/alternation.rb +50 -0
  21. data/lib/rack/mount/vendor/reginald/reginald/anchor.rb +20 -0
  22. data/lib/rack/mount/vendor/reginald/reginald/character.rb +53 -0
  23. data/lib/rack/mount/vendor/reginald/reginald/character_class.rb +61 -0
  24. data/lib/rack/mount/vendor/reginald/reginald/expression.rb +75 -0
  25. data/lib/rack/mount/vendor/reginald/reginald/group.rb +61 -0
  26. data/lib/rack/mount/vendor/reginald/reginald/parser.rb +306 -0
  27. data/lib/rack/mount/vendor/reginald/reginald/tokenizer.rb +141 -0
  28. metadata +14 -15
  29. data/lib/rack/mount/const.rb +0 -45
  30. data/lib/rack/mount/meta_method.rb +0 -104
@@ -0,0 +1,141 @@
1
+ #--
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by rex 1.0.4
4
+ # from lexical definition file "lib/reginald/tokenizer.rex".
5
+ #++
6
+
7
+ require 'racc/parser'
8
+ module Reginald
9
+ class Parser < Racc::Parser
10
+ require 'strscan'
11
+
12
+ class ScanError < StandardError ; end
13
+
14
+ attr_reader :lineno
15
+ attr_reader :filename
16
+ attr_accessor :state
17
+
18
+ def scan_setup(str)
19
+ @ss = StringScanner.new(str)
20
+ @lineno = 1
21
+ @state = nil
22
+ end
23
+
24
+ def action(&block)
25
+ yield
26
+ end
27
+
28
+ def scan_str(str)
29
+ scan_setup(str)
30
+ do_parse
31
+ end
32
+
33
+ def load_file( filename )
34
+ @filename = filename
35
+ open(filename, "r") do |f|
36
+ scan_setup(f.read)
37
+ end
38
+ end
39
+
40
+ def scan_file( filename )
41
+ load_file(filename)
42
+ do_parse
43
+ end
44
+
45
+
46
+ def next_token
47
+ return if @ss.eos?
48
+
49
+ text = @ss.peek(1)
50
+ @lineno += 1 if text == "\n"
51
+ token = case @state
52
+ when nil
53
+ case
54
+ when (text = @ss.scan(/\\c/))
55
+ action { [:CHAR_CLASS, text] }
56
+
57
+ when (text = @ss.scan(/\\s/))
58
+ action { [:CHAR_CLASS, text] }
59
+
60
+ when (text = @ss.scan(/\\S/))
61
+ action { [:CHAR_CLASS, text] }
62
+
63
+ when (text = @ss.scan(/\\d/))
64
+ action { [:CHAR_CLASS, text] }
65
+
66
+ when (text = @ss.scan(/\\w/))
67
+ action { [:CHAR_CLASS, text] }
68
+
69
+ when (text = @ss.scan(/\\W/))
70
+ action { [:CHAR_CLASS, text] }
71
+
72
+ when (text = @ss.scan(/\^/))
73
+ action { [:L_ANCHOR, text] }
74
+
75
+ when (text = @ss.scan(/\\A/))
76
+ action { [:L_ANCHOR, text] }
77
+
78
+ when (text = @ss.scan(/\$/))
79
+ action { [:R_ANCHOR, text] }
80
+
81
+ when (text = @ss.scan(/\\Z/))
82
+ action { [:R_ANCHOR, text] }
83
+
84
+ when (text = @ss.scan(/<(\w+)>/))
85
+ action { [:NAME, @ss[1]] }
86
+
87
+ when (text = @ss.scan(/\(/))
88
+ action { [:LPAREN, text] }
89
+
90
+ when (text = @ss.scan(/\)/))
91
+ action { [:RPAREN, text] }
92
+
93
+ when (text = @ss.scan(/\[/))
94
+ action { [:LBRACK, text] }
95
+
96
+ when (text = @ss.scan(/\]/))
97
+ action { [:RBRACK, text] }
98
+
99
+ when (text = @ss.scan(/\{/))
100
+ action { [:LCURLY, text] }
101
+
102
+ when (text = @ss.scan(/\}/))
103
+ action { [:RCURLY, text] }
104
+
105
+ when (text = @ss.scan(/\|/))
106
+ action { [:BAR, text] }
107
+
108
+ when (text = @ss.scan(/\./))
109
+ action { [:DOT, text] }
110
+
111
+ when (text = @ss.scan(/\?/))
112
+ action { [:QMARK, text] }
113
+
114
+ when (text = @ss.scan(/\+/))
115
+ action { [:PLUS, text] }
116
+
117
+ when (text = @ss.scan(/\*/))
118
+ action { [:STAR, text] }
119
+
120
+ when (text = @ss.scan(/\:/))
121
+ action { [:COLON, text] }
122
+
123
+ when (text = @ss.scan(/\\(.)/))
124
+ action { [:CHAR, @ss[1]] }
125
+
126
+ when (text = @ss.scan(/./))
127
+ action { [:CHAR, text] }
128
+
129
+ else
130
+ text = @ss.string[@ss.pos .. -1]
131
+ raise ScanError, "can not match: '" + text + "'"
132
+ end # if
133
+
134
+ else
135
+ raise ScanError, "undefined state: '" + state.to_s + "'"
136
+ end # case state
137
+ token
138
+ end # def next_token
139
+
140
+ end # class
141
+ end # module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-mount
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-12 00:00:00 -05:00
12
+ date: 2009-11-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,16 +22,6 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.0.0
24
24
  version:
25
- - !ruby/object:Gem::Dependency
26
- name: multimap
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.0.0
34
- version:
35
25
  description: Stackable dynamic tree based Rack router
36
26
  email: josh@joshpeek.com
37
27
  executables: []
@@ -45,12 +35,10 @@ files:
45
35
  - lib/rack/mount/analysis/frequency.rb
46
36
  - lib/rack/mount/analysis/histogram.rb
47
37
  - lib/rack/mount/analysis/splitting.rb
48
- - lib/rack/mount/const.rb
49
38
  - lib/rack/mount/exceptions.rb
50
39
  - lib/rack/mount/generatable_regexp.rb
51
40
  - lib/rack/mount/generation/route.rb
52
41
  - lib/rack/mount/generation/route_set.rb
53
- - lib/rack/mount/meta_method.rb
54
42
  - lib/rack/mount/mixover.rb
55
43
  - lib/rack/mount/multimap.rb
56
44
  - lib/rack/mount/prefix.rb
@@ -60,11 +48,22 @@ files:
60
48
  - lib/rack/mount/regexp_with_named_groups.rb
61
49
  - lib/rack/mount/route.rb
62
50
  - lib/rack/mount/route_set.rb
51
+ - lib/rack/mount/strexp/parser.rb
52
+ - lib/rack/mount/strexp/tokenizer.rb
63
53
  - lib/rack/mount/strexp.rb
64
54
  - lib/rack/mount/utils.rb
65
55
  - lib/rack/mount/vendor/multimap/multimap.rb
66
56
  - lib/rack/mount/vendor/multimap/multiset.rb
67
57
  - lib/rack/mount/vendor/multimap/nested_multimap.rb
58
+ - lib/rack/mount/vendor/reginald/reginald/alternation.rb
59
+ - lib/rack/mount/vendor/reginald/reginald/anchor.rb
60
+ - lib/rack/mount/vendor/reginald/reginald/character.rb
61
+ - lib/rack/mount/vendor/reginald/reginald/character_class.rb
62
+ - lib/rack/mount/vendor/reginald/reginald/expression.rb
63
+ - lib/rack/mount/vendor/reginald/reginald/group.rb
64
+ - lib/rack/mount/vendor/reginald/reginald/parser.rb
65
+ - lib/rack/mount/vendor/reginald/reginald/tokenizer.rb
66
+ - lib/rack/mount/vendor/reginald/reginald.rb
68
67
  - lib/rack/mount.rb
69
68
  - README.rdoc
70
69
  - LICENSE
@@ -91,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
90
  version:
92
91
  requirements: []
93
92
 
94
- rubyforge_project: rack-mount
93
+ rubyforge_project:
95
94
  rubygems_version: 1.3.5
96
95
  signing_key:
97
96
  specification_version: 3
@@ -1,45 +0,0 @@
1
- module Rack::Mount
2
- module Const
3
- RACK_ROUTING_ARGS = 'rack.routing_args'.freeze
4
-
5
- begin
6
- eval('/(?<foo>.*)/').named_captures
7
- SUPPORTS_NAMED_CAPTURES = true
8
- REGEXP_NAMED_CAPTURE = '(?<%s>%s)'.freeze
9
- rescue SyntaxError, NoMethodError
10
- SUPPORTS_NAMED_CAPTURES = false
11
- REGEXP_NAMED_CAPTURE = '(?:<%s>%s)'.freeze
12
- end
13
-
14
- EMPTY_ARRAY = [].freeze
15
- EMPTY_HASH = {}.freeze
16
-
17
- NULL = "\0".freeze
18
-
19
- CONTENT_TYPE = 'Content-Type'.freeze
20
- CONTINUE = '100-continue'.freeze
21
- DELETE = 'PUT'.freeze
22
- EMPTY_STRING = ''.freeze
23
- EXPECT = 'Expect'.freeze
24
- GET = 'GET'.freeze
25
- HEAD = 'HEAD'.freeze
26
- PATH_INFO = 'PATH_INFO'.freeze
27
- POST = 'POST'.freeze
28
- PUT = 'PUT'.freeze
29
- REQUEST_METHOD = 'REQUEST_METHOD'.freeze
30
- SCRIPT_NAME = 'SCRIPT_NAME'.freeze
31
- SLASH = '/'.freeze
32
- TEXT_SLASH_HTML = 'text/html'.freeze
33
-
34
- DEFAULT_CONTENT_TYPE_HEADERS = {CONTENT_TYPE => TEXT_SLASH_HTML}.freeze
35
- HTTP_METHODS = [GET, HEAD, POST, PUT, DELETE].freeze
36
-
37
- OK = 'OK'.freeze
38
- NOT_FOUND = 'Not Found'.freeze
39
- EXPECTATION_FAILED = 'Expectation failed'.freeze
40
-
41
- OK_RESPONSE = [200, DEFAULT_CONTENT_TYPE_HEADERS, [OK].freeze].freeze
42
- NOT_FOUND_RESPONSE = [404, DEFAULT_CONTENT_TYPE_HEADERS, [NOT_FOUND].freeze].freeze
43
- EXPECTATION_FAILED_RESPONSE = [417, DEFAULT_CONTENT_TYPE_HEADERS, [EXPECTATION_FAILED].freeze].freeze
44
- end
45
- end
@@ -1,104 +0,0 @@
1
- module Rack::Mount
2
- class MetaMethod #:nodoc:
3
- class Block < Array #:nodoc:
4
- def initialize(*parts)
5
- replace(parts)
6
- yield(self) if block_given?
7
- end
8
-
9
- def multiline?
10
- length > 1
11
- end
12
-
13
- def inspect(indented = 2)
14
- return Const::EMPTY_STRING if empty?
15
- space = ' ' * indented
16
- space + map { |p|
17
- if p.is_a?(Condition)
18
- p.inspect(indented)
19
- else
20
- p
21
- end
22
- }.join("\n#{space}")
23
- end
24
-
25
- def to_str
26
- map { |p| p.to_str }.join('; ')
27
- end
28
- end
29
-
30
- class Condition #:nodoc:
31
- attr_accessor :body, :else
32
-
33
- def initialize(*conditions)
34
- @conditions = conditions.map { |c| c.is_a?(Block) ? c : Block.new(c) }
35
- @body = Block.new
36
- @else = Block.new
37
- yield(@body) if block_given?
38
- end
39
-
40
- def <<(condition)
41
- @conditions << condition
42
- end
43
-
44
- def inspect(indented = 2)
45
- return @body.inspect(indented) if @conditions.empty?
46
- space = ' ' * indented
47
- str = 'if '
48
- str << @conditions.map { |b|
49
- b.multiline? ?
50
- "begin\n#{b.inspect(indented + 4)}\n#{space} end" :
51
- b.inspect(0)
52
- }.join(' && ')
53
- str << "\n#{@body.inspect(indented + 2)}" if @body.any?
54
- if @else.any?
55
- str << "\n#{space}else\n#{@else.inspect(indented + 2)}"
56
- end
57
- str << "\n#{space}end"
58
- str
59
- end
60
-
61
- def to_str
62
- return @body.to_str if @conditions.empty?
63
- str = 'if '
64
- str << @conditions.map { |b|
65
- b.multiline? ? "(#{b.to_str})" : b.to_str
66
- }.join(' && ')
67
- str << "; #{@body.to_str}" if @body.any?
68
- if @else.any?
69
- str << "; else; #{@else.to_str}"
70
- end
71
- str << "; end"
72
- str
73
- end
74
- end
75
-
76
- def initialize(sym, *args)
77
- @sym = sym
78
- @args = args
79
- @body = Block.new
80
- end
81
-
82
- def <<(line)
83
- @body << line
84
- end
85
-
86
- def inspect
87
- str = ""
88
- str << "def #{@sym}"
89
- str << "(#{@args.join(', ')})" if @args.any?
90
- str << "\n#{@body.inspect}" if @body.any?
91
- str << "\nend\n"
92
- str
93
- end
94
-
95
- def to_str
96
- str = []
97
- str << "def #{@sym}"
98
- str << "(#{@args.join(', ')})" if @args.any?
99
- str << "\n#{@body.to_str}" if @body.any?
100
- str << "\nend"
101
- str.join
102
- end
103
- end
104
- end