ombu_labs-shortener 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -1
- data/lib/ombu_labs/shortener/cli/application.rb +1 -1
- data/lib/ombu_labs/shortener/version.rb +1 -1
- data/lib/ombu_labs/shortener.rb +27 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b41c6ce007788b2e45ca15b194d133f2be197becb6ff1155f0936b2607ac4ef
|
4
|
+
data.tar.gz: c756cd79bca5d925b465c327581fcefa09f329fe4e4b3bfe9a074a79f67d9c38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 440e33d610fa634ab46e73029413bfd14265d185f50f2e4d8dee8d22b5079e3419e566d92697e6210ef5942c856fef685cc93d97ff04e4348fe5eb1d79fd561c
|
7
|
+
data.tar.gz: e06ac0d425851010e7bb76be5e76cac2850cb665e147d060c0d99dc69f882211e636b0036bea7851b8fa2bb7b244a2e52529ad40846ef1497ab3faa4131024e7
|
data/Gemfile.lock
CHANGED
data/lib/ombu_labs/shortener.rb
CHANGED
@@ -6,22 +6,43 @@ require_relative "shortener/version"
|
|
6
6
|
module OmbuLabs
|
7
7
|
module Shortener
|
8
8
|
class RebrandlyClient
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
# You can initialize the client like this:
|
11
|
+
#
|
12
|
+
# > OmbuLabs::Shortener::RebrandlyClient.new("https://example.com/ombu")
|
13
|
+
#
|
14
|
+
# @param args [String] A valid long URL
|
15
|
+
def initialize(url)
|
16
|
+
@url = url
|
11
17
|
Rebrandly.configure do |config|
|
12
18
|
config.api_key = ENV['REBRANDLY_API_KEY']
|
13
19
|
end
|
14
20
|
@api = Rebrandly::Api.new
|
15
21
|
end
|
16
22
|
|
23
|
+
# Shortens the URL and returns a short URL string. It will
|
24
|
+
# NOT raise an exception if there is a communication error with
|
25
|
+
# the Rebrandly API.
|
26
|
+
#
|
27
|
+
# @return [String]
|
17
28
|
def shorten
|
29
|
+
shorten!
|
30
|
+
rescue Rebrandly::RebrandlyError => err
|
31
|
+
puts "Error: #{err.message}"
|
32
|
+
@url
|
33
|
+
end
|
34
|
+
|
35
|
+
# Shortens the URL and returns a short URL string. It will
|
36
|
+
# raise an exception if there is a communication error with
|
37
|
+
# the Rebrandly API.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
def shorten!
|
18
41
|
puts "Shortening: #{@url}"
|
19
42
|
domain = find_domain
|
20
43
|
link = @api.shorten(@url, domain: domain.to_h)
|
21
44
|
puts "Shortened: SHORT: https://#{link.short_url}"
|
22
|
-
|
23
|
-
rescue Rebrandly::RebrandlyError => err
|
24
|
-
puts "Error: #{err.message}"
|
45
|
+
link.short_url
|
25
46
|
end
|
26
47
|
|
27
48
|
private
|
@@ -46,4 +67,4 @@ module OmbuLabs
|
|
46
67
|
class Error < StandardError; end
|
47
68
|
# Your code goes here...
|
48
69
|
end
|
49
|
-
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ombu_labs-shortener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernesto Tagwerker
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rebrandly
|
@@ -67,7 +67,7 @@ metadata:
|
|
67
67
|
homepage_uri: https://github.com/fastruby/ombu_labs-shortener
|
68
68
|
source_code_uri: https://github.com/fastruby/ombu_labs-shortener
|
69
69
|
changelog_uri: https://github.com/fastruby/ombu_labs-shortener/CHANGELOG.md
|
70
|
-
post_install_message:
|
70
|
+
post_install_message:
|
71
71
|
rdoc_options: []
|
72
72
|
require_paths:
|
73
73
|
- lib
|
@@ -82,8 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.3.
|
86
|
-
signing_key:
|
85
|
+
rubygems_version: 3.3.7
|
86
|
+
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: One executable to shorten all the long URLs related to OmbuLabs.
|
89
89
|
test_files: []
|