sinatra_more 0.3.16 → 0.3.18
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.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.18
|
@@ -11,7 +11,7 @@ module SinatraMore
|
|
11
11
|
# Used to define the url mapping to the supplied alias
|
12
12
|
# NamedRoute.new(@app, :account).to('/account/path')
|
13
13
|
def to(path)
|
14
|
-
@app.named_paths[@names.unshift(@app.app_name)] =
|
14
|
+
@app.named_paths[@names.unshift(@app.app_name)] = path
|
15
15
|
end
|
16
16
|
|
17
17
|
# Used to define the url mappings for child aliases within a namespace
|
@@ -9,7 +9,7 @@ module SinatraMore
|
|
9
9
|
values = route_name.extract_options!
|
10
10
|
mapped_url = self.class.named_paths[route_name] || self.class.named_paths[route_name.dup.unshift(self.class.app_name)]
|
11
11
|
raise SinatraMore::RouteNotFound.new("Route alias #{route_name.inspect} is not mapped to a url") unless mapped_url
|
12
|
-
result_url = String.new(mapped_url)
|
12
|
+
result_url = String.new(File.join(self.class.uri_root, mapped_url))
|
13
13
|
result_url.scan(%r{/?(:\S+?)(?:/|$)}).each do |placeholder|
|
14
14
|
value_key = placeholder[0][1..-1].to_sym
|
15
15
|
result_url.gsub!(Regexp.new(placeholder[0]), values[value_key].to_s)
|
data/sinatra_more.gemspec
CHANGED
data/test/test_routing_plugin.rb
CHANGED
@@ -28,12 +28,14 @@ class TestRoutingPlugin < Test::Unit::TestCase
|
|
28
28
|
demo = app.new
|
29
29
|
demo.class.stubs(:uri_root).returns("/")
|
30
30
|
demo.class.map(:demo).to('/demo')
|
31
|
+
assert_equal "/demo", demo.class.named_paths[[:routing_demo, :demo]]
|
31
32
|
assert_equal "/demo", demo.url_for(:demo)
|
32
33
|
end
|
33
34
|
should "support changing uri root with mount" do
|
34
35
|
demo = app.new
|
35
36
|
demo.class.stubs(:uri_root).returns("/blog")
|
36
37
|
demo.class.map(:demo).to('/demo')
|
38
|
+
assert_equal "/demo", demo.class.named_paths[[:routing_demo, :demo]]
|
37
39
|
assert_equal "/blog/demo", demo.url_for(:demo)
|
38
40
|
end
|
39
41
|
end
|