tanshuku 4.0.0 → 4.0.2
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/models/tanshuku/url.rb +23 -0
- data/db/migrate/20230220123456_create_tanshuku_urls.rb +2 -2
- data/lib/generators/tanshuku/install_generator.rb +9 -1
- data/lib/tanshuku/version.rb +1 -1
- metadata +7 -12
- data/lib/tasks/check_all.rb +0 -69
- data/sig/lib/tasks/check_all.rbs +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076e5ce40463d17a9fa6361a0e8a317fb15d1428300921e8527b6765a2f62ee8
|
4
|
+
data.tar.gz: bd412ced4ce541d9b4896ea8382caeaf6ec9a4ea7cd8c33e3f4364c643b93538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e1f3ad12c2f5d59c9536ea37a11018502391e455693cf75ea54b94cacee202a0247483978e4192be13886c28ccf67db380d528f6467894204db952858d2fbb5
|
7
|
+
data.tar.gz: '07801692da343d445145619b9ac9c87895a1c0644c60864ac24bd2721a948558c644ea8354fa4e8ea254fe1b95d4ec8eef0d0fdbc3ab8617c697bebe3e6475d9'
|
data/app/models/tanshuku/url.rb
CHANGED
@@ -167,6 +167,10 @@ module Tanshuku
|
|
167
167
|
# @param url_options [Hash] An option for Rails’ +url_for+.
|
168
168
|
#
|
169
169
|
# @return [String] A shortened URL.
|
170
|
+
#
|
171
|
+
# @note
|
172
|
+
# In Rails 8.0 or later, this method loads the routes before calling +url_for+ as Tanshuku depends on them.
|
173
|
+
# cf. https://github.com/rails/rails/pull/52353
|
170
174
|
def shortened_url(url_options = {})
|
171
175
|
url_options = url_options.symbolize_keys
|
172
176
|
url_options[:controller] = "tanshuku/urls"
|
@@ -175,6 +179,25 @@ module Tanshuku
|
|
175
179
|
|
176
180
|
Tanshuku::Engine.routes.url_for(url_options)
|
177
181
|
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
|
178
201
|
end
|
179
202
|
# rubocop:enable Rails/ApplicationRecord
|
180
203
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class CreateTanshukuUrls < ActiveRecord::Migration[
|
3
|
+
class CreateTanshukuUrls < ActiveRecord::Migration[Rails::VERSION::STRING.to_f]
|
4
4
|
def change
|
5
5
|
create_table :tanshuku_urls do |t|
|
6
6
|
t.text :url, null: false
|
@@ -11,7 +11,7 @@ class CreateTanshukuUrls < ActiveRecord::Migration[7.0]
|
|
11
11
|
# You might adjust the `limit: 20` depending on `.key_length` and `.key_generator` of `Tanshuku.config`.
|
12
12
|
t.string :key, null: false, limit: 20, index: { unique: true }, comment: "cf. Tanshuku::Url.generate_key"
|
13
13
|
|
14
|
-
t.datetime :created_at, null: false
|
14
|
+
t.datetime :created_at, null: false
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -24,8 +24,16 @@ module Tanshuku
|
|
24
24
|
# rubocop:disable Rails/TimeZone
|
25
25
|
old_filename = "20230220123456_create_tanshuku_urls.rb"
|
26
26
|
new_filename = old_filename.sub("20230220123456", Time.now.strftime("%Y%m%d%H%M%S"))
|
27
|
-
copy_file "../../../db/migrate/#{old_filename}", "db/migrate/#{new_filename}"
|
28
27
|
# rubocop:enable Rails/TimeZone
|
28
|
+
|
29
|
+
old_filepath = "../../../db/migrate/#{old_filename}"
|
30
|
+
new_filepath = "db/migrate/#{new_filename}"
|
31
|
+
|
32
|
+
copy_file old_filepath, new_filepath
|
33
|
+
|
34
|
+
# rubocop:disable Lint/NumberConversion
|
35
|
+
gsub_file new_filepath, "Rails::VERSION::STRING.to_f", Rails::VERSION::STRING.to_f.to_s
|
36
|
+
# rubocop:enable Lint/NumberConversion
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
data/lib/tanshuku/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanshuku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kg8m
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-
|
10
|
+
date: 2024-12-28 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: addressable
|
@@ -16,28 +15,28 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.4
|
18
|
+
version: '2.4'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.4
|
25
|
+
version: '2.4'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: rails
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: 7.0
|
32
|
+
version: '7.0'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: 7.0
|
39
|
+
version: '7.0'
|
41
40
|
description: Tanshuku is a simple and performance aware Rails engine for shortening
|
42
41
|
URLs. Tanshuku generates a shortened URL per a normalized original URL. Tanshuku
|
43
42
|
redirects from a shortened URL to its corresponding original URL.
|
@@ -61,7 +60,6 @@ files:
|
|
61
60
|
- lib/tanshuku/configuration.rb
|
62
61
|
- lib/tanshuku/engine.rb
|
63
62
|
- lib/tanshuku/version.rb
|
64
|
-
- lib/tasks/check_all.rb
|
65
63
|
- sig/app/controllers/tanshuku/urls_controller.rbs
|
66
64
|
- sig/app/models/tanshuku/url.rbs
|
67
65
|
- sig/db/migrate/create_tanshuku_urls.rbs
|
@@ -70,7 +68,6 @@ files:
|
|
70
68
|
- sig/lib/tanshuku/configuration.rbs
|
71
69
|
- sig/lib/tanshuku/engine.rbs
|
72
70
|
- sig/lib/tanshuku/version.rbs
|
73
|
-
- sig/lib/tasks/check_all.rbs
|
74
71
|
homepage: https://github.com/kg8m/tanshuku
|
75
72
|
licenses:
|
76
73
|
- MIT
|
@@ -80,7 +77,6 @@ metadata:
|
|
80
77
|
changelog_uri: https://github.com/kg8m/tanshuku/releases
|
81
78
|
documentation_uri: https://kg8m.github.io/tanshuku/
|
82
79
|
rubygems_mfa_required: 'true'
|
83
|
-
post_install_message:
|
84
80
|
rdoc_options: []
|
85
81
|
require_paths:
|
86
82
|
- lib
|
@@ -95,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
91
|
- !ruby/object:Gem::Version
|
96
92
|
version: '0'
|
97
93
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
99
|
-
signing_key:
|
94
|
+
rubygems_version: 3.6.2
|
100
95
|
specification_version: 4
|
101
96
|
summary: Tanshuku is a simple and performance aware Rails engine for shortening URLs.
|
102
97
|
test_files: []
|
data/lib/tasks/check_all.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "English"
|
4
|
-
require "io/console"
|
5
|
-
require "paint"
|
6
|
-
require "pty"
|
7
|
-
|
8
|
-
class CheckAll
|
9
|
-
TASKNAMES = %i[rubocop spec steep:check yard:check].freeze
|
10
|
-
LINE = Paint["-" * (IO.console or raise).winsize[1], :bold]
|
11
|
-
TITLE_TEMPLATE = Paint["\n#{LINE}\nExecute: %<command>s\n#{LINE}\n\n", :bold]
|
12
|
-
|
13
|
-
attr_reader :failed_commands
|
14
|
-
|
15
|
-
def self.call
|
16
|
-
new.call
|
17
|
-
end
|
18
|
-
|
19
|
-
def initialize
|
20
|
-
@failed_commands = []
|
21
|
-
end
|
22
|
-
|
23
|
-
def call
|
24
|
-
# rubocop:disable ThreadSafety/NewThread
|
25
|
-
TASKNAMES.map { |taskname| Thread.new(taskname, &executor) }.each(&:join)
|
26
|
-
# rubocop:enable ThreadSafety/NewThread
|
27
|
-
output_result
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def executor
|
33
|
-
lambda do |taskname|
|
34
|
-
command = "bundle exec rake #{taskname}"
|
35
|
-
|
36
|
-
outputs = []
|
37
|
-
outputs << format(TITLE_TEMPLATE, command:)
|
38
|
-
|
39
|
-
# Use `PTY.spawn` to get colorized outputs of each command.
|
40
|
-
PTY.spawn(command) do |reader, writer, pid|
|
41
|
-
writer.close
|
42
|
-
|
43
|
-
while (output = reader.gets)
|
44
|
-
outputs << output
|
45
|
-
end
|
46
|
-
|
47
|
-
Process.wait(pid)
|
48
|
-
end
|
49
|
-
failed_commands << command unless $CHILD_STATUS&.success?
|
50
|
-
|
51
|
-
puts outputs.join
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def output_result
|
56
|
-
puts ""
|
57
|
-
puts LINE
|
58
|
-
puts Paint["Result", :bold]
|
59
|
-
puts LINE
|
60
|
-
|
61
|
-
if failed_commands.empty?
|
62
|
-
puts Paint["\nAll checks are OK.", :green, :bold]
|
63
|
-
else
|
64
|
-
puts Paint["\nChecks failed!!\n", :red, :bold]
|
65
|
-
puts failed_commands.map { |command| " - #{command}" }.join("\n")
|
66
|
-
abort ""
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/sig/lib/tasks/check_all.rbs
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
class CheckAll
|
2
|
-
TASKNAMES: Array[Symbol]
|
3
|
-
LINE: String
|
4
|
-
TITLE_TEMPLATE: String
|
5
|
-
|
6
|
-
attr_reader failed_commands: Array[String]
|
7
|
-
|
8
|
-
def initialize: () -> void
|
9
|
-
|
10
|
-
def self.call: () -> void
|
11
|
-
|
12
|
-
def call: () -> void
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def executor: () -> ^(*String) -> void
|
17
|
-
def output_result: () -> void
|
18
|
-
end
|