tanshuku 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 797579e31bb1b82be39ee3e1e9b47cab79bd93db8088ef07f2a442c0f843b71b
4
- data.tar.gz: 96fde025c079c4253338bc58bd487075f93b50262247e1349eb2c56d3fc26a16
3
+ metadata.gz: c4b9a3b20b2baf4c09ad35c5e10d00419ec7e3492f885b3cceb9cc129355f722
4
+ data.tar.gz: f66396318dcb615cef25136c8e6206cf3b857ea4907cb0fb45f1195f4e53caf5
5
5
  SHA512:
6
- metadata.gz: 32be6ddbfd71a34393bb100f8a5382ef456e3c856598f5b9947a8fa8aa292b6578e4150cda40aec4125c022ad8a55449b71df00916a0b1c9c42a5aac8fe578ab
7
- data.tar.gz: 5becf84144a9a733310fd8d7a871f7e66921d6ef9f84400c618ee1a3c6ad43413693f30090f80ecca293dabe513927f3f81638dc98066d03a46ff1d0ebd512c6
6
+ metadata.gz: 02f976e4e5b3d24cbdb867eba134387f74b4050b65238d26a2307308b12ce55413fbe42fe95bfff68e3b25deca790eed20852ee50ea2069be2cbd0c8430aab38
7
+ data.tar.gz: efaf9a395bab9c57a3cb985cc93f699c5f5c39dd8c776d23ebae71531b2a398044dd1c15c452bbbdeb988961b492179aa6fc821910dd71a65d03197182f0e80f
@@ -23,12 +23,14 @@ module Tanshuku
23
23
  def self.shorten(original_url, retries: 0)
24
24
  url = normalize_url(original_url)
25
25
 
26
- record =
27
- create_or_find_by!(hashed_url: hash_url(url)) do |r|
28
- r.attributes = { url:, key: generate_key }
29
- end
26
+ transaction do
27
+ record =
28
+ create_or_find_by!(hashed_url: hash_url(url)) do |r|
29
+ r.attributes = { url:, key: generate_key }
30
+ end
30
31
 
31
- record.shortened_url
32
+ record.shortened_url
33
+ end
32
34
  rescue ActiveRecord::RecordNotUnique => e
33
35
  if retries < 10
34
36
  shorten(url, retries: retries + 1)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateRailsUrlShortenerUrls < ActiveRecord::Migration[7.0]
3
+ class CreateTanshukuUrls < ActiveRecord::Migration[7.0]
4
4
  def change
5
5
  create_table :tanshuku_urls do |t|
6
6
  t.text :url, null: false
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tanshuku
4
- VERSION = "0.0.6"
4
+ VERSION = "0.0.8"
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.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - kg8m
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-21 00:00:00.000000000 Z
11
+ date: 2023-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable