actionpack 4.0.1 → 4.2.11.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +402 -1173
- data/MIT-LICENSE +1 -1
- data/README.rdoc +7 -7
- data/lib/abstract_controller/base.rb +39 -7
- data/lib/abstract_controller/callbacks.rb +32 -53
- data/lib/abstract_controller/collector.rb +11 -1
- data/lib/abstract_controller/helpers.rb +26 -16
- data/lib/abstract_controller/railties/routes_helpers.rb +3 -3
- data/lib/abstract_controller/rendering.rb +57 -127
- data/lib/abstract_controller/url_for.rb +1 -1
- data/lib/abstract_controller.rb +1 -2
- data/lib/action_controller/base.rb +19 -10
- data/lib/action_controller/caching/fragments.rb +7 -1
- data/lib/action_controller/caching.rb +2 -12
- data/lib/action_controller/log_subscriber.rb +29 -20
- data/lib/action_controller/metal/conditional_get.rb +37 -12
- data/lib/action_controller/metal/data_streaming.rb +1 -1
- data/lib/action_controller/metal/etag_with_template_digest.rb +50 -0
- data/lib/action_controller/metal/exceptions.rb +1 -1
- data/lib/action_controller/metal/flash.rb +17 -0
- data/lib/action_controller/metal/force_ssl.rb +2 -2
- data/lib/action_controller/metal/head.rb +8 -6
- data/lib/action_controller/metal/helpers.rb +6 -2
- data/lib/action_controller/metal/http_authentication.rb +45 -23
- data/lib/action_controller/metal/instrumentation.rb +9 -6
- data/lib/action_controller/metal/live.rb +173 -20
- data/lib/action_controller/metal/mime_responds.rb +127 -232
- data/lib/action_controller/metal/params_wrapper.rb +16 -9
- data/lib/action_controller/metal/rack_delegation.rb +1 -1
- data/lib/action_controller/metal/redirecting.rb +34 -26
- data/lib/action_controller/metal/renderers.rb +39 -12
- data/lib/action_controller/metal/rendering.rb +41 -14
- data/lib/action_controller/metal/request_forgery_protection.rb +147 -19
- data/lib/action_controller/metal/streaming.rb +19 -21
- data/lib/action_controller/metal/strong_parameters.rb +166 -22
- data/lib/action_controller/metal/testing.rb +0 -1
- data/lib/action_controller/metal/url_for.rb +11 -12
- data/lib/action_controller/metal.rb +14 -8
- data/lib/action_controller/model_naming.rb +1 -1
- data/lib/action_controller/railtie.rb +5 -1
- data/lib/action_controller/test_case.rb +160 -94
- data/lib/action_controller.rb +2 -18
- data/lib/action_dispatch/http/cache.rb +5 -4
- data/lib/action_dispatch/http/filter_parameters.rb +2 -2
- data/lib/action_dispatch/http/filter_redirect.rb +5 -4
- data/lib/action_dispatch/http/headers.rb +46 -10
- data/lib/action_dispatch/http/mime_negotiation.rb +31 -4
- data/lib/action_dispatch/http/mime_type.rb +25 -26
- data/lib/action_dispatch/http/mime_types.rb +1 -0
- data/lib/action_dispatch/http/parameter_filter.rb +1 -1
- data/lib/action_dispatch/http/parameters.rb +25 -41
- data/lib/action_dispatch/http/request.rb +49 -32
- data/lib/action_dispatch/http/response.rb +127 -25
- data/lib/action_dispatch/http/upload.rb +9 -21
- data/lib/action_dispatch/http/url.rb +97 -70
- data/lib/action_dispatch/journey/formatter.rb +35 -19
- data/lib/action_dispatch/journey/gtg/builder.rb +3 -3
- data/lib/action_dispatch/journey/gtg/simulator.rb +10 -7
- data/lib/action_dispatch/journey/gtg/transition_table.rb +23 -33
- data/lib/action_dispatch/journey/nfa/dot.rb +2 -2
- data/lib/action_dispatch/journey/nfa/simulator.rb +1 -1
- data/lib/action_dispatch/journey/nfa/transition_table.rb +5 -5
- data/lib/action_dispatch/journey/nodes/node.rb +4 -0
- data/lib/action_dispatch/journey/parser.rb +51 -59
- data/lib/action_dispatch/journey/parser.y +12 -10
- data/lib/action_dispatch/journey/path/pattern.rb +16 -19
- data/lib/action_dispatch/journey/route.rb +8 -19
- data/lib/action_dispatch/journey/router/strexp.rb +9 -6
- data/lib/action_dispatch/journey/router/utils.rb +54 -18
- data/lib/action_dispatch/journey/router.rb +53 -75
- data/lib/action_dispatch/journey/routes.rb +4 -0
- data/lib/action_dispatch/journey/scanner.rb +5 -5
- data/lib/action_dispatch/journey/visitors.rb +81 -60
- data/lib/action_dispatch/journey/visualizer/fsm.css +0 -4
- data/lib/action_dispatch/journey/visualizer/index.html.erb +2 -2
- data/lib/action_dispatch/middleware/callbacks.rb +7 -7
- data/lib/action_dispatch/middleware/cookies.rb +119 -43
- data/lib/action_dispatch/middleware/debug_exceptions.rb +32 -13
- data/lib/action_dispatch/middleware/exception_wrapper.rb +60 -20
- data/lib/action_dispatch/middleware/flash.rb +37 -24
- data/lib/action_dispatch/middleware/params_parser.rb +2 -2
- data/lib/action_dispatch/middleware/public_exceptions.rb +12 -3
- data/lib/action_dispatch/middleware/reloader.rb +11 -2
- data/lib/action_dispatch/middleware/remote_ip.rb +40 -54
- data/lib/action_dispatch/middleware/request_id.rb +1 -1
- data/lib/action_dispatch/middleware/session/cache_store.rb +3 -3
- data/lib/action_dispatch/middleware/session/cookie_store.rb +8 -7
- data/lib/action_dispatch/middleware/show_exceptions.rb +6 -2
- data/lib/action_dispatch/middleware/ssl.rb +10 -7
- data/lib/action_dispatch/middleware/static.rb +79 -23
- data/lib/action_dispatch/middleware/templates/rescues/{_request_and_response.erb → _request_and_response.html.erb} +0 -0
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
- data/lib/action_dispatch/middleware/templates/rescues/_source.erb +21 -19
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +52 -0
- data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +9 -0
- data/lib/action_dispatch/middleware/templates/rescues/{diagnostics.erb → diagnostics.html.erb} +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +6 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +11 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
- data/lib/action_dispatch/middleware/templates/rescues/{routing_error.erb → routing_error.html.erb} +3 -1
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +20 -0
- data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +7 -0
- data/lib/action_dispatch/middleware/templates/rescues/{unknown_action.erb → unknown_action.html.erb} +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +120 -64
- data/lib/action_dispatch/railtie.rb +5 -2
- data/lib/action_dispatch/request/session.rb +12 -0
- data/lib/action_dispatch/request/utils.rb +35 -0
- data/lib/action_dispatch/routing/endpoint.rb +10 -0
- data/lib/action_dispatch/routing/inspector.rb +11 -17
- data/lib/action_dispatch/routing/mapper.rb +519 -312
- data/lib/action_dispatch/routing/polymorphic_routes.rb +204 -79
- data/lib/action_dispatch/routing/redirection.rb +51 -26
- data/lib/action_dispatch/routing/route_set.rb +331 -206
- data/lib/action_dispatch/routing/routes_proxy.rb +5 -4
- data/lib/action_dispatch/routing/url_for.rb +19 -5
- data/lib/action_dispatch/routing.rb +9 -6
- data/lib/action_dispatch/testing/assertions/dom.rb +2 -26
- data/lib/action_dispatch/testing/assertions/response.rb +9 -15
- data/lib/action_dispatch/testing/assertions/routing.rb +22 -22
- data/lib/action_dispatch/testing/assertions/selector.rb +2 -429
- data/lib/action_dispatch/testing/assertions/tag.rb +2 -134
- data/lib/action_dispatch/testing/assertions.rb +11 -7
- data/lib/action_dispatch/testing/integration.rb +31 -29
- data/lib/action_dispatch/testing/test_request.rb +1 -1
- data/lib/action_dispatch/testing/test_response.rb +1 -5
- data/lib/action_dispatch.rb +5 -8
- data/lib/action_pack/gem_version.rb +15 -0
- data/lib/action_pack/version.rb +4 -7
- data/lib/action_pack.rb +1 -1
- metadata +77 -159
- data/lib/abstract_controller/layouts.rb +0 -423
- data/lib/abstract_controller/view_paths.rb +0 -96
- data/lib/action_controller/deprecated/integration_test.rb +0 -5
- data/lib/action_controller/deprecated.rb +0 -7
- data/lib/action_controller/metal/responder.rb +0 -287
- data/lib/action_controller/record_identifier.rb +0 -31
- data/lib/action_controller/vendor/html-scanner.rb +0 -5
- data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +0 -24
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.erb +0 -7
- data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +0 -43
- data/lib/action_view/base.rb +0 -201
- data/lib/action_view/buffers.rb +0 -49
- data/lib/action_view/context.rb +0 -36
- data/lib/action_view/dependency_tracker.rb +0 -93
- data/lib/action_view/digestor.rb +0 -113
- data/lib/action_view/flows.rb +0 -76
- data/lib/action_view/helpers/active_model_helper.rb +0 -49
- data/lib/action_view/helpers/asset_tag_helper.rb +0 -320
- data/lib/action_view/helpers/asset_url_helper.rb +0 -355
- data/lib/action_view/helpers/atom_feed_helper.rb +0 -203
- data/lib/action_view/helpers/cache_helper.rb +0 -196
- data/lib/action_view/helpers/capture_helper.rb +0 -216
- data/lib/action_view/helpers/controller_helper.rb +0 -25
- data/lib/action_view/helpers/csrf_helper.rb +0 -30
- data/lib/action_view/helpers/date_helper.rb +0 -1083
- data/lib/action_view/helpers/debug_helper.rb +0 -39
- data/lib/action_view/helpers/form_helper.rb +0 -1880
- data/lib/action_view/helpers/form_options_helper.rb +0 -838
- data/lib/action_view/helpers/form_tag_helper.rb +0 -785
- data/lib/action_view/helpers/javascript_helper.rb +0 -117
- data/lib/action_view/helpers/number_helper.rb +0 -441
- data/lib/action_view/helpers/output_safety_helper.rb +0 -38
- data/lib/action_view/helpers/record_tag_helper.rb +0 -106
- data/lib/action_view/helpers/rendering_helper.rb +0 -90
- data/lib/action_view/helpers/sanitize_helper.rb +0 -256
- data/lib/action_view/helpers/tag_helper.rb +0 -173
- data/lib/action_view/helpers/tags/base.rb +0 -148
- data/lib/action_view/helpers/tags/check_box.rb +0 -64
- data/lib/action_view/helpers/tags/checkable.rb +0 -16
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +0 -44
- data/lib/action_view/helpers/tags/collection_helpers.rb +0 -84
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +0 -36
- data/lib/action_view/helpers/tags/collection_select.rb +0 -28
- data/lib/action_view/helpers/tags/color_field.rb +0 -25
- data/lib/action_view/helpers/tags/date_field.rb +0 -13
- data/lib/action_view/helpers/tags/date_select.rb +0 -72
- data/lib/action_view/helpers/tags/datetime_field.rb +0 -22
- data/lib/action_view/helpers/tags/datetime_local_field.rb +0 -19
- data/lib/action_view/helpers/tags/datetime_select.rb +0 -8
- data/lib/action_view/helpers/tags/email_field.rb +0 -8
- data/lib/action_view/helpers/tags/file_field.rb +0 -8
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +0 -29
- data/lib/action_view/helpers/tags/hidden_field.rb +0 -8
- data/lib/action_view/helpers/tags/label.rb +0 -66
- data/lib/action_view/helpers/tags/month_field.rb +0 -13
- data/lib/action_view/helpers/tags/number_field.rb +0 -18
- data/lib/action_view/helpers/tags/password_field.rb +0 -12
- data/lib/action_view/helpers/tags/radio_button.rb +0 -31
- data/lib/action_view/helpers/tags/range_field.rb +0 -8
- data/lib/action_view/helpers/tags/search_field.rb +0 -24
- data/lib/action_view/helpers/tags/select.rb +0 -40
- data/lib/action_view/helpers/tags/tel_field.rb +0 -8
- data/lib/action_view/helpers/tags/text_area.rb +0 -18
- data/lib/action_view/helpers/tags/text_field.rb +0 -29
- data/lib/action_view/helpers/tags/time_field.rb +0 -13
- data/lib/action_view/helpers/tags/time_select.rb +0 -8
- data/lib/action_view/helpers/tags/time_zone_select.rb +0 -20
- data/lib/action_view/helpers/tags/url_field.rb +0 -8
- data/lib/action_view/helpers/tags/week_field.rb +0 -13
- data/lib/action_view/helpers/tags.rb +0 -39
- data/lib/action_view/helpers/text_helper.rb +0 -443
- data/lib/action_view/helpers/translation_helper.rb +0 -107
- data/lib/action_view/helpers/url_helper.rb +0 -635
- data/lib/action_view/helpers.rb +0 -58
- data/lib/action_view/locale/en.yml +0 -56
- data/lib/action_view/log_subscriber.rb +0 -30
- data/lib/action_view/lookup_context.rb +0 -241
- data/lib/action_view/model_naming.rb +0 -12
- data/lib/action_view/path_set.rb +0 -77
- data/lib/action_view/railtie.rb +0 -43
- data/lib/action_view/record_identifier.rb +0 -84
- data/lib/action_view/renderer/abstract_renderer.rb +0 -47
- data/lib/action_view/renderer/partial_renderer.rb +0 -492
- data/lib/action_view/renderer/renderer.rb +0 -50
- data/lib/action_view/renderer/streaming_template_renderer.rb +0 -103
- data/lib/action_view/renderer/template_renderer.rb +0 -96
- data/lib/action_view/routing_url_for.rb +0 -107
- data/lib/action_view/tasks/dependencies.rake +0 -17
- data/lib/action_view/template/error.rb +0 -138
- data/lib/action_view/template/handlers/builder.rb +0 -26
- data/lib/action_view/template/handlers/erb.rb +0 -146
- data/lib/action_view/template/handlers/raw.rb +0 -11
- data/lib/action_view/template/handlers.rb +0 -53
- data/lib/action_view/template/resolver.rb +0 -326
- data/lib/action_view/template/text.rb +0 -34
- data/lib/action_view/template/types.rb +0 -57
- data/lib/action_view/template.rb +0 -339
- data/lib/action_view/test_case.rb +0 -270
- data/lib/action_view/testing/resolvers.rb +0 -50
- data/lib/action_view/vendor/html-scanner/html/document.rb +0 -68
- data/lib/action_view/vendor/html-scanner/html/node.rb +0 -532
- data/lib/action_view/vendor/html-scanner/html/sanitizer.rb +0 -188
- data/lib/action_view/vendor/html-scanner/html/selector.rb +0 -830
- data/lib/action_view/vendor/html-scanner/html/tokenizer.rb +0 -107
- data/lib/action_view/vendor/html-scanner/html/version.rb +0 -11
- data/lib/action_view/vendor/html-scanner.rb +0 -20
- data/lib/action_view.rb +0 -93
@@ -27,7 +27,7 @@ module ActionDispatch
|
|
27
27
|
marked[s] = true # mark s
|
28
28
|
|
29
29
|
s.group_by { |state| symbol(state) }.each do |sym, ps|
|
30
|
-
u = ps.
|
30
|
+
u = ps.flat_map { |l| followpos(l) }
|
31
31
|
next if u.empty?
|
32
32
|
|
33
33
|
if u.uniq == [DUMMY]
|
@@ -90,7 +90,7 @@ module ActionDispatch
|
|
90
90
|
firstpos(node.left)
|
91
91
|
end
|
92
92
|
when Nodes::Or
|
93
|
-
node.children.
|
93
|
+
node.children.flat_map { |c| firstpos(c) }.uniq
|
94
94
|
when Nodes::Unary
|
95
95
|
firstpos(node.left)
|
96
96
|
when Nodes::Terminal
|
@@ -105,7 +105,7 @@ module ActionDispatch
|
|
105
105
|
when Nodes::Star
|
106
106
|
firstpos(node.left)
|
107
107
|
when Nodes::Or
|
108
|
-
node.children.
|
108
|
+
node.children.flat_map { |c| lastpos(c) }.uniq
|
109
109
|
when Nodes::Cat
|
110
110
|
if nullable?(node.right)
|
111
111
|
lastpos(node.left) | lastpos(node.right)
|
@@ -19,6 +19,14 @@ module ActionDispatch
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def simulate(string)
|
22
|
+
ms = memos(string) { return }
|
23
|
+
MatchData.new(ms)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias :=~ :simulate
|
27
|
+
alias :match :simulate
|
28
|
+
|
29
|
+
def memos(string)
|
22
30
|
input = StringScanner.new(string)
|
23
31
|
state = [0]
|
24
32
|
while sym = input.scan(%r([/.?]|[^/.?]+))
|
@@ -29,15 +37,10 @@ module ActionDispatch
|
|
29
37
|
tt.accepting? s
|
30
38
|
}
|
31
39
|
|
32
|
-
return if acceptance_states.empty?
|
40
|
+
return yield if acceptance_states.empty?
|
33
41
|
|
34
|
-
|
35
|
-
|
36
|
-
MatchData.new(memos)
|
42
|
+
acceptance_states.flat_map { |x| tt.memo(x) }.compact
|
37
43
|
end
|
38
|
-
|
39
|
-
alias :=~ :simulate
|
40
|
-
alias :match :simulate
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -40,12 +40,22 @@ module ActionDispatch
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def move(t, a)
|
43
|
-
|
44
|
-
|
43
|
+
return [] if t.empty?
|
44
|
+
|
45
|
+
regexps = []
|
46
|
+
|
47
|
+
t.map { |s|
|
48
|
+
if states = @regexp_states[s]
|
49
|
+
regexps.concat states.map { |re, v| re === a ? v : nil }
|
50
|
+
end
|
45
51
|
|
46
|
-
|
47
|
-
|
52
|
+
if states = @string_states[s]
|
53
|
+
states[a]
|
54
|
+
end
|
55
|
+
}.compact.concat regexps
|
56
|
+
end
|
48
57
|
|
58
|
+
def as_json(options = nil)
|
49
59
|
simple_regexp = Hash.new { |h,k| h[k] = {} }
|
50
60
|
|
51
61
|
@regexp_states.each do |from, hash|
|
@@ -54,11 +64,11 @@ module ActionDispatch
|
|
54
64
|
end
|
55
65
|
end
|
56
66
|
|
57
|
-
|
67
|
+
{
|
58
68
|
regexp_states: simple_regexp,
|
59
69
|
string_states: @string_states,
|
60
70
|
accepting: @accepting
|
61
|
-
}
|
71
|
+
}
|
62
72
|
end
|
63
73
|
|
64
74
|
def to_svg
|
@@ -78,13 +88,13 @@ module ActionDispatch
|
|
78
88
|
erb = File.read File.join(viz_dir, 'index.html.erb')
|
79
89
|
states = "function tt() { return #{to_json}; }"
|
80
90
|
|
81
|
-
fun_routes = paths.
|
91
|
+
fun_routes = paths.sample(3).map do |ast|
|
82
92
|
ast.map { |n|
|
83
93
|
case n
|
84
94
|
when Nodes::Symbol
|
85
95
|
case n.left
|
86
96
|
when ':id' then rand(100).to_s
|
87
|
-
when ':format' then %w{ xml json }.
|
97
|
+
when ':format' then %w{ xml json }.sample
|
88
98
|
else
|
89
99
|
'omg'
|
90
100
|
end
|
@@ -116,17 +126,17 @@ module ActionDispatch
|
|
116
126
|
end
|
117
127
|
|
118
128
|
def states
|
119
|
-
ss = @string_states.keys + @string_states.values.
|
120
|
-
rs = @regexp_states.keys + @regexp_states.values.
|
129
|
+
ss = @string_states.keys + @string_states.values.flat_map(&:values)
|
130
|
+
rs = @regexp_states.keys + @regexp_states.values.flat_map(&:values)
|
121
131
|
(ss + rs).uniq
|
122
132
|
end
|
123
133
|
|
124
134
|
def transitions
|
125
|
-
@string_states.
|
135
|
+
@string_states.flat_map { |from, hash|
|
126
136
|
hash.map { |s, to| [from, s, to] }
|
127
|
-
}
|
137
|
+
} + @regexp_states.flat_map { |from, hash|
|
128
138
|
hash.map { |s, to| [from, s, to] }
|
129
|
-
}
|
139
|
+
}
|
130
140
|
end
|
131
141
|
|
132
142
|
private
|
@@ -141,26 +151,6 @@ module ActionDispatch
|
|
141
151
|
raise ArgumentError, 'unknown symbol: %s' % sym.class
|
142
152
|
end
|
143
153
|
end
|
144
|
-
|
145
|
-
def move_regexp(t, a)
|
146
|
-
return [] if t.empty?
|
147
|
-
|
148
|
-
t.map { |s|
|
149
|
-
if states = @regexp_states[s]
|
150
|
-
states.map { |re, v| re === a ? v : nil }
|
151
|
-
end
|
152
|
-
}.flatten.compact.uniq
|
153
|
-
end
|
154
|
-
|
155
|
-
def move_string(t, a)
|
156
|
-
return [] if t.empty?
|
157
|
-
|
158
|
-
t.map do |s|
|
159
|
-
if states = @string_states[s]
|
160
|
-
states[a]
|
161
|
-
end
|
162
|
-
end.compact
|
163
|
-
end
|
164
154
|
end
|
165
155
|
end
|
166
156
|
end
|
@@ -16,9 +16,9 @@ module ActionDispatch
|
|
16
16
|
# end
|
17
17
|
# " #{n.object_id} [label=\"#{label}\", shape=box];"
|
18
18
|
#}
|
19
|
-
#memo_edges = memos.
|
19
|
+
#memo_edges = memos.flat_map { |k, memos|
|
20
20
|
# (memos || []).map { |v| " #{k} -> #{v.object_id};" }
|
21
|
-
#}.
|
21
|
+
#}.uniq
|
22
22
|
|
23
23
|
<<-eodot
|
24
24
|
digraph nfa {
|
@@ -42,7 +42,7 @@ module ActionDispatch
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def states
|
45
|
-
(@table.keys + @table.values.
|
45
|
+
(@table.keys + @table.values.flat_map(&:keys)).uniq
|
46
46
|
end
|
47
47
|
|
48
48
|
# Returns a generalized transition graph with reduced states. The states
|
@@ -93,7 +93,7 @@ module ActionDispatch
|
|
93
93
|
# Returns set of NFA states to which there is a transition on ast symbol
|
94
94
|
# +a+ from some state +s+ in +t+.
|
95
95
|
def following_states(t, a)
|
96
|
-
Array(t).
|
96
|
+
Array(t).flat_map { |s| inverted[s][a] }.uniq
|
97
97
|
end
|
98
98
|
|
99
99
|
# Returns set of NFA states to which there is a transition on ast symbol
|
@@ -107,7 +107,7 @@ module ActionDispatch
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def alphabet
|
110
|
-
inverted.values.
|
110
|
+
inverted.values.flat_map(&:keys).compact.uniq.sort_by { |x| x.to_s }
|
111
111
|
end
|
112
112
|
|
113
113
|
# Returns a set of NFA states reachable from some NFA state +s+ in set
|
@@ -131,9 +131,9 @@ module ActionDispatch
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def transitions
|
134
|
-
@table.
|
134
|
+
@table.flat_map { |to, hash|
|
135
135
|
hash.map { |from, sym| [from, sym, to] }
|
136
|
-
}
|
136
|
+
}
|
137
137
|
end
|
138
138
|
|
139
139
|
private
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.
|
3
|
+
# This file is automatically generated by Racc 1.4.11
|
4
4
|
# from Racc grammer file "".
|
5
5
|
#
|
6
6
|
|
@@ -9,42 +9,38 @@ require 'racc/parser.rb'
|
|
9
9
|
|
10
10
|
require 'action_dispatch/journey/parser_extras'
|
11
11
|
module ActionDispatch
|
12
|
-
module Journey
|
13
|
-
class Parser < Racc::Parser
|
12
|
+
module Journey
|
13
|
+
class Parser < Racc::Parser
|
14
14
|
##### State transition tables begin ###
|
15
15
|
|
16
16
|
racc_action_table = [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
16, 8, 13, 15, 14, 7, nil, 16, 8 ]
|
17
|
+
13, 15, 14, 7, 21, 16, 8, 19, 13, 15,
|
18
|
+
14, 7, 17, 16, 8, 13, 15, 14, 7, 24,
|
19
|
+
16, 8, 13, 15, 14, 7, 19, 16, 8 ]
|
21
20
|
|
22
21
|
racc_action_check = [
|
23
|
-
|
24
|
-
|
25
|
-
7, 7,
|
26
|
-
19, 19, 0, 0, 0, 0, nil, 0, 0 ]
|
22
|
+
2, 2, 2, 2, 17, 2, 2, 2, 0, 0,
|
23
|
+
0, 0, 1, 0, 0, 19, 19, 19, 19, 20,
|
24
|
+
19, 19, 7, 7, 7, 7, 22, 7, 7 ]
|
27
25
|
|
28
26
|
racc_action_pointer = [
|
29
|
-
|
30
|
-
nil, nil, nil, nil, nil, nil, nil,
|
31
|
-
|
27
|
+
6, 12, -2, nil, nil, nil, nil, 20, nil, nil,
|
28
|
+
nil, nil, nil, nil, nil, nil, nil, 4, nil, 13,
|
29
|
+
13, nil, 17, nil, nil ]
|
32
30
|
|
33
31
|
racc_action_default = [
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
32
|
+
-19, -19, -2, -3, -4, -5, -6, -19, -10, -11,
|
33
|
+
-12, -13, -14, -15, -16, -17, -18, -19, -1, -19,
|
34
|
+
-19, 25, -8, -9, -7 ]
|
37
35
|
|
38
36
|
racc_goto_table = [
|
39
|
-
|
40
|
-
nil, nil, nil, nil, nil, nil, nil, nil, 22, 18 ]
|
37
|
+
1, 22, 18, 23, nil, nil, nil, 20 ]
|
41
38
|
|
42
39
|
racc_goto_check = [
|
43
|
-
2, 1,
|
44
|
-
nil, nil, nil, nil, nil, nil, nil, nil, 2, 2 ]
|
40
|
+
1, 2, 1, 3, nil, nil, nil, 1 ]
|
45
41
|
|
46
42
|
racc_goto_pointer = [
|
47
|
-
nil,
|
43
|
+
nil, 0, -18, -16, nil, nil, nil, nil, nil, nil,
|
48
44
|
nil ]
|
49
45
|
|
50
46
|
racc_goto_default = [
|
@@ -61,19 +57,20 @@ racc_reduce_table = [
|
|
61
57
|
1, 12, :_reduce_none,
|
62
58
|
3, 15, :_reduce_7,
|
63
59
|
3, 13, :_reduce_8,
|
64
|
-
|
60
|
+
3, 13, :_reduce_9,
|
61
|
+
1, 16, :_reduce_10,
|
65
62
|
1, 14, :_reduce_none,
|
66
63
|
1, 14, :_reduce_none,
|
67
64
|
1, 14, :_reduce_none,
|
68
65
|
1, 14, :_reduce_none,
|
69
|
-
1, 19, :
|
70
|
-
1, 17, :
|
71
|
-
1, 18, :
|
72
|
-
1, 20, :
|
66
|
+
1, 19, :_reduce_15,
|
67
|
+
1, 17, :_reduce_16,
|
68
|
+
1, 18, :_reduce_17,
|
69
|
+
1, 20, :_reduce_18 ]
|
73
70
|
|
74
|
-
racc_reduce_n =
|
71
|
+
racc_reduce_n = 19
|
75
72
|
|
76
|
-
racc_shift_n =
|
73
|
+
racc_shift_n = 25
|
77
74
|
|
78
75
|
racc_token_table = {
|
79
76
|
false => 0,
|
@@ -89,7 +86,7 @@ racc_token_table = {
|
|
89
86
|
|
90
87
|
racc_nt_base = 10
|
91
88
|
|
92
|
-
racc_use_result_var =
|
89
|
+
racc_use_result_var = false
|
93
90
|
|
94
91
|
Racc_arg = [
|
95
92
|
racc_action_table,
|
@@ -136,14 +133,12 @@ Racc_debug_parser = false
|
|
136
133
|
|
137
134
|
# reduce 0 omitted
|
138
135
|
|
139
|
-
def _reduce_1(val, _values
|
140
|
-
|
141
|
-
result
|
136
|
+
def _reduce_1(val, _values)
|
137
|
+
Cat.new(val.first, val.last)
|
142
138
|
end
|
143
139
|
|
144
|
-
def _reduce_2(val, _values
|
145
|
-
|
146
|
-
result
|
140
|
+
def _reduce_2(val, _values)
|
141
|
+
val.first
|
147
142
|
end
|
148
143
|
|
149
144
|
# reduce 3 omitted
|
@@ -154,22 +149,21 @@ end
|
|
154
149
|
|
155
150
|
# reduce 6 omitted
|
156
151
|
|
157
|
-
def _reduce_7(val, _values
|
158
|
-
|
159
|
-
result
|
152
|
+
def _reduce_7(val, _values)
|
153
|
+
Group.new(val[1])
|
160
154
|
end
|
161
155
|
|
162
|
-
def _reduce_8(val, _values
|
163
|
-
|
164
|
-
result
|
156
|
+
def _reduce_8(val, _values)
|
157
|
+
Or.new([val.first, val.last])
|
165
158
|
end
|
166
159
|
|
167
|
-
def _reduce_9(val, _values
|
168
|
-
|
169
|
-
result
|
160
|
+
def _reduce_9(val, _values)
|
161
|
+
Or.new([val.first, val.last])
|
170
162
|
end
|
171
163
|
|
172
|
-
|
164
|
+
def _reduce_10(val, _values)
|
165
|
+
Star.new(Symbol.new(val.last))
|
166
|
+
end
|
173
167
|
|
174
168
|
# reduce 11 omitted
|
175
169
|
|
@@ -177,27 +171,25 @@ end
|
|
177
171
|
|
178
172
|
# reduce 13 omitted
|
179
173
|
|
180
|
-
|
181
|
-
|
182
|
-
|
174
|
+
# reduce 14 omitted
|
175
|
+
|
176
|
+
def _reduce_15(val, _values)
|
177
|
+
Slash.new('/')
|
183
178
|
end
|
184
179
|
|
185
|
-
def
|
186
|
-
|
187
|
-
result
|
180
|
+
def _reduce_16(val, _values)
|
181
|
+
Symbol.new(val.first)
|
188
182
|
end
|
189
183
|
|
190
|
-
def
|
191
|
-
|
192
|
-
result
|
184
|
+
def _reduce_17(val, _values)
|
185
|
+
Literal.new(val.first)
|
193
186
|
end
|
194
187
|
|
195
|
-
def
|
196
|
-
|
197
|
-
result
|
188
|
+
def _reduce_18(val, _values)
|
189
|
+
Dot.new(val.first)
|
198
190
|
end
|
199
191
|
|
200
|
-
def _reduce_none(val, _values
|
192
|
+
def _reduce_none(val, _values)
|
201
193
|
val[0]
|
202
194
|
end
|
203
195
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class ActionDispatch::Journey::Parser
|
2
|
-
|
2
|
+
options no_result_var
|
3
3
|
token SLASH LITERAL SYMBOL LPAREN RPAREN DOT STAR OR
|
4
4
|
|
5
5
|
rule
|
6
6
|
expressions
|
7
|
-
: expressions
|
8
|
-
| expression {
|
7
|
+
: expression expressions { Cat.new(val.first, val.last) }
|
8
|
+
| expression { val.first }
|
9
9
|
| or
|
10
10
|
;
|
11
11
|
expression
|
@@ -14,13 +14,14 @@ rule
|
|
14
14
|
| star
|
15
15
|
;
|
16
16
|
group
|
17
|
-
: LPAREN expressions RPAREN {
|
17
|
+
: LPAREN expressions RPAREN { Group.new(val[1]) }
|
18
18
|
;
|
19
19
|
or
|
20
|
-
:
|
20
|
+
: expression OR expression { Or.new([val.first, val.last]) }
|
21
|
+
| expression OR or { Or.new([val.first, val.last]) }
|
21
22
|
;
|
22
23
|
star
|
23
|
-
: STAR {
|
24
|
+
: STAR { Star.new(Symbol.new(val.last)) }
|
24
25
|
;
|
25
26
|
terminal
|
26
27
|
: symbol
|
@@ -29,15 +30,16 @@ rule
|
|
29
30
|
| dot
|
30
31
|
;
|
31
32
|
slash
|
32
|
-
: SLASH {
|
33
|
+
: SLASH { Slash.new('/') }
|
33
34
|
;
|
34
35
|
symbol
|
35
|
-
: SYMBOL {
|
36
|
+
: SYMBOL { Symbol.new(val.first) }
|
36
37
|
;
|
37
38
|
literal
|
38
|
-
: LITERAL {
|
39
|
+
: LITERAL { Literal.new(val.first) }
|
40
|
+
;
|
39
41
|
dot
|
40
|
-
: DOT {
|
42
|
+
: DOT { Dot.new(val.first) }
|
41
43
|
;
|
42
44
|
|
43
45
|
end
|
@@ -1,27 +1,20 @@
|
|
1
|
+
require 'action_dispatch/journey/router/strexp'
|
2
|
+
|
1
3
|
module ActionDispatch
|
2
4
|
module Journey # :nodoc:
|
3
5
|
module Path # :nodoc:
|
4
6
|
class Pattern # :nodoc:
|
5
7
|
attr_reader :spec, :requirements, :anchored
|
6
8
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
@anchored = true
|
9
|
+
def self.from_string string
|
10
|
+
new Journey::Router::Strexp.build(string, {}, ["/.?"], true)
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
when Router::Strexp
|
18
|
-
@spec = parser.parse(strexp.path)
|
19
|
-
@requirements = strexp.requirements
|
20
|
-
@separators = strexp.separators.join
|
21
|
-
@anchored = strexp.anchor
|
22
|
-
else
|
23
|
-
raise ArgumentError, "Bad expression: #{strexp}"
|
24
|
-
end
|
13
|
+
def initialize(strexp)
|
14
|
+
@spec = strexp.ast
|
15
|
+
@requirements = strexp.requirements
|
16
|
+
@separators = strexp.separators.join
|
17
|
+
@anchored = strexp.anchor
|
25
18
|
|
26
19
|
@names = nil
|
27
20
|
@optional_names = nil
|
@@ -30,6 +23,10 @@ module ActionDispatch
|
|
30
23
|
@offsets = nil
|
31
24
|
end
|
32
25
|
|
26
|
+
def build_formatter
|
27
|
+
Visitors::FormatBuilder.new.accept(spec)
|
28
|
+
end
|
29
|
+
|
33
30
|
def ast
|
34
31
|
@spec.grep(Nodes::Symbol).each do |node|
|
35
32
|
re = @requirements[node.to_sym]
|
@@ -53,9 +50,9 @@ module ActionDispatch
|
|
53
50
|
end
|
54
51
|
|
55
52
|
def optional_names
|
56
|
-
@optional_names ||= spec.grep(Nodes::Group).
|
53
|
+
@optional_names ||= spec.grep(Nodes::Group).flat_map { |group|
|
57
54
|
group.grep(Nodes::Symbol)
|
58
|
-
}.
|
55
|
+
}.map { |n| n.name }.uniq
|
59
56
|
end
|
60
57
|
|
61
58
|
class RegexpOffsets < Journey::Visitors::Visitor # :nodoc:
|
@@ -16,14 +16,6 @@ module ActionDispatch
|
|
16
16
|
@app = app
|
17
17
|
@path = path
|
18
18
|
|
19
|
-
# Unwrap any constraints so we can see what's inside for route generation.
|
20
|
-
# This allows the formatter to skip over any mounted applications or redirects
|
21
|
-
# that shouldn't be matched when using a url_for without a route name.
|
22
|
-
while app.is_a?(Routing::Mapper::Constraints) do
|
23
|
-
app = app.app
|
24
|
-
end
|
25
|
-
@dispatcher = app.is_a?(Routing::RouteSet::Dispatcher)
|
26
|
-
|
27
19
|
@constraints = constraints
|
28
20
|
@defaults = defaults
|
29
21
|
@required_defaults = nil
|
@@ -31,6 +23,7 @@ module ActionDispatch
|
|
31
23
|
@parts = nil
|
32
24
|
@decorated_ast = nil
|
33
25
|
@precedence = 0
|
26
|
+
@path_formatter = @path.build_formatter
|
34
27
|
end
|
35
28
|
|
36
29
|
def ast
|
@@ -43,7 +36,7 @@ module ActionDispatch
|
|
43
36
|
|
44
37
|
def requirements # :nodoc:
|
45
38
|
# needed for rails `rake routes`
|
46
|
-
path.requirements
|
39
|
+
@defaults.merge(path.requirements).delete_if { |_,v|
|
47
40
|
/.+?/ == v
|
48
41
|
}
|
49
42
|
end
|
@@ -72,15 +65,7 @@ module ActionDispatch
|
|
72
65
|
alias :segment_keys :parts
|
73
66
|
|
74
67
|
def format(path_options)
|
75
|
-
|
76
|
-
value.to_s == defaults[key].to_s && !required_parts.include?(key)
|
77
|
-
end
|
78
|
-
|
79
|
-
Visitors::Formatter.new(path_options).accept(path.spec)
|
80
|
-
end
|
81
|
-
|
82
|
-
def optimized_path
|
83
|
-
Visitors::OptimizedPath.new.accept(path.spec)
|
68
|
+
@path_formatter.evaluate path_options
|
84
69
|
end
|
85
70
|
|
86
71
|
def optional_parts
|
@@ -101,8 +86,12 @@ module ActionDispatch
|
|
101
86
|
end
|
102
87
|
end
|
103
88
|
|
89
|
+
def glob?
|
90
|
+
!path.spec.grep(Nodes::Star).empty?
|
91
|
+
end
|
92
|
+
|
104
93
|
def dispatcher?
|
105
|
-
@dispatcher
|
94
|
+
@app.dispatcher?
|
106
95
|
end
|
107
96
|
|
108
97
|
def matches?(request)
|
@@ -6,18 +6,21 @@ module ActionDispatch
|
|
6
6
|
alias :compile :new
|
7
7
|
end
|
8
8
|
|
9
|
-
attr_reader :path, :requirements, :separators, :anchor
|
9
|
+
attr_reader :path, :requirements, :separators, :anchor, :ast
|
10
10
|
|
11
|
-
def
|
11
|
+
def self.build(path, requirements, separators, anchor = true)
|
12
|
+
parser = Journey::Parser.new
|
13
|
+
ast = parser.parse path
|
14
|
+
new ast, path, requirements, separators, anchor
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(ast, path, requirements, separators, anchor = true)
|
18
|
+
@ast = ast
|
12
19
|
@path = path
|
13
20
|
@requirements = requirements
|
14
21
|
@separators = separators
|
15
22
|
@anchor = anchor
|
16
23
|
end
|
17
|
-
|
18
|
-
def names
|
19
|
-
@path.scan(/:\w+/).map { |s| s.tr(':', '') }
|
20
|
-
end
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|