redirect-rails 0.1.3 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 849f33875dddadecef17b46ef8fed0cc3e38ccc22d3654ae89a7d27b7f15a67c
4
- data.tar.gz: 478015406f237ff05ac0ff96d11e1cf1c00bdcd2dd714984f9f9955534cb3c7d
3
+ metadata.gz: f46377411074f4d5f0324f7bff7da2916112df9993b508d81955803b2c940716
4
+ data.tar.gz: 31c05112cde8119377775e03e71215111c95392969c83f9cc2e70e9b2e34a047
5
5
  SHA512:
6
- metadata.gz: 3e158ec43ea86a19666da40896c5a465971522cac5b9e44f7d85e86e5428a3471f9cb80f02e591a8f1ea71066c1f9322392ad0f718a1e83040ad12cb4de0e14c
7
- data.tar.gz: 4d4e41e622e36423352cd61ac3a7821db25e0ca3bace61e20ddf137075a80f681e4902f26d2bebd438ad0e65a869eb9ca78a7e27141f49b3c16774575c87729b
6
+ metadata.gz: 23cca88b54bc5c1af86553e0ec161cd7d8a2d53c97132152d6865dff418b1967fd64956cf9f7dcc1b87d2f526219414d71c7642b379137e92e5f86cb8ef2e249
7
+ data.tar.gz: 3245137b076b61c97321d3ce20383196ae2c51794d352a4c52eb9fe0c167c3dc4c676bf6e560a45a15b498fbfb26f274fd1e62cb731dbec62dc2c75331571c2f
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 unless 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.1"
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.1
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.