redirect-rails 0.1.3 → 0.2.0

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: 849f33875dddadecef17b46ef8fed0cc3e38ccc22d3654ae89a7d27b7f15a67c
4
- data.tar.gz: 478015406f237ff05ac0ff96d11e1cf1c00bdcd2dd714984f9f9955534cb3c7d
3
+ metadata.gz: c66620968de2d42cd6e33412b00efb687f4923aaaffd900228ac985bdb333f3e
4
+ data.tar.gz: 104b84668431748b12106c7b2e9c21adbc003da3d835e98d5071ed7fa8c96156
5
5
  SHA512:
6
- metadata.gz: 3e158ec43ea86a19666da40896c5a465971522cac5b9e44f7d85e86e5428a3471f9cb80f02e591a8f1ea71066c1f9322392ad0f718a1e83040ad12cb4de0e14c
7
- data.tar.gz: 4d4e41e622e36423352cd61ac3a7821db25e0ca3bace61e20ddf137075a80f681e4902f26d2bebd438ad0e65a869eb9ca78a7e27141f49b3c16774575c87729b
6
+ metadata.gz: 75e6682ea244c26e8a2f49e8b62205291ee38943ef05abc960a77bc8c3158edc581f01840ecd25a4637a06b0c0c1ada8cef868daf2a5a3d7b191f7e0270779ae
7
+ data.tar.gz: 18800ad819165a411eaf99bef5508e23e1cda4b6f097b6de49f127317d41ae89d4efbba2f8c4afad083a0204177f0870db8dfeb81e6edc001215991216c95f08
data/README.md CHANGED
@@ -19,9 +19,21 @@ $ bin/rails redirect:install
19
19
 
20
20
  List the correspondence of the paths you want to redirect in config/redirect.yml."
21
21
 
22
+ ## paths
23
+
24
+ In the `config/redirect.yml` file, you can write redirect settings as follows.
25
+
26
+ ```
27
+ paths:
28
+ /regexp/([^/]+): /redirected/regexp/<%= $1 %>
29
+ /static/failuer: /static/true
30
+ ```
31
+
22
32
  ## Contributing
23
33
 
24
- Bug reports and pull requests are welcome on GitHub at https://github.com/slidict/redirect-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/slidict/redirect-rails/blob/main/CODE_OF_CONDUCT.md).
34
+ - No test code yet. Pull requests are welcome.
35
+
36
+ -Bug reports and pull requests are welcome on GitHub at https://github.com/slidict/redirect-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/slidict/redirect-rails/blob/main/CODE_OF_CONDUCT.md).
25
37
 
26
38
  ## License
27
39
 
data/config/redirect.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  paths:
2
- # /redirect/falsity01: /redirect/truth/
3
- # /redirect/falsity02: /redirect/truth/
2
+ # /regexp/([^/]+): /redirected/regexp/<%= $1 %>
3
+ # /static/failuer: /static/true
@@ -16,19 +16,19 @@ module Redirect
16
16
  end
17
17
 
18
18
  def match?(request_path)
19
+ return if Redirect::Rails.paths
20
+
19
21
  Redirect::Rails.paths.map do |path, redirect_path|
20
- if Regexp.new(path).match(request_path)
21
- return redirect_to(redirect_path)
22
- end
23
- end if Redirect::Rails.paths
24
- return nil
22
+ return redirect_to(ERB.new(redirect_path).result(binding)) if Regexp.new(path).match(request_path)
23
+ end
25
24
  end
26
25
 
27
26
  def redirect_to(uri)
28
- headers = { 'Location' => uri,
29
- 'Content-Type' => @request['Content-Type'],
30
- 'Pragma' => 'no-cache',
31
- 'Cache-Control' => 'no-cache; max-age=0' }
27
+ headers = { "Location": uri,
28
+ "Content-Type": @request["Content-Type"],
29
+ "Pragma": "no-cache",
30
+ "Cache-Control": "no-cache; max-age=0"
31
+ }
32
32
  [302, headers, [redirect_message(uri)]]
33
33
  end
34
34
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Redirect
4
4
  module Rails
5
- VERSION = "0.1.3"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirect-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-30 00:00:00.000000000 Z
11
+ date: 2024-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.3.7
72
+ rubygems_version: 3.5.7
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Provide a routing table dedicated to redirect in rails.