redirect-rails 0.3.1 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd0f45248f4da1f4c59d5738a560c46911d19475734ed4f813afcc5489eb7f1c
4
- data.tar.gz: 3468f49a9e12108d13c458990ad5073ef9b1ff52d7b5854b23af1191d5838862
3
+ metadata.gz: 2f8daaae55ea15a53bea6dac7a5699f7167414e6eec3ed0b64314f4aeac2e272
4
+ data.tar.gz: 48a60747d0a970f3e05d7e2bf445d62ebcd18b61baed41c43ea50ddec4a447a4
5
5
  SHA512:
6
- metadata.gz: 034ad9b08df9ccf6648f718dc77b53dfeeb3272447a883a30c88b42a88888e2a84febb737360e8d642eb6921771c3d8d600b9a93b2f38a36d28fac5b1f784f84
7
- data.tar.gz: c5997266f646d25d1e9900a446911faf0d85616b22c6870a5710956f1d440ff3add16ff053afb50da81a61e53ff4b4b96a5130a868cdb08ed3721c24e0f75a0a
6
+ metadata.gz: 79d86e2e879d8cd790df0e9e3cfdf8a593203f9c7981b73ac09b8e9ea11b4de466cb70a7ce0cb881287769d95b126d3e0990bf3b54189a933f9ceb1c2a283aa8
7
+ data.tar.gz: 65c91d8c654d2ee7ef3c13828280d921ff4ce29e83b6239dcd76f71389425d2e14a9c493f237eac921191a885f2bfd4b63a77dfdce99af7682dd8396d51625b9
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.2
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
data/Gemfile CHANGED
@@ -6,7 +6,5 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
-
10
9
  gem "rspec", "~> 3.0"
11
-
12
10
  gem "rubocop", "~> 1.21"
data/Gemfile.lock CHANGED
@@ -1,48 +1,217 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redirect-rails (0.1.0)
4
+ redirect-rails (0.3.3)
5
+ rails
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ actioncable (7.2.1.1)
11
+ actionpack (= 7.2.1.1)
12
+ activesupport (= 7.2.1.1)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ zeitwerk (~> 2.6)
16
+ actionmailbox (7.2.1.1)
17
+ actionpack (= 7.2.1.1)
18
+ activejob (= 7.2.1.1)
19
+ activerecord (= 7.2.1.1)
20
+ activestorage (= 7.2.1.1)
21
+ activesupport (= 7.2.1.1)
22
+ mail (>= 2.8.0)
23
+ actionmailer (7.2.1.1)
24
+ actionpack (= 7.2.1.1)
25
+ actionview (= 7.2.1.1)
26
+ activejob (= 7.2.1.1)
27
+ activesupport (= 7.2.1.1)
28
+ mail (>= 2.8.0)
29
+ rails-dom-testing (~> 2.2)
30
+ actionpack (7.2.1.1)
31
+ actionview (= 7.2.1.1)
32
+ activesupport (= 7.2.1.1)
33
+ nokogiri (>= 1.8.5)
34
+ racc
35
+ rack (>= 2.2.4, < 3.2)
36
+ rack-session (>= 1.0.1)
37
+ rack-test (>= 0.6.3)
38
+ rails-dom-testing (~> 2.2)
39
+ rails-html-sanitizer (~> 1.6)
40
+ useragent (~> 0.16)
41
+ actiontext (7.2.1.1)
42
+ actionpack (= 7.2.1.1)
43
+ activerecord (= 7.2.1.1)
44
+ activestorage (= 7.2.1.1)
45
+ activesupport (= 7.2.1.1)
46
+ globalid (>= 0.6.0)
47
+ nokogiri (>= 1.8.5)
48
+ actionview (7.2.1.1)
49
+ activesupport (= 7.2.1.1)
50
+ builder (~> 3.1)
51
+ erubi (~> 1.11)
52
+ rails-dom-testing (~> 2.2)
53
+ rails-html-sanitizer (~> 1.6)
54
+ activejob (7.2.1.1)
55
+ activesupport (= 7.2.1.1)
56
+ globalid (>= 0.3.6)
57
+ activemodel (7.2.1.1)
58
+ activesupport (= 7.2.1.1)
59
+ activerecord (7.2.1.1)
60
+ activemodel (= 7.2.1.1)
61
+ activesupport (= 7.2.1.1)
62
+ timeout (>= 0.4.0)
63
+ activestorage (7.2.1.1)
64
+ actionpack (= 7.2.1.1)
65
+ activejob (= 7.2.1.1)
66
+ activerecord (= 7.2.1.1)
67
+ activesupport (= 7.2.1.1)
68
+ marcel (~> 1.0)
69
+ activesupport (7.2.1.1)
70
+ base64
71
+ bigdecimal
72
+ concurrent-ruby (~> 1.0, >= 1.3.1)
73
+ connection_pool (>= 2.2.5)
74
+ drb
75
+ i18n (>= 1.6, < 2)
76
+ logger (>= 1.4.2)
77
+ minitest (>= 5.1)
78
+ securerandom (>= 0.3)
79
+ tzinfo (~> 2.0, >= 2.0.5)
9
80
  ast (2.4.2)
10
- diff-lcs (1.5.0)
11
- json (2.6.2)
12
- parallel (1.22.1)
13
- parser (3.1.2.1)
81
+ base64 (0.2.0)
82
+ bigdecimal (3.1.8)
83
+ builder (3.3.0)
84
+ concurrent-ruby (1.3.4)
85
+ connection_pool (2.4.1)
86
+ crass (1.0.6)
87
+ date (3.3.4)
88
+ diff-lcs (1.5.1)
89
+ drb (2.2.1)
90
+ erubi (1.13.0)
91
+ globalid (1.2.1)
92
+ activesupport (>= 6.1)
93
+ i18n (1.14.6)
94
+ concurrent-ruby (~> 1.0)
95
+ io-console (0.7.2)
96
+ irb (1.14.1)
97
+ rdoc (>= 4.0.0)
98
+ reline (>= 0.4.2)
99
+ json (2.7.2)
100
+ language_server-protocol (3.17.0.3)
101
+ logger (1.6.1)
102
+ loofah (2.22.0)
103
+ crass (~> 1.0.2)
104
+ nokogiri (>= 1.12.0)
105
+ mail (2.8.1)
106
+ mini_mime (>= 0.1.1)
107
+ net-imap
108
+ net-pop
109
+ net-smtp
110
+ marcel (1.0.4)
111
+ mini_mime (1.1.5)
112
+ minitest (5.25.1)
113
+ net-imap (0.5.0)
114
+ date
115
+ net-protocol
116
+ net-pop (0.1.2)
117
+ net-protocol
118
+ net-protocol (0.2.2)
119
+ timeout
120
+ net-smtp (0.5.0)
121
+ net-protocol
122
+ nio4r (2.7.3)
123
+ nokogiri (1.16.7-x86_64-linux)
124
+ racc (~> 1.4)
125
+ parallel (1.26.3)
126
+ parser (3.3.5.0)
14
127
  ast (~> 2.4.1)
128
+ racc
129
+ psych (5.1.2)
130
+ stringio
131
+ racc (1.8.1)
132
+ rack (3.1.8)
133
+ rack-session (2.0.0)
134
+ rack (>= 3.0.0)
135
+ rack-test (2.1.0)
136
+ rack (>= 1.3)
137
+ rackup (2.1.0)
138
+ rack (>= 3)
139
+ webrick (~> 1.8)
140
+ rails (7.2.1.1)
141
+ actioncable (= 7.2.1.1)
142
+ actionmailbox (= 7.2.1.1)
143
+ actionmailer (= 7.2.1.1)
144
+ actionpack (= 7.2.1.1)
145
+ actiontext (= 7.2.1.1)
146
+ actionview (= 7.2.1.1)
147
+ activejob (= 7.2.1.1)
148
+ activemodel (= 7.2.1.1)
149
+ activerecord (= 7.2.1.1)
150
+ activestorage (= 7.2.1.1)
151
+ activesupport (= 7.2.1.1)
152
+ bundler (>= 1.15.0)
153
+ railties (= 7.2.1.1)
154
+ rails-dom-testing (2.2.0)
155
+ activesupport (>= 5.0.0)
156
+ minitest
157
+ nokogiri (>= 1.6)
158
+ rails-html-sanitizer (1.6.0)
159
+ loofah (~> 2.21)
160
+ nokogiri (~> 1.14)
161
+ railties (7.2.1.1)
162
+ actionpack (= 7.2.1.1)
163
+ activesupport (= 7.2.1.1)
164
+ irb (~> 1.13)
165
+ rackup (>= 1.0.0)
166
+ rake (>= 12.2)
167
+ thor (~> 1.0, >= 1.2.2)
168
+ zeitwerk (~> 2.6)
15
169
  rainbow (3.1.1)
16
- rake (13.0.6)
17
- regexp_parser (2.6.0)
18
- rexml (3.2.5)
19
- rspec (3.12.0)
20
- rspec-core (~> 3.12.0)
21
- rspec-expectations (~> 3.12.0)
22
- rspec-mocks (~> 3.12.0)
23
- rspec-core (3.12.0)
24
- rspec-support (~> 3.12.0)
25
- rspec-expectations (3.12.0)
170
+ rake (13.2.1)
171
+ rdoc (6.7.0)
172
+ psych (>= 4.0.0)
173
+ regexp_parser (2.9.2)
174
+ reline (0.5.10)
175
+ io-console (~> 0.5)
176
+ rspec (3.13.0)
177
+ rspec-core (~> 3.13.0)
178
+ rspec-expectations (~> 3.13.0)
179
+ rspec-mocks (~> 3.13.0)
180
+ rspec-core (3.13.2)
181
+ rspec-support (~> 3.13.0)
182
+ rspec-expectations (3.13.3)
26
183
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.12.0)
28
- rspec-mocks (3.12.0)
184
+ rspec-support (~> 3.13.0)
185
+ rspec-mocks (3.13.2)
29
186
  diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.12.0)
31
- rspec-support (3.12.0)
32
- rubocop (1.38.0)
187
+ rspec-support (~> 3.13.0)
188
+ rspec-support (3.13.1)
189
+ rubocop (1.67.0)
33
190
  json (~> 2.3)
191
+ language_server-protocol (>= 3.17.0)
34
192
  parallel (~> 1.10)
35
- parser (>= 3.1.2.1)
193
+ parser (>= 3.3.0.2)
36
194
  rainbow (>= 2.2.2, < 4.0)
37
- regexp_parser (>= 1.8, < 3.0)
38
- rexml (>= 3.2.5, < 4.0)
39
- rubocop-ast (>= 1.23.0, < 2.0)
195
+ regexp_parser (>= 2.4, < 3.0)
196
+ rubocop-ast (>= 1.32.2, < 2.0)
40
197
  ruby-progressbar (~> 1.7)
41
- unicode-display_width (>= 1.4.0, < 3.0)
42
- rubocop-ast (1.23.0)
43
- parser (>= 3.1.1.0)
44
- ruby-progressbar (1.11.0)
45
- unicode-display_width (2.3.0)
198
+ unicode-display_width (>= 2.4.0, < 3.0)
199
+ rubocop-ast (1.32.3)
200
+ parser (>= 3.3.1.0)
201
+ ruby-progressbar (1.13.0)
202
+ securerandom (0.3.1)
203
+ stringio (3.1.1)
204
+ thor (1.3.2)
205
+ timeout (0.4.1)
206
+ tzinfo (2.0.6)
207
+ concurrent-ruby (~> 1.0)
208
+ unicode-display_width (2.6.0)
209
+ useragent (0.16.10)
210
+ webrick (1.8.2)
211
+ websocket-driver (0.7.6)
212
+ websocket-extensions (>= 0.1.0)
213
+ websocket-extensions (0.1.5)
214
+ zeitwerk (2.7.1)
46
215
 
47
216
  PLATFORMS
48
217
  x86_64-linux
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Redirect
4
+ # Insert middleware
4
5
  class Engine < ::Rails::Engine
5
6
  initializer "insert_redirect_middleware" do |app|
6
7
  app.middleware.insert_before ActionDispatch::Callbacks, Redirect::Middleware
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Redirect
4
+ # Redirect::Middleware
4
5
  class Middleware
5
6
  def initialize(app)
6
7
  @app = app
@@ -8,7 +9,7 @@ module Redirect
8
9
 
9
10
  def call(env)
10
11
  @request = Rack::Request.new(env)
11
- if url = redirect_url(@request.path) || url = redirect_host(@request.host)
12
+ if (url = redirect_url(@request.path) || redirect_host(@request.host))
12
13
  redirect_to(url)
13
14
  else
14
15
  @app.call(env)
@@ -35,15 +36,14 @@ module Redirect
35
36
 
36
37
  def redirect_to(uri)
37
38
  headers = { "Location": uri,
38
- "Content-Type": @request["Content-Type"],
39
39
  "Pragma": "no-cache",
40
- "Cache-Control": "no-cache; max-age=0"
41
- }
40
+ "Cache-Control": "no-cache; max-age=0" }
41
+ headers["Content-Type"] = @request["Content-Type"] if @request.has_key?("Content-Type")
42
42
  [302, headers, [redirect_message(uri)]]
43
43
  end
44
44
 
45
45
  def redirect_message(location)
46
- %Q(Redirecting to <a href="#{location}">#{location}</a>)
46
+ %(Redirecting to <a href="#{location}">#{location}</a>)
47
47
  end
48
48
  end
49
49
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Redirect
4
4
  module Rails
5
- VERSION = "0.3.1"
5
+ VERSION = "0.3.4"
6
6
  end
7
7
  end
@@ -7,8 +7,11 @@ require_relative "engine"
7
7
  require_relative "middleware"
8
8
 
9
9
  module Redirect
10
+ # Redirect::Rails
10
11
  module Rails
11
12
  class Error < StandardError; end
13
+
14
+ # For rails task
12
15
  class Railtie < ::Rails::Railtie
13
16
  rake_tasks do
14
17
  load "redirect/tasks/redirect/tasks.rake"
@@ -17,15 +20,15 @@ module Redirect
17
20
 
18
21
  class << self
19
22
  def root
20
- File.expand_path '../../..', __FILE__
23
+ File.expand_path "../..", __dir__
21
24
  end
22
25
 
23
26
  def paths
24
- YAML.safe_load(File.read(yaml_name))['paths']
27
+ YAML.safe_load(File.read(yaml_name))["paths"]
25
28
  end
26
29
 
27
30
  def hosts
28
- YAML.safe_load(File.read(yaml_name))['hosts']
31
+ YAML.safe_load(File.read(yaml_name))["hosts"]
29
32
  end
30
33
 
31
34
  def original_yaml_name
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  namespace :redirect do
4
- desc 'Install redirect-rails'
4
+ desc "Install redirect-rails"
5
5
  task :install do
6
6
  target_filepath = Redirect::Rails.yaml_name
7
7
  if File.exist?(target_filepath)
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "List the correspondence of the paths you want to redirect in config/redirect.yml."
13
13
  spec.homepage = "https://github.com/slidict/redirect-rails"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
15
+ spec.required_ruby_version = ">= 3.2.0"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/slidict/redirect-rails"
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.3.1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-13 00:00:00.000000000 Z
11
+ date: 2024-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -54,7 +54,7 @@ metadata:
54
54
  homepage_uri: https://github.com/slidict/redirect-rails
55
55
  source_code_uri: https://github.com/slidict/redirect-rails
56
56
  changelog_uri: https://github.com/slidict/redirect-rails/releases
57
- post_install_message:
57
+ post_install_message:
58
58
  rdoc_options: []
59
59
  require_paths:
60
60
  - lib
@@ -62,15 +62,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
62
  requirements:
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: 2.6.0
65
+ version: 3.2.0
66
66
  required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.5.7
73
- signing_key:
72
+ rubygems_version: 3.5.11
73
+ signing_key:
74
74
  specification_version: 4
75
75
  summary: Provide a routing table dedicated to redirect in rails.
76
76
  test_files: []