Class: AePageObjects::RakeRouter
Defined Under Namespace
Classes: Param, Path, Route
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(rake_routes, mounted_prefix = '') ⇒ RakeRouter
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/ae_page_objects/core/rake_router.rb', line 6
def initialize(rake_routes, mounted_prefix = '')
@mounted_prefix = mounted_prefix || ""
@routes = {}
route_line_regex = /(\w+)(?:\s[A-Z]+)?\s+(\/.*)\(.:format\).*$/
rake_routes.split("\n").each do |line|
line = line.strip
matches = route_line_regex.match(line)
if matches
@routes[matches[1].to_sym] = Route.new(matches[2], @mounted_prefix)
end
end
end
|
Instance Attribute Details
#routes ⇒ Object
Returns the value of attribute routes.
4
5
6
|
# File 'lib/ae_page_objects/core/rake_router.rb', line 4
def routes
@routes
end
|
Instance Method Details
#generate_path(named_route, *args) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/ae_page_objects/core/rake_router.rb', line 29
def generate_path(named_route, *args)
if named_route.is_a?(String)
return Path.new(@mounted_prefix + named_route)
end
if route = @routes[named_route]
options = args.last.is_a?(Hash) ? args.pop : {}
route.generate_path(options)
end
end
|
#path_recognizes_url?(path, url) ⇒ Boolean
20
21
22
23
24
25
26
27
|
# File 'lib/ae_page_objects/core/rake_router.rb', line 20
def path_recognizes_url?(path, url)
if path.is_a?(Symbol)
route = @routes[path]
route && route.matches?(url)
else
super
end
end
|