redirect-rails 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f46377411074f4d5f0324f7bff7da2916112df9993b508d81955803b2c940716
4
- data.tar.gz: 31c05112cde8119377775e03e71215111c95392969c83f9cc2e70e9b2e34a047
3
+ metadata.gz: a6690ed059ca2cea75e6303e9a9a0901448a1d65950d8fd2f4cf2bd9fba22217
4
+ data.tar.gz: a9f26f09c3700e70522ab9d9032cbc76bbe02738e7ff8575d26732c0d7311446
5
5
  SHA512:
6
- metadata.gz: 23cca88b54bc5c1af86553e0ec161cd7d8a2d53c97132152d6865dff418b1967fd64956cf9f7dcc1b87d2f526219414d71c7642b379137e92e5f86cb8ef2e249
7
- data.tar.gz: 3245137b076b61c97321d3ce20383196ae2c51794d352a4c52eb9fe0c167c3dc4c676bf6e560a45a15b498fbfb26f274fd1e62cb731dbec62dc2c75331571c2f
6
+ metadata.gz: aa5a76a662e15d69a78a1774714a7aa109c8aa298f09d677646fb1b5f323801f6809809f674a296e5664a77e9cbb8c3ed53d57af49b05425c2aeebd892b155b0
7
+ data.tar.gz: 06f16613d08a5e0e0232d7d99f4e9768f39dbf07d9a5e28277daa4cdbf4eda992b37035f1d166dfac99de6f862f08535696ada3b9e3b78de4152bc4dd9a2dc94
@@ -8,19 +8,19 @@ module Redirect
8
8
 
9
9
  def call(env)
10
10
  @request = Rack::Request.new(env)
11
- if response = match?(@request.path)
12
- response
11
+ if url = redirect_url(@request.path)
12
+ redirect_to(url)
13
13
  else
14
14
  @app.call(env)
15
15
  end
16
16
  end
17
17
 
18
- def match?(request_path)
18
+ def redirect_url(request_path)
19
19
  return unless Redirect::Rails.paths
20
20
 
21
21
  Redirect::Rails.paths.map do |path, redirect_path|
22
- return redirect_to(ERB.new(redirect_path).result(binding)) if Regexp.new(path).match(request_path)
23
- end
22
+ return ERB.new(redirect_path).result(binding) if Regexp.new(path).match(request_path)
23
+ end.first
24
24
  end
25
25
 
26
26
  def redirect_to(uri)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Redirect
4
4
  module Rails
5
- VERSION = "0.2.1"
5
+ VERSION = "0.2.2"
6
6
  end
7
7
  end
@@ -21,7 +21,7 @@ module Redirect
21
21
  end
22
22
 
23
23
  def paths
24
- YAML.load(ERB.new(File.read(yaml_name)).result)['paths']
24
+ YAML.safe_load(File.read(yaml_name))['paths']
25
25
  end
26
26
 
27
27
  def original_yaml_name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirect-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke