tanshuku 1.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Steepfile +7 -0
- data/app/models/tanshuku/url.rb +9 -27
- data/db/migrate/20230220123456_create_tanshuku_urls.rb +1 -1
- data/lib/generators/tanshuku/install_generator.rb +2 -1
- data/lib/tanshuku/configuration.rb +3 -64
- data/lib/tanshuku/version.rb +1 -1
- data/lib/tanshuku.rb +2 -2
- data/lib/tasks/check_all.rb +2 -2
- data/rbs_collection.lock.yaml +230 -0
- data/rbs_collection.yaml +19 -0
- data/sig/app/controllers/tanshuku/urls_controller.rbs +5 -0
- data/sig/app/models/tanshuku/url.rbs +114 -0
- data/sig/db/migrate/create_tanshuku_urls.rbs +2 -0
- data/sig/lib/generators/tanshuku/install_generator.rbs +4 -0
- data/sig/lib/tanshuku/configuration.rbs +42 -0
- data/sig/lib/tanshuku/engine.rbs +4 -0
- data/sig/lib/tanshuku/version.rbs +3 -0
- data/sig/lib/tanshuku.rbs +6 -0
- data/sig/lib/tasks/check_all.rbs +16 -0
- metadata +19 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5ff274193edca38641529760b038e3768c39548f092c4eeaa88d26984e48f4a
|
4
|
+
data.tar.gz: 2efbb4cc502878b7e7bf9d3eab8e4aefa2bd9006c730065735705012ac3c7123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94e2ca5cd226b71bbde625b6cbfbceb0a4bbfff38a46a00f0a40b207f9026c61487bc6b8d51c68f69534554e0006228ac2cf034196f7e1aaf13b9568a842aabc
|
7
|
+
data.tar.gz: 98f6a408b804298b838b740781b6ceb134f2afb1bc9f193778c12107d94207793de8edc8f3fbc34e3c933957d84c1aa7196ed90d49a7831ff28b2599bc6c112c
|
data/README.md
CHANGED
@@ -65,7 +65,7 @@ The following example means that an exception and a URL will be reported to [Sen
|
|
65
65
|
Tanshuku.configure do |config|
|
66
66
|
config.exception_reporter =
|
67
67
|
lambda { |exception:, original_url:|
|
68
|
-
Sentry.capture_exception(exception, tags: { original_url:
|
68
|
+
Sentry.capture_exception(exception, tags: { original_url: })
|
69
69
|
}
|
70
70
|
end
|
71
71
|
```
|
@@ -180,7 +180,7 @@ A. Does Tanshuku have some missing features? Please [create an issue](https://gi
|
|
180
180
|
|
181
181
|
1. Fork this repository
|
182
182
|
1. `git clone` your fork
|
183
|
-
1. `bundle install`
|
183
|
+
1. `bundle install` and `rake steep:prepare`
|
184
184
|
1. Update sources
|
185
185
|
1. `rake`
|
186
186
|
1. Fix `rake` errors if `rake` fails
|
data/Steepfile
ADDED
data/app/models/tanshuku/url.rb
CHANGED
@@ -26,11 +26,10 @@ module Tanshuku
|
|
26
26
|
DEFAULT_NAMESPACE = ""
|
27
27
|
|
28
28
|
validates :url, :hashed_url, :key, presence: true
|
29
|
+
validates :url, length: { maximum: proc { Tanshuku.config.max_url_length } }
|
29
30
|
validates :url, format: { with: proc { Tanshuku.config.url_pattern } }, allow_blank: true
|
30
31
|
|
31
32
|
# Don’t validate uniqueness of unique attributes. Raise ActiveRecord::RecordNotUnique instead if the attributes get
|
32
|
-
validate :validates_length_of_url
|
33
|
-
|
34
33
|
# duplicated. Then rescue the exception and try to retry.
|
35
34
|
# validates :url, :hashed_url, :key, uniqueness: true
|
36
35
|
|
@@ -83,8 +82,8 @@ module Tanshuku
|
|
83
82
|
begin
|
84
83
|
transaction do
|
85
84
|
record =
|
86
|
-
create_or_find_by!(hashed_url: hash_url(url, namespace:
|
87
|
-
r.attributes = { url
|
85
|
+
create_or_find_by!(hashed_url: hash_url(url, namespace:)) do |r|
|
86
|
+
r.attributes = { url:, key: generate_key }
|
88
87
|
end
|
89
88
|
|
90
89
|
record.shortened_url(url_options)
|
@@ -95,24 +94,15 @@ module Tanshuku
|
|
95
94
|
retries += 1
|
96
95
|
retry
|
97
96
|
else
|
98
|
-
report_exception(exception: e, original_url:
|
97
|
+
report_exception(exception: e, original_url:)
|
99
98
|
original_url
|
100
99
|
end
|
101
100
|
end
|
102
101
|
rescue StandardError => e
|
103
|
-
report_exception(exception: e, original_url:
|
102
|
+
report_exception(exception: e, original_url:)
|
104
103
|
original_url
|
105
104
|
end
|
106
105
|
|
107
|
-
unless respond_to?(:create_or_find_by!)
|
108
|
-
# https://github.com/rails/rails/blob/v6.0.0/activerecord/lib/active_record/relation.rb#L218-L222
|
109
|
-
def self.create_or_find_by!(attributes, &block)
|
110
|
-
transaction(requires_new: true) { create!(attributes, &block) }
|
111
|
-
rescue ActiveRecord::RecordNotUnique
|
112
|
-
find_by!(attributes)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
106
|
# Finds a {Tanshuku::Url} record by a non-shortened URL.
|
117
107
|
#
|
118
108
|
# @param url [String] A non-shortened URL.
|
@@ -122,9 +112,9 @@ module Tanshuku
|
|
122
112
|
# @return [nil] +nil+ unless found.
|
123
113
|
def self.find_by_url(url, namespace: DEFAULT_NAMESPACE)
|
124
114
|
normalized_url = normalize_url(url)
|
125
|
-
hashed_url = hash_url(normalized_url, namespace:
|
115
|
+
hashed_url = hash_url(normalized_url, namespace:)
|
126
116
|
|
127
|
-
find_by(hashed_url:
|
117
|
+
find_by(hashed_url:)
|
128
118
|
end
|
129
119
|
|
130
120
|
# Normalizes a URL. Adds or removes a trailing slash, removes +?+ for an empty query, and so on. And sorts query
|
@@ -148,7 +138,7 @@ module Tanshuku
|
|
148
138
|
#
|
149
139
|
# @return [String] Depends on your {Tanshuku::Configuration#url_hasher} configuration.
|
150
140
|
def self.hash_url(url, namespace: DEFAULT_NAMESPACE)
|
151
|
-
Tanshuku.config.url_hasher.call(url, namespace:
|
141
|
+
Tanshuku.config.url_hasher.call(url, namespace:)
|
152
142
|
end
|
153
143
|
|
154
144
|
# Generates a unique key for a shortened URL.
|
@@ -169,7 +159,7 @@ module Tanshuku
|
|
169
159
|
#
|
170
160
|
# @return [void] Depends on your {Tanshuku::Configuration#exception_reporter} configuration.
|
171
161
|
def self.report_exception(exception:, original_url:)
|
172
|
-
Tanshuku.config.exception_reporter.call(exception
|
162
|
+
Tanshuku.config.exception_reporter.call(exception:, original_url:)
|
173
163
|
end
|
174
164
|
|
175
165
|
# The record’s shortened URL.
|
@@ -185,14 +175,6 @@ module Tanshuku
|
|
185
175
|
|
186
176
|
Tanshuku::Engine.routes.url_for(url_options)
|
187
177
|
end
|
188
|
-
|
189
|
-
private
|
190
|
-
|
191
|
-
def validates_length_of_url
|
192
|
-
if url && url.length > Tanshuku.config.max_url_length
|
193
|
-
errors.add(:url, :too_long, count: Tanshuku.config.max_url_length)
|
194
|
-
end
|
195
|
-
end
|
196
178
|
end
|
197
179
|
# rubocop:enable Rails/ApplicationRecord
|
198
180
|
end
|
@@ -7,7 +7,8 @@ module Tanshuku
|
|
7
7
|
#
|
8
8
|
# @api private
|
9
9
|
class InstallGenerator < Rails::Generators::Base
|
10
|
-
|
10
|
+
# Assign `_ = __dir__` because Steep reports `__dir__` which can be a `nil` but I don’t want to care about that.
|
11
|
+
source_root File.expand_path("../templates", _ = __dir__)
|
11
12
|
|
12
13
|
# Generates a configuration file +config/initializers/tanshuku.rb+.
|
13
14
|
#
|
@@ -42,68 +42,7 @@ module Tanshuku
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
include ActiveModel::Attributes
|
47
|
-
else
|
48
|
-
# https://github.com/rails/rails/blob/v5.2.8.1/activemodel/lib/active_model/attributes.rb
|
49
|
-
# https://github.com/rails/rails/blob/v5.2.8.1/activemodel/lib/active_model/type/integer.rb
|
50
|
-
concerning :PetitModelAttributes do
|
51
|
-
const_set :NO_DEFAULT_PROVIDED, Object.new
|
52
|
-
|
53
|
-
class_methods do
|
54
|
-
# rubocop:disable Metrics/MethodLength
|
55
|
-
|
56
|
-
# A petit and limited implementation of `ActiveModel::Attributes`'s `attribute` method for backward
|
57
|
-
# compatibility.
|
58
|
-
#
|
59
|
-
# @param name [Symbol] An attribute name.
|
60
|
-
# @param cast_type [Symbol,nil] A type to cast the attribute's value.
|
61
|
-
# @param default [Object] A default value of the attribute.
|
62
|
-
#
|
63
|
-
# @return [void]
|
64
|
-
def attribute(name, cast_type = nil, default: NO_DEFAULT_PROVIDED)
|
65
|
-
attr_reader name
|
66
|
-
|
67
|
-
case cast_type
|
68
|
-
when nil
|
69
|
-
attr_writer name
|
70
|
-
when :integer
|
71
|
-
class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
72
|
-
def #{name}=(value) # def max_url_length=(value)
|
73
|
-
@#{name} = # @max_url_length =
|
74
|
-
case value # case value
|
75
|
-
when true # when true
|
76
|
-
1 # 1
|
77
|
-
when false # when false
|
78
|
-
0 # 0
|
79
|
-
when nil # when nil
|
80
|
-
nil # nil
|
81
|
-
else # else
|
82
|
-
value.to_i rescue nil # value.to_i rescue nil
|
83
|
-
end # end
|
84
|
-
end # end
|
85
|
-
RUBY
|
86
|
-
else
|
87
|
-
raise ArgumentError, "Non-supported cast type: #{cast_type.inspect}"
|
88
|
-
end
|
89
|
-
|
90
|
-
return if default == NO_DEFAULT_PROVIDED
|
91
|
-
|
92
|
-
mod =
|
93
|
-
Module.new do
|
94
|
-
class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
95
|
-
def initialize(*args) # def initialize(*args)
|
96
|
-
super # super
|
97
|
-
self.#{name} = #{default.inspect} # self.max_url_length = 10_000
|
98
|
-
end # end
|
99
|
-
RUBY
|
100
|
-
end
|
101
|
-
prepend mod
|
102
|
-
end
|
103
|
-
# rubocop:enable Metrics/MethodLength
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
45
|
+
include ActiveModel::Attributes
|
107
46
|
|
108
47
|
# @!attribute [rw] default_url_options
|
109
48
|
# Default URL options for Rails’ +url_for+. Defaults to +{}+.
|
@@ -227,12 +166,12 @@ module Tanshuku
|
|
227
166
|
# Tanshuku.configure do |config|
|
228
167
|
# config.exception_reporter =
|
229
168
|
# lambda { |exception:, original_url:|
|
230
|
-
# Sentry.capture_exception(exception, tags: { original_url:
|
169
|
+
# Sentry.capture_exception(exception, tags: { original_url: })
|
231
170
|
# }
|
232
171
|
# end
|
233
172
|
attribute :exception_reporter, default: DefaultExceptionReporter
|
234
173
|
|
235
|
-
def initialize(
|
174
|
+
def initialize(...)
|
236
175
|
super
|
237
176
|
@mutex = Mutex.new
|
238
177
|
end
|
data/lib/tanshuku/version.rb
CHANGED
data/lib/tanshuku.rb
CHANGED
data/lib/tasks/check_all.rb
CHANGED
@@ -6,7 +6,7 @@ require "paint"
|
|
6
6
|
require "pty"
|
7
7
|
|
8
8
|
class CheckAll
|
9
|
-
TASKNAMES = %i[rubocop spec yard:check].freeze
|
9
|
+
TASKNAMES = %i[rubocop spec steep:check yard:check].freeze
|
10
10
|
LINE = Paint["-" * (IO.console or raise).winsize[1], :bold]
|
11
11
|
TITLE_TEMPLATE = Paint["\n#{LINE}\nExecute: %<command>s\n#{LINE}\n\n", :bold]
|
12
12
|
|
@@ -32,7 +32,7 @@ class CheckAll
|
|
32
32
|
command = "bundle exec rake #{taskname}"
|
33
33
|
|
34
34
|
outputs = []
|
35
|
-
outputs << format(TITLE_TEMPLATE, command:
|
35
|
+
outputs << format(TITLE_TEMPLATE, command:)
|
36
36
|
|
37
37
|
# Use `PTY.spawn` to get colorized outputs of each command.
|
38
38
|
PTY.spawn(command) do |reader, writer, pid|
|
@@ -0,0 +1,230 @@
|
|
1
|
+
---
|
2
|
+
sources:
|
3
|
+
- type: git
|
4
|
+
name: ruby/gem_rbs_collection
|
5
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
6
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
7
|
+
repo_dir: gems
|
8
|
+
path: ".gem_rbs_collection"
|
9
|
+
gems:
|
10
|
+
- name: actionmailer
|
11
|
+
version: '7.0'
|
12
|
+
source:
|
13
|
+
type: git
|
14
|
+
name: ruby/gem_rbs_collection
|
15
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
16
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
17
|
+
repo_dir: gems
|
18
|
+
- name: actionpack
|
19
|
+
version: '6.0'
|
20
|
+
source:
|
21
|
+
type: git
|
22
|
+
name: ruby/gem_rbs_collection
|
23
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
24
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
25
|
+
repo_dir: gems
|
26
|
+
- name: actionview
|
27
|
+
version: '6.0'
|
28
|
+
source:
|
29
|
+
type: git
|
30
|
+
name: ruby/gem_rbs_collection
|
31
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
32
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
33
|
+
repo_dir: gems
|
34
|
+
- name: activejob
|
35
|
+
version: '6.0'
|
36
|
+
source:
|
37
|
+
type: git
|
38
|
+
name: ruby/gem_rbs_collection
|
39
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
40
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
41
|
+
repo_dir: gems
|
42
|
+
- name: activemodel
|
43
|
+
version: '7.0'
|
44
|
+
source:
|
45
|
+
type: git
|
46
|
+
name: ruby/gem_rbs_collection
|
47
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
48
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
49
|
+
repo_dir: gems
|
50
|
+
- name: activerecord
|
51
|
+
version: '7.0'
|
52
|
+
source:
|
53
|
+
type: git
|
54
|
+
name: ruby/gem_rbs_collection
|
55
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
56
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
57
|
+
repo_dir: gems
|
58
|
+
- name: activestorage
|
59
|
+
version: '6.1'
|
60
|
+
source:
|
61
|
+
type: git
|
62
|
+
name: ruby/gem_rbs_collection
|
63
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
64
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
65
|
+
repo_dir: gems
|
66
|
+
- name: activesupport
|
67
|
+
version: '7.0'
|
68
|
+
source:
|
69
|
+
type: git
|
70
|
+
name: ruby/gem_rbs_collection
|
71
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
72
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
73
|
+
repo_dir: gems
|
74
|
+
- name: base64
|
75
|
+
version: '0'
|
76
|
+
source:
|
77
|
+
type: stdlib
|
78
|
+
- name: bigdecimal
|
79
|
+
version: '0'
|
80
|
+
source:
|
81
|
+
type: stdlib
|
82
|
+
- name: cgi
|
83
|
+
version: '0'
|
84
|
+
source:
|
85
|
+
type: stdlib
|
86
|
+
- name: concurrent-ruby
|
87
|
+
version: '1.1'
|
88
|
+
source:
|
89
|
+
type: git
|
90
|
+
name: ruby/gem_rbs_collection
|
91
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
92
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
93
|
+
repo_dir: gems
|
94
|
+
- name: connection_pool
|
95
|
+
version: '2.4'
|
96
|
+
source:
|
97
|
+
type: git
|
98
|
+
name: ruby/gem_rbs_collection
|
99
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
100
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
101
|
+
repo_dir: gems
|
102
|
+
- name: date
|
103
|
+
version: '0'
|
104
|
+
source:
|
105
|
+
type: stdlib
|
106
|
+
- name: digest
|
107
|
+
version: '0'
|
108
|
+
source:
|
109
|
+
type: stdlib
|
110
|
+
- name: erb
|
111
|
+
version: '0'
|
112
|
+
source:
|
113
|
+
type: stdlib
|
114
|
+
- name: globalid
|
115
|
+
version: '1.1'
|
116
|
+
source:
|
117
|
+
type: git
|
118
|
+
name: ruby/gem_rbs_collection
|
119
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
120
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
121
|
+
repo_dir: gems
|
122
|
+
- name: i18n
|
123
|
+
version: '1.10'
|
124
|
+
source:
|
125
|
+
type: git
|
126
|
+
name: ruby/gem_rbs_collection
|
127
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
128
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
129
|
+
repo_dir: gems
|
130
|
+
- name: io-console
|
131
|
+
version: '0'
|
132
|
+
source:
|
133
|
+
type: stdlib
|
134
|
+
- name: logger
|
135
|
+
version: '0'
|
136
|
+
source:
|
137
|
+
type: stdlib
|
138
|
+
- name: mail
|
139
|
+
version: '2.8'
|
140
|
+
source:
|
141
|
+
type: git
|
142
|
+
name: ruby/gem_rbs_collection
|
143
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
144
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
145
|
+
repo_dir: gems
|
146
|
+
- name: minitest
|
147
|
+
version: '0'
|
148
|
+
source:
|
149
|
+
type: stdlib
|
150
|
+
- name: monitor
|
151
|
+
version: '0'
|
152
|
+
source:
|
153
|
+
type: stdlib
|
154
|
+
- name: mutex_m
|
155
|
+
version: '0'
|
156
|
+
source:
|
157
|
+
type: stdlib
|
158
|
+
- name: nokogiri
|
159
|
+
version: '1.11'
|
160
|
+
source:
|
161
|
+
type: git
|
162
|
+
name: ruby/gem_rbs_collection
|
163
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
164
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
165
|
+
repo_dir: gems
|
166
|
+
- name: rack
|
167
|
+
version: '2.2'
|
168
|
+
source:
|
169
|
+
type: git
|
170
|
+
name: ruby/gem_rbs_collection
|
171
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
172
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
173
|
+
repo_dir: gems
|
174
|
+
- name: rails-dom-testing
|
175
|
+
version: '2.0'
|
176
|
+
source:
|
177
|
+
type: git
|
178
|
+
name: ruby/gem_rbs_collection
|
179
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
180
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
181
|
+
repo_dir: gems
|
182
|
+
- name: railties
|
183
|
+
version: '6.0'
|
184
|
+
source:
|
185
|
+
type: git
|
186
|
+
name: ruby/gem_rbs_collection
|
187
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
188
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
189
|
+
repo_dir: gems
|
190
|
+
- name: rdoc
|
191
|
+
version: '0'
|
192
|
+
source:
|
193
|
+
type: stdlib
|
194
|
+
- name: securerandom
|
195
|
+
version: '0'
|
196
|
+
source:
|
197
|
+
type: stdlib
|
198
|
+
- name: singleton
|
199
|
+
version: '0'
|
200
|
+
source:
|
201
|
+
type: stdlib
|
202
|
+
- name: tempfile
|
203
|
+
version: '0'
|
204
|
+
source:
|
205
|
+
type: stdlib
|
206
|
+
- name: thor
|
207
|
+
version: '1.2'
|
208
|
+
source:
|
209
|
+
type: git
|
210
|
+
name: ruby/gem_rbs_collection
|
211
|
+
revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
|
212
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
213
|
+
repo_dir: gems
|
214
|
+
- name: time
|
215
|
+
version: '0'
|
216
|
+
source:
|
217
|
+
type: stdlib
|
218
|
+
- name: timeout
|
219
|
+
version: '0'
|
220
|
+
source:
|
221
|
+
type: stdlib
|
222
|
+
- name: tsort
|
223
|
+
version: '0'
|
224
|
+
source:
|
225
|
+
type: stdlib
|
226
|
+
- name: uri
|
227
|
+
version: '0'
|
228
|
+
source:
|
229
|
+
type: stdlib
|
230
|
+
gemfile_lock_path: Gemfile.lock
|
data/rbs_collection.yaml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
sources:
|
2
|
+
- type: git
|
3
|
+
name: ruby/gem_rbs_collection
|
4
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
5
|
+
revision: main
|
6
|
+
repo_dir: gems
|
7
|
+
|
8
|
+
path: .gem_rbs_collection
|
9
|
+
|
10
|
+
gems:
|
11
|
+
- name: rbs
|
12
|
+
ignore: true
|
13
|
+
- name: steep
|
14
|
+
ignore: true
|
15
|
+
- name: tanshuku
|
16
|
+
ignore: true
|
17
|
+
|
18
|
+
- name: digest
|
19
|
+
- name: securerandom
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# cf. https://github.com/pocke/rbs_rails
|
2
|
+
module Tanshuku
|
3
|
+
class Url < ActiveRecord::Base
|
4
|
+
class ActiveRecord_Relation < ActiveRecord::Relation
|
5
|
+
include _ActiveRecord_Relation[Tanshuku::Url, Integer]
|
6
|
+
include Enumerable[Tanshuku::Url]
|
7
|
+
end
|
8
|
+
|
9
|
+
extend _ActiveRecord_Relation_ClassMethods[Tanshuku::Url, ActiveRecord_Relation, Integer]
|
10
|
+
|
11
|
+
DEFAULT_NAMESPACE: String
|
12
|
+
|
13
|
+
module GeneratedAttributeMethods
|
14
|
+
attr_accessor id (): Integer?
|
15
|
+
def id?: () -> bool
|
16
|
+
def id_changed?: () -> bool
|
17
|
+
def id_change: () -> [Integer?, Integer?]
|
18
|
+
def id_will_change!: () -> void
|
19
|
+
def id_was: () -> Integer?
|
20
|
+
def id_previously_changed?: () -> bool
|
21
|
+
def id_previous_change: () -> [Integer?, Integer?]?
|
22
|
+
def id_previously_was: () -> Integer?
|
23
|
+
def id_before_last_save: () -> Integer?
|
24
|
+
def id_change_to_be_saved: () -> [Integer?, Integer?]?
|
25
|
+
def id_in_database: () -> Integer?
|
26
|
+
def saved_change_to_id: () -> [Integer?, Integer?]?
|
27
|
+
def saved_change_to_id?: () -> bool
|
28
|
+
def will_save_change_to_id?: () -> bool
|
29
|
+
def restore_id!: () -> void
|
30
|
+
def clear_id_change: () -> void
|
31
|
+
|
32
|
+
attr_accessor url (): String?
|
33
|
+
def url?: () -> bool
|
34
|
+
def url_changed?: () -> bool
|
35
|
+
def url_change: () -> [String?, String?]
|
36
|
+
def url_will_change!: () -> void
|
37
|
+
def url_was: () -> String?
|
38
|
+
def url_previously_changed?: () -> bool
|
39
|
+
def url_previous_change: () -> [String?, String?]?
|
40
|
+
def url_previously_was: () -> String?
|
41
|
+
def url_before_last_save: () -> String?
|
42
|
+
def url_change_to_be_saved: () -> [String?, String?]?
|
43
|
+
def url_in_database: () -> String?
|
44
|
+
def saved_change_to_url: () -> [String?, String?]?
|
45
|
+
def saved_change_to_url?: () -> bool
|
46
|
+
def will_save_change_to_url?: () -> bool
|
47
|
+
def restore_url!: () -> void
|
48
|
+
def clear_url_change: () -> void
|
49
|
+
|
50
|
+
attr_accessor hashed_url (): String?
|
51
|
+
def hashed_url?: () -> bool
|
52
|
+
def hashed_url_changed?: () -> bool
|
53
|
+
def hashed_url_change: () -> [String?, String?]
|
54
|
+
def hashed_url_will_change!: () -> void
|
55
|
+
def hashed_url_was: () -> String?
|
56
|
+
def hashed_url_previously_changed?: () -> bool
|
57
|
+
def hashed_url_previous_change: () -> [String?, String?]?
|
58
|
+
def hashed_url_previously_was: () -> String?
|
59
|
+
def hashed_url_before_last_save: () -> String?
|
60
|
+
def hashed_url_change_to_be_saved: () -> [String?, String?]?
|
61
|
+
def hashed_url_in_database: () -> String?
|
62
|
+
def saved_change_to_hashed_url: () -> [String?, String?]?
|
63
|
+
def saved_change_to_hashed_url?: () -> bool
|
64
|
+
def will_save_change_to_hashed_url?: () -> bool
|
65
|
+
def restore_hashed_url!: () -> void
|
66
|
+
def clear_hashed_url_change: () -> void
|
67
|
+
|
68
|
+
attr_accessor key (): String?
|
69
|
+
def key?: () -> bool
|
70
|
+
def key_changed?: () -> bool
|
71
|
+
def key_change: () -> [String?, String?]
|
72
|
+
def key_will_change!: () -> void
|
73
|
+
def key_was: () -> String?
|
74
|
+
def key_previously_changed?: () -> bool
|
75
|
+
def key_previous_change: () -> [String?, String?]?
|
76
|
+
def key_previously_was: () -> String?
|
77
|
+
def key_before_last_save: () -> String?
|
78
|
+
def key_change_to_be_saved: () -> [String?, String?]?
|
79
|
+
def key_in_database: () -> String?
|
80
|
+
def saved_change_to_key: () -> [String?, String?]?
|
81
|
+
def saved_change_to_key?: () -> bool
|
82
|
+
def will_save_change_to_key?: () -> bool
|
83
|
+
def restore_key!: () -> void
|
84
|
+
def clear_key_change: () -> void
|
85
|
+
|
86
|
+
attr_accessor created_at (): ActiveSupport::TimeWithZone?
|
87
|
+
def created_at?: () -> bool
|
88
|
+
def created_at_changed?: () -> bool
|
89
|
+
def created_at_change: () -> [ActiveSupport::TimeWithZone?, ActiveSupport::TimeWithZone?]
|
90
|
+
def created_at_will_change!: () -> void
|
91
|
+
def created_at_was: () -> ActiveSupport::TimeWithZone?
|
92
|
+
def created_at_previously_changed?: () -> bool
|
93
|
+
def created_at_previous_change: () -> [ActiveSupport::TimeWithZone?, ActiveSupport::TimeWithZone?]?
|
94
|
+
def created_at_previously_was: () -> ActiveSupport::TimeWithZone?
|
95
|
+
def created_at_before_last_save: () -> ActiveSupport::TimeWithZone?
|
96
|
+
def created_at_change_to_be_saved: () -> [ActiveSupport::TimeWithZone?, ActiveSupport::TimeWithZone?]?
|
97
|
+
def created_at_in_database: () -> ActiveSupport::TimeWithZone?
|
98
|
+
def saved_change_to_created_at: () -> [ActiveSupport::TimeWithZone?, ActiveSupport::TimeWithZone?]?
|
99
|
+
def saved_change_to_created_at?: () -> bool
|
100
|
+
def will_save_change_to_created_at?: () -> bool
|
101
|
+
def restore_created_at!: () -> void
|
102
|
+
def clear_created_at_change: () -> void
|
103
|
+
end
|
104
|
+
include GeneratedAttributeMethods
|
105
|
+
|
106
|
+
def self.shorten: (String original_url, ?namespace: String, ?url_options: Hash[String | Symbol, untyped]) -> String
|
107
|
+
def self.find_by_url: (String url, ?namespace: String) -> Tanshuku::Url?
|
108
|
+
def self.normalize_url: (String url) -> String
|
109
|
+
def self.hash_url: (String url, ?namespace: String) -> String
|
110
|
+
def self.generate_key: -> String
|
111
|
+
def self.report_exception: (exception: Exception, original_url: String) -> void
|
112
|
+
def shortened_url: (?Hash[String | Symbol, untyped] url_options) -> String
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Tanshuku
|
2
|
+
class Configuration
|
3
|
+
interface _UrlHasher
|
4
|
+
def call: (String url, namespace: String) -> String
|
5
|
+
end
|
6
|
+
|
7
|
+
interface _KeyGenerator
|
8
|
+
def call: -> String
|
9
|
+
end
|
10
|
+
|
11
|
+
interface _ExceptionReporter
|
12
|
+
def call: (exception: Exception, original_url: String) -> void
|
13
|
+
end
|
14
|
+
|
15
|
+
extend ActiveModel::Attributes::ClassMethods
|
16
|
+
|
17
|
+
@mutex: Thread::Mutex
|
18
|
+
|
19
|
+
attr_accessor default_url_options (): Hash[String | Symbol, untyped]
|
20
|
+
attr_accessor max_url_length (): Integer
|
21
|
+
attr_accessor url_pattern (): Regexp
|
22
|
+
attr_accessor key_length (): Integer
|
23
|
+
attr_accessor url_hasher (): _UrlHasher
|
24
|
+
attr_accessor key_generator (): _KeyGenerator
|
25
|
+
attr_accessor exception_reporter (): _ExceptionReporter
|
26
|
+
|
27
|
+
def initialize: (*bot noname) -> void
|
28
|
+
def configure: { (Configuration) -> void } -> void
|
29
|
+
|
30
|
+
module DefaultUrlHasher
|
31
|
+
extend _UrlHasher
|
32
|
+
end
|
33
|
+
|
34
|
+
module DefaultKeyGenerator
|
35
|
+
extend _KeyGenerator
|
36
|
+
end
|
37
|
+
|
38
|
+
module DefaultExceptionReporter
|
39
|
+
extend _ExceptionReporter
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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 self.call: () -> void
|
9
|
+
|
10
|
+
def call: () -> void
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def executor: () -> ^(*String) -> void
|
15
|
+
def output_result: () -> void
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanshuku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kg8m
|
@@ -16,34 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '6.0'
|
33
|
+
version: 7.0.0
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ">="
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '6.0'
|
40
|
+
version: 7.0.0
|
47
41
|
description: Tanshuku is a simple and performance aware Rails engine for shortening
|
48
42
|
URLs. Tanshuku generates a shortened URL per a normalized original URL. Tanshuku
|
49
43
|
redirects from a shortened URL to its corresponding original URL.
|
@@ -55,6 +49,7 @@ extra_rdoc_files: []
|
|
55
49
|
files:
|
56
50
|
- LICENSE
|
57
51
|
- README.md
|
52
|
+
- Steepfile
|
58
53
|
- app/controllers/tanshuku/urls_controller.rb
|
59
54
|
- app/models/tanshuku/url.rb
|
60
55
|
- config/locales/en.yml
|
@@ -68,6 +63,17 @@ files:
|
|
68
63
|
- lib/tanshuku/engine.rb
|
69
64
|
- lib/tanshuku/version.rb
|
70
65
|
- lib/tasks/check_all.rb
|
66
|
+
- rbs_collection.lock.yaml
|
67
|
+
- rbs_collection.yaml
|
68
|
+
- sig/app/controllers/tanshuku/urls_controller.rbs
|
69
|
+
- sig/app/models/tanshuku/url.rbs
|
70
|
+
- sig/db/migrate/create_tanshuku_urls.rbs
|
71
|
+
- sig/lib/generators/tanshuku/install_generator.rbs
|
72
|
+
- sig/lib/tanshuku.rbs
|
73
|
+
- sig/lib/tanshuku/configuration.rbs
|
74
|
+
- sig/lib/tanshuku/engine.rbs
|
75
|
+
- sig/lib/tanshuku/version.rbs
|
76
|
+
- sig/lib/tasks/check_all.rbs
|
71
77
|
homepage: https://github.com/kg8m/tanshuku
|
72
78
|
licenses:
|
73
79
|
- MIT
|
@@ -85,17 +91,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
91
|
requirements:
|
86
92
|
- - ">="
|
87
93
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
89
|
-
- - "<"
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '3.0'
|
94
|
+
version: '3.1'
|
92
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
97
|
- - ">="
|
95
98
|
- !ruby/object:Gem::Version
|
96
99
|
version: '0'
|
97
100
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.4.10
|
99
102
|
signing_key:
|
100
103
|
specification_version: 4
|
101
104
|
summary: Tanshuku is a simple and performance aware Rails engine for shortening URLs.
|