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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 076e5ce40463d17a9fa6361a0e8a317fb15d1428300921e8527b6765a2f62ee8
4
- data.tar.gz: bd412ced4ce541d9b4896ea8382caeaf6ec9a4ea7cd8c33e3f4364c643b93538
3
+ metadata.gz: 917b42fb5da1554baa82f02eab43fd54242c25205adca2d86375088e74587130
4
+ data.tar.gz: 84c3115dd375e421648438352b981464873478598e9be988d338c6f9a5d6bf68
5
5
  SHA512:
6
- metadata.gz: 1e1f3ad12c2f5d59c9536ea37a11018502391e455693cf75ea54b94cacee202a0247483978e4192be13886c28ccf67db380d528f6467894204db952858d2fbb5
7
- data.tar.gz: '07801692da343d445145619b9ac9c87895a1c0644c60864ac24bd2721a948558c644ea8354fa4e8ea254fe1b95d4ec8eef0d0fdbc3ab8617c697bebe3e6475d9'
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[:key])
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
@@ -169,9 +169,11 @@ module Tanshuku
169
169
  # @return [String] A shortened URL.
170
170
  #
171
171
  # @note
172
- # In Rails 8.0 or later, this method loads the routes before calling +url_for+ as Tanshuku depends on them.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tanshuku
4
- VERSION = "4.0.2"
4
+ VERSION = "5.0.0"
5
5
  end
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.
@@ -1,5 +1,5 @@
1
1
  module Tanshuku
2
2
  class UrlsController < ActionController::API
3
- def show: -> void
3
+ def show: () -> void
4
4
  end
5
5
  end
@@ -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
@@ -1,2 +1,3 @@
1
- class CreateTanshukuUrls < ActiveRecord::Migration::Compatibility::V7_0
1
+ class CreateTanshukuUrls < ActiveRecord::Migration::Current
2
+ def change: () -> void
2
3
  end
@@ -1,4 +1,6 @@
1
1
  module Tanshuku
2
2
  class InstallGenerator < Rails::Generators::Base
3
+ def copy_initializer_file: () -> void
4
+ def copy_migration_file: () -> void
3
5
  end
4
6
  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
@@ -1,6 +1,6 @@
1
1
  module Tanshuku
2
2
  self.@config: Configuration
3
3
 
4
- def self.config: -> Configuration
5
- def self.configure: { (Configuration config) -> void } -> void
4
+ def self.config: () -> Configuration
5
+ def self.configure: () { (Configuration config) -> void } -> void
6
6
  end
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.0.2
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: 2024-12-28 00:00:00.000000000 Z
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.4'
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.4'
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: '7.0'
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: '7.0'
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.2'
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: 3.6.2
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: []