ombu_labs-shortener 0.1.0 → 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: 1204f8c8cade58cf124ee8528dd9be55034d233fc94c506d3d5932448c24a418
4
- data.tar.gz: cd291bb6f406cb733db5a7d136fef4cfb63e27fc923d95cd00f0d71ac8b8a6c0
3
+ metadata.gz: 1b41c6ce007788b2e45ca15b194d133f2be197becb6ff1155f0936b2607ac4ef
4
+ data.tar.gz: c756cd79bca5d925b465c327581fcefa09f329fe4e4b3bfe9a074a79f67d9c38
5
5
  SHA512:
6
- metadata.gz: ded6eb19cf5bfcd4770f00347834c75fd6d4dc96c513c5b255abc0403f468925f0758d4aef1a9c34fc2802bb17b569665464b4f58a0930b08884f33cf6b7919c
7
- data.tar.gz: d60dc6c94e5684bab2ec2ce506e5b8178287547d334100e0315210de98d8695fe098290fea1e2a1464019bfbcb40d943d2d345d5ff358ec715edae4f93ba0e9a
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
- ombulabs-shortener (0.1.0)
4
+ ombu_labs-shortener (0.1.1)
5
5
  rebrandly
6
6
 
7
7
  GEM
@@ -35,10 +35,11 @@ GEM
35
35
 
36
36
  PLATFORMS
37
37
  x86_64-darwin-19
38
+ x86_64-linux
38
39
 
39
40
  DEPENDENCIES
40
41
  byebug
41
- ombulabs-shortener!
42
+ ombu_labs-shortener!
42
43
  rake (~> 13.0)
43
44
  rspec (~> 3.0)
44
45
 
data/README.md CHANGED
@@ -1,22 +1,31 @@
1
1
  # OmbuLabs::Shortener
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ombu_labs/shortener`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A short script to shorten links for these domains:
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ - https://fastruby.io
6
+ - https://ombulabs.com
6
7
 
7
8
  ## Installation
8
9
 
9
- Install the gem and add to the application's Gemfile by executing:
10
+ Install the gem:
10
11
 
11
- $ bundle add ombulabs-shortener
12
+ gem install ombu_labs-shortener
12
13
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
14
+ ## Usage
14
15
 
15
- $ gem install ombulabs-shortener
16
+ You will need to set up your API key in your environment:
16
17
 
17
- ## Usage
18
+ ```
19
+ export REBRANDLY_API_KEY=<your api key>
20
+ ```
21
+
22
+ Then you can just call the `shorten` command:
18
23
 
19
- TODO: Write usage instructions here
24
+ ```
25
+ shorten https://www.ombulabs.com\?utm_source\=pepe
26
+ Shortening: https://www.ombulabs.com?utm_source=pepe
27
+ Shortened: SHORT: go.ombulabs.com/oxh
28
+ ```
20
29
 
21
30
  ## Development
22
31
 
@@ -26,7 +35,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
26
35
 
27
36
  ## Contributing
28
37
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ombulabs-shortener. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ombulabs-shortener/blob/master/CODE_OF_CONDUCT.md).
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fastruby/ombulabs-shortener. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/fastruby/ombulabs-shortener/blob/master/CODE_OF_CONDUCT.md).
30
39
 
31
40
  ## License
32
41
 
@@ -34,4 +43,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
34
43
 
35
44
  ## Code of Conduct
36
45
 
37
- Everyone interacting in the Ombulabs::Shortener project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ombulabs-shortener/blob/master/CODE_OF_CONDUCT.md).
46
+ Everyone interacting in the OmbuLabs::Shortener project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fastruby/ombulabs-shortener/blob/master/CODE_OF_CONDUCT.md).
@@ -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.0"
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
- puts "Shortened: SHORT: #{link.short_url}"
22
-
23
- rescue Rebrandly::RebrandlyError => err
24
- puts "Error: #{err.message}"
44
+ puts "Shortened: SHORT: https://#{link.short_url}"
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.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-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: []