tanshuku 4.0.2 → 5.0.0
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 +4 -4
- data/app/controllers/tanshuku/urls_controller.rb +1 -1
- data/app/models/tanshuku/url.rb +3 -20
- data/lib/generators/tanshuku/install_generator.rb +1 -2
- data/lib/tanshuku/version.rb +1 -1
- data/lib/tanshuku.rb +1 -2
- data/sig/app/controllers/tanshuku/urls_controller.rbs +1 -1
- data/sig/app/models/tanshuku/url.rbs +1 -1
- data/sig/db/migrate/create_tanshuku_urls.rbs +2 -1
- data/sig/lib/generators/tanshuku/install_generator.rbs +2 -0
- data/sig/lib/tanshuku/configuration.rbs +2 -2
- data/sig/lib/tanshuku.rbs +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 917b42fb5da1554baa82f02eab43fd54242c25205adca2d86375088e74587130
|
|
4
|
+
data.tar.gz: 84c3115dd375e421648438352b981464873478598e9be988d338c6f9a5d6bf68
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c744a47b164d7d130ba6cc224c0041e08663fd123c9005588d15a786d94ff1b84e9c7976ea560e26c3f98169db104734a189e4837d25dc723613d3d441ca95da
|
|
7
|
+
data.tar.gz: c876d258f9392e80c0f6093041ce800aa4e5754506793325deb66c3b0391f8b90e632d90743362005aa0726eb20dc45bd9a107ecdb22c29da4c3f972f2f0b13b
|
|
@@ -9,7 +9,7 @@ module Tanshuku
|
|
|
9
9
|
#
|
|
10
10
|
# @raise [ActiveRecord::NotFound] If no {Tanshuku::Url} record is found for the given +key+.
|
|
11
11
|
def show
|
|
12
|
-
url = Url.find_by!(key: params
|
|
12
|
+
url = Url.find_by!(key: params.expect(:key))
|
|
13
13
|
redirect_to url.url, status: :moved_permanently, allow_other_host: true
|
|
14
14
|
end
|
|
15
15
|
end
|
data/app/models/tanshuku/url.rb
CHANGED
|
@@ -169,9 +169,11 @@ module Tanshuku
|
|
|
169
169
|
# @return [String] A shortened URL.
|
|
170
170
|
#
|
|
171
171
|
# @note
|
|
172
|
-
#
|
|
172
|
+
# This method loads the routes before calling +url_for+ as Tanshuku depends on them.
|
|
173
173
|
# cf. https://github.com/rails/rails/pull/52353
|
|
174
174
|
def shortened_url(url_options = {})
|
|
175
|
+
Rails.application.reload_routes_unless_loaded
|
|
176
|
+
|
|
175
177
|
url_options = url_options.symbolize_keys
|
|
176
178
|
url_options[:controller] = "tanshuku/urls"
|
|
177
179
|
url_options[:action] = :show
|
|
@@ -179,25 +181,6 @@ module Tanshuku
|
|
|
179
181
|
|
|
180
182
|
Tanshuku::Engine.routes.url_for(url_options)
|
|
181
183
|
end
|
|
182
|
-
|
|
183
|
-
case Gem::Version.new(Rails.version)
|
|
184
|
-
when "7.0"..."8.0"
|
|
185
|
-
# Don’t define `#shortened_url` in this branch because YARD doesn’t recognize the method.
|
|
186
|
-
else
|
|
187
|
-
# Overwrite the `#shortened_url` in Rails 8.0 or later.
|
|
188
|
-
# rubocop:disable Lint/DuplicateMethods
|
|
189
|
-
def shortened_url(url_options = {})
|
|
190
|
-
Rails.application.reload_routes_unless_loaded
|
|
191
|
-
|
|
192
|
-
url_options = url_options.symbolize_keys
|
|
193
|
-
url_options[:controller] = "tanshuku/urls"
|
|
194
|
-
url_options[:action] = :show
|
|
195
|
-
url_options[:key] = key
|
|
196
|
-
|
|
197
|
-
Tanshuku::Engine.routes.url_for(url_options)
|
|
198
|
-
end
|
|
199
|
-
# rubocop:enable Lint/DuplicateMethods
|
|
200
|
-
end
|
|
201
184
|
end
|
|
202
185
|
# rubocop:enable Rails/ApplicationRecord
|
|
203
186
|
end
|
|
@@ -31,9 +31,8 @@ module Tanshuku
|
|
|
31
31
|
|
|
32
32
|
copy_file old_filepath, new_filepath
|
|
33
33
|
|
|
34
|
-
# rubocop:disable Lint/NumberConversion
|
|
34
|
+
# rubocop:disable-next Lint/NumberConversion
|
|
35
35
|
gsub_file new_filepath, "Rails::VERSION::STRING.to_f", Rails::VERSION::STRING.to_f.to_s
|
|
36
|
-
# rubocop:enable Lint/NumberConversion
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
end
|
data/lib/tanshuku/version.rb
CHANGED
data/lib/tanshuku.rb
CHANGED
|
@@ -15,9 +15,8 @@ module Tanshuku
|
|
|
15
15
|
# {Tanshuku.configure} for configuration.
|
|
16
16
|
def self.config
|
|
17
17
|
# Disable this cop but use `Tanshuku::Configuration#configure` for thread-safety.
|
|
18
|
-
# rubocop:disable ThreadSafety/ClassInstanceVariable
|
|
18
|
+
# rubocop:disable-next ThreadSafety/ClassInstanceVariable
|
|
19
19
|
@config ||= Configuration.new
|
|
20
|
-
# rubocop:enable ThreadSafety/ClassInstanceVariable
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
# Configures Tanshuku.
|
|
@@ -107,7 +107,7 @@ module Tanshuku
|
|
|
107
107
|
def self.find_by_url: (String url, ?namespace: String) -> Tanshuku::Url?
|
|
108
108
|
def self.normalize_url: (String url) -> String
|
|
109
109
|
def self.hash_url: (String url, ?namespace: String) -> String
|
|
110
|
-
def self.generate_key: -> String
|
|
110
|
+
def self.generate_key: () -> String
|
|
111
111
|
def self.report_exception: (exception: Exception, original_url: String) -> void
|
|
112
112
|
def shortened_url: (?Hash[String | Symbol, untyped] url_options) -> String
|
|
113
113
|
end
|
|
@@ -5,7 +5,7 @@ module Tanshuku
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
interface _KeyGenerator
|
|
8
|
-
def call: -> String
|
|
8
|
+
def call: () -> String
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
interface _ExceptionReporter
|
|
@@ -25,7 +25,7 @@ module Tanshuku
|
|
|
25
25
|
attr_accessor exception_reporter (): _ExceptionReporter
|
|
26
26
|
|
|
27
27
|
def initialize: (*bot noname) -> void
|
|
28
|
-
def configure: { (Configuration) -> void } -> void
|
|
28
|
+
def configure: () { (Configuration) -> void } -> void
|
|
29
29
|
|
|
30
30
|
module DefaultUrlHasher
|
|
31
31
|
extend _UrlHasher
|
data/sig/lib/tanshuku.rbs
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tanshuku
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kg8m
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: addressable
|
|
@@ -15,28 +15,28 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.
|
|
18
|
+
version: '2.8'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '2.
|
|
25
|
+
version: '2.8'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: rails
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '8.0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
39
|
+
version: '8.0'
|
|
40
40
|
description: Tanshuku is a simple and performance aware Rails engine for shortening
|
|
41
41
|
URLs. Tanshuku generates a shortened URL per a normalized original URL. Tanshuku
|
|
42
42
|
redirects from a shortened URL to its corresponding original URL.
|
|
@@ -84,14 +84,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
84
84
|
requirements:
|
|
85
85
|
- - ">="
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '3.
|
|
87
|
+
version: '3.3'
|
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
requirements:
|
|
90
90
|
- - ">="
|
|
91
91
|
- !ruby/object:Gem::Version
|
|
92
92
|
version: '0'
|
|
93
93
|
requirements: []
|
|
94
|
-
rubygems_version:
|
|
94
|
+
rubygems_version: 4.0.24
|
|
95
95
|
specification_version: 4
|
|
96
96
|
summary: Tanshuku is a simple and performance aware Rails engine for shortening URLs.
|
|
97
97
|
test_files: []
|