ombu_labs-shortener 0.1.1 → 0.2.0

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: '0783a590c5d702f09609f84009663cb0c7b731382af63a794137271d8fe89334'
4
- data.tar.gz: 7e6bd4b44d362d68381a83e1f5ad9c0e8ac92f6af18435691da234c47b183080
3
+ metadata.gz: 1b41c6ce007788b2e45ca15b194d133f2be197becb6ff1155f0936b2607ac4ef
4
+ data.tar.gz: c756cd79bca5d925b465c327581fcefa09f329fe4e4b3bfe9a074a79f67d9c38
5
5
  SHA512:
6
- metadata.gz: 777407491cde0678bf15abcba81bc22f8497f8491274904eb96714f83e28dbe47e7f29269939083d536a8e075a13dedcd60497027bbf60ab13aa586fd4d66869
7
- data.tar.gz: 74d12d2dba7d0f5e7ec1c9be9ba7db9420fcdd63b1409d6bfa27f71225d045df030d2f59c38f1190cfabcdb664de42f656b386ae359576e951b4ba175a6108f1
6
+ metadata.gz: 440e33d610fa634ab46e73029413bfd14265d185f50f2e4d8dee8d22b5079e3419e566d92697e6210ef5942c856fef685cc93d97ff04e4348fe5eb1d79fd561c
7
+ data.tar.gz: e06ac0d425851010e7bb76be5e76cac2850cb665e147d060c0d99dc69f882211e636b0036bea7851b8fa2bb7b244a2e52529ad40846ef1497ab3faa4131024e7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ombu_labs-shortener (0.1.0)
4
+ ombu_labs-shortener (0.1.1)
5
5
  rebrandly
6
6
 
7
7
  GEM
@@ -35,6 +35,7 @@ GEM
35
35
 
36
36
  PLATFORMS
37
37
  x86_64-darwin-19
38
+ x86_64-linux
38
39
 
39
40
  DEPENDENCIES
40
41
  byebug
@@ -16,7 +16,7 @@ class MyCLI
16
16
  return puts help if no_api_key?
17
17
  return puts invalid_uri if invalid_uri?(args)
18
18
 
19
- OmbuLabs::Shortener::RebrandlyClient.new(args).shorten
19
+ OmbuLabs::Shortener::RebrandlyClient.new(args.first).shorten
20
20
  end
21
21
 
22
22
  def self.help
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmbuLabs
4
4
  module Shortener
5
- VERSION = "0.1.1"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -6,22 +6,43 @@ require_relative "shortener/version"
6
6
  module OmbuLabs
7
7
  module Shortener
8
8
  class RebrandlyClient
9
- def initialize(args = [])
10
- @url = args.first
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.1.1
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-08-24 00:00:00.000000000 Z
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.21
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: []