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 +4 -4
- data/Gemfile.lock +3 -2
- data/README.md +19 -10
- 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 +28 -7
- 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
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
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
|
-
|
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
|
-
|
3
|
+
A short script to shorten links for these domains:
|
4
4
|
|
5
|
-
|
5
|
+
- https://fastruby.io
|
6
|
+
- https://ombulabs.com
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
|
-
Install the gem
|
10
|
+
Install the gem:
|
10
11
|
|
11
|
-
|
12
|
+
gem install ombu_labs-shortener
|
12
13
|
|
13
|
-
|
14
|
+
## Usage
|
14
15
|
|
15
|
-
|
16
|
+
You will need to set up your API key in your environment:
|
16
17
|
|
17
|
-
|
18
|
+
```
|
19
|
+
export REBRANDLY_API_KEY=<your api key>
|
20
|
+
```
|
21
|
+
|
22
|
+
Then you can just call the `shorten` command:
|
18
23
|
|
19
|
-
|
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/
|
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
|
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).
|
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
|
-
puts "Shortened: SHORT:
|
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.
|
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: []
|