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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58228d834716ae9f1a9415212f4976816aeaf61bd6ff2a1e92672a62bd202a93
4
- data.tar.gz: e8ecd16d19d73cdff428f08cd5a3b801e59934fa86d69fa1b182e0da40da1feb
3
+ metadata.gz: 06377e7737ccb49d4080ce2a728f4ba5ca98d00bd14f85838e3e888c899327d1
4
+ data.tar.gz: 63065a557df15b3c6ca45b9af168a9562a8aae1f9a41bb7b3db7a2ad9adaa82f
5
5
  SHA512:
6
- metadata.gz: f786879cc78304a288487079e4b2e218be8df2d7c6df4edc8f629ca672369fa583998e2b44bc4d62876b1f242dd24ae0f67201a1a85f391d20fb26dd07d80ca1
7
- data.tar.gz: 2b7af5d5181be59774b1d6ae13e12df32347c862cec776139a4ba31da153a38fb63959380e8bebcc931fa707b658799b33eb5a248a7bf765ba77dc9de3397bf9
6
+ metadata.gz: 5bab0a2c9c7b26ec1f34ef02d465ecea40435e890e6381a6e3140850e5738a803141906f5bb6ca2b2ff715935d5380eb3119b66f556ce231d8f584b21d5f66d3
7
+ data.tar.gz: 14d22e0bb7de15a6c37de42e314be5521f2e3ff77bd8511cacfd1cf0847791b4a234c98e459a01e1443f52990672b9be636828f90a3aaf10fb67bc6d4fb9e8f6
@@ -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
- Tanshuku::Engine.routes.url_for(controller: "tanshuku/urls", action: :show, key:)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tanshuku
4
- VERSION = "0.0.11"
4
+ VERSION = "0.0.12"
5
5
  end
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.11
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-10 00:00:00.000000000 Z
11
+ date: 2023-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable