schmobile 0.0.3 → 0.0.4

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.0.3
1
+ 0.0.4
@@ -69,8 +69,20 @@ module Rack
69
69
  def redirect(env)
70
70
  destination = @options[:redirect_to].to_s
71
71
  request = Rack::Request.new(env)
72
- # Substitutions here
73
- destination
72
+ build_path(destination, request)
73
+ end
74
+
75
+ private
76
+
77
+ def build_path(destination, request)
78
+ final_destination = destination.dup
79
+ destination.scan(/\{\{\w+\}\}/) { |call|
80
+ func = call.scan(/\w+/).to_s
81
+ if request.respond_to?(func)
82
+ final_destination.sub!(/\{\{#{func}\}\}/, request.send(func))
83
+ end
84
+ }
85
+ final_destination
74
86
  end
75
87
 
76
88
  end
data/schmobile.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{schmobile}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Morten Primdahl"]
@@ -126,10 +126,14 @@ class TestSchmobile < Test::Unit::TestCase
126
126
  end
127
127
 
128
128
  context "#redirect" do
129
- should_eventually "interpolate the argument string" do
129
+ should "interpolate the argument string" do
130
130
  @rack = Rack::Schmobile.new(@app, :redirect_to => "/wonderland/{{path}}")
131
131
  assert_equal "/wonderland/wiffle", @rack.redirect(environment("PATH_INFO" => "wiffle"))
132
132
  end
133
+ should "interpolate a multipart argument string" do
134
+ @rack = Rack::Schmobile.new(@app, :redirect_to => "/wonderland/{{path}}/lemurs/{{path}}")
135
+ assert_equal "/wonderland/wiffle/lemurs/wiffle", @rack.redirect(environment("PATH_INFO" => "wiffle"))
136
+ end
133
137
  end
134
138
  end
135
139
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schmobile
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl