tanshuku 0.0.11 → 0.0.12
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 +9 -4
- data/lib/tanshuku/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06377e7737ccb49d4080ce2a728f4ba5ca98d00bd14f85838e3e888c899327d1
|
4
|
+
data.tar.gz: 63065a557df15b3c6ca45b9af168a9562a8aae1f9a41bb7b3db7a2ad9adaa82f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bab0a2c9c7b26ec1f34ef02d465ecea40435e890e6381a6e3140850e5738a803141906f5bb6ca2b2ff715935d5380eb3119b66f556ce231d8f584b21d5f66d3
|
7
|
+
data.tar.gz: 14d22e0bb7de15a6c37de42e314be5521f2e3ff77bd8511cacfd1cf0847791b4a234c98e459a01e1443f52990672b9be636828f90a3aaf10fb67bc6d4fb9e8f6
|
data/app/models/tanshuku/url.rb
CHANGED
@@ -22,7 +22,7 @@ module Tanshuku
|
|
22
22
|
# duplicated. Then rescue the exception and try to retry.
|
23
23
|
# validates :url, :hashed_url, :key, uniqueness: true
|
24
24
|
|
25
|
-
def self.shorten(original_url, namespace: DEFAULT_NAMESPACE)
|
25
|
+
def self.shorten(original_url, namespace: DEFAULT_NAMESPACE, url_options: {})
|
26
26
|
raise ArgumentError, "original_url should be present" unless original_url
|
27
27
|
|
28
28
|
url = normalize_url(original_url)
|
@@ -35,7 +35,7 @@ module Tanshuku
|
|
35
35
|
r.attributes = { url:, key: generate_key }
|
36
36
|
end
|
37
37
|
|
38
|
-
record.shortened_url
|
38
|
+
record.shortened_url(url_options)
|
39
39
|
end
|
40
40
|
# ActiveRecord::RecordNotFound is raised when the key is duplicated.
|
41
41
|
rescue ActiveRecord::RecordNotFound => e
|
@@ -78,8 +78,13 @@ module Tanshuku
|
|
78
78
|
Tanshuku.config.exception_reporter.call(exception:, original_url:)
|
79
79
|
end
|
80
80
|
|
81
|
-
def shortened_url
|
82
|
-
|
81
|
+
def shortened_url(url_options = {})
|
82
|
+
url_options = url_options.symbolize_keys
|
83
|
+
url_options[:controller] = "tanshuku/urls"
|
84
|
+
url_options[:action] = :show
|
85
|
+
url_options[:key] = key
|
86
|
+
|
87
|
+
Tanshuku::Engine.routes.url_for(url_options)
|
83
88
|
end
|
84
89
|
end
|
85
90
|
end
|
data/lib/tanshuku/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanshuku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kg8m
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|