shorturl_at 0.1.0 → 1.0.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: 1856f80f28f765a58e6821c9462cb2e0b2225fdec44ec075733b66d3ce4e21ee
4
- data.tar.gz: 854adc01cac4b1fbd58a8b403b37e0ef6498786d49fa314a8e61a53ff17803a2
3
+ metadata.gz: 02e0676b02cb0efe74e8fcca952568ccfee00d254154f7a2c2445124b5780778
4
+ data.tar.gz: 27f5671b81acb6cc6e04099bbd073ff3d04935a71734590191b36f557c5cac8c
5
5
  SHA512:
6
- metadata.gz: 7ec04fc7cc9b1ea8a173d8ee5f9a9f881b301a9d5325590eb59f1bda2973fe2332af667a403e7389c6464d5c6e321a27430100b791eaaf6bc3622e09f7a557f8
7
- data.tar.gz: 6427a02a6b7f07ce3ccac416e820147de3f8e528c4c77c4d7ff0508ef5d56950011b83b7687f9b58f2835a3bf48580ce649b5b7fa2ae872185140ea8ec4f385a
6
+ metadata.gz: 3113724e1eeafe087fd611b755a28a1b93f8c5fed7298d0f751533176fd7365ab2fc9860a893383b0ef5d88daa6c48d3336311170d37b309fa7f0f6531ada165
7
+ data.tar.gz: e5c85b044e6dcdb946c88d4b3793995ca9dcdcff7f80cc8ae4b183d2d23fbd423d9eb0d9a2af8a6f3dd20abfa0896b8cae3c88cb39a2c087d0a0e17816abbafe
data/.gitignore CHANGED
@@ -7,5 +7,8 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ # Gemfile
11
+ Gemfile.lock
12
+
10
13
  # rspec failure tracking
11
14
  .rspec_status
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # ShorturlAt
2
2
 
3
- A simple Ruby gem that uses the URL shortener service at https://www.shorturl.at/
3
+ A simple Ruby gem that uses the URL shortener service.
4
+ Supports the following services:
5
+
6
+ 1. shorturl.at (default)
7
+ 2. tinyurl.com ('tinyurl')
4
8
 
5
9
  ## Installation
6
10
 
@@ -20,8 +24,10 @@ Or install it yourself as:
20
24
 
21
25
  ## Usage
22
26
 
23
- ```
24
- ShorturlAt.shorten("http://your.long.url/to/shorten")
27
+ ```ruby
28
+ ShorturlAt.shorten("http://your.long.url/to/shorten") # will return ~ http://shorturl.at/xxYYnn
29
+
30
+ ShorturlAt.shorten("http://another.long.url/to/shorten") # will return ~ https://tinyurl.com/zznnXX
25
31
  ```
26
32
 
27
33
  ## Development
data/lib/shorturl_at.rb CHANGED
@@ -5,22 +5,43 @@ require "nokogiri"
5
5
  module ShorturlAt
6
6
 
7
7
  SHORTEN_URL = 'https://www.shorturl.at/shortener.php'
8
+ TINY_URL = 'https://tinyurl.com/create.php'
8
9
 
9
10
  class Error < StandardError; end
10
11
 
11
12
  class << self
12
13
  attr_accessor :long_url
13
14
 
14
- def shorten(long_url)
15
- response = HTTP.post(SHORTEN_URL, :form => {:u => long_url})
16
- if response.status.success?
17
- doc = Nokogiri::HTML(response.body.to_s)
18
- short_url = doc.at('input#shortenurl')['value']
19
- short_url = "http://#{short_url}"
15
+ def shorten(long_url, method='')
16
+ case method
17
+ when 'tinyurl'
18
+ shorten_tiny_url(long_url)
19
+ when 'rebrandly'
20
+ shorten_rebrandly
21
+ else
22
+ response = HTTP.post(SHORTEN_URL, :form => {:u => long_url})
23
+ if response.status.success?
24
+ doc = Nokogiri::HTML(response.body.to_s)
25
+ short_url = doc.at('input#shortenurl')['value']
26
+ short_url = "http://#{short_url}"
27
+ end
28
+ short_url
20
29
  end
30
+ end
21
31
 
22
- short_url
32
+ def shorten_tiny_url(long_url)
33
+ response = HTTP.post(TINY_URL, :form => {:url => long_url})
34
+ if response.status.success?
35
+ doc = Nokogiri::HTML(response.body.to_s)
36
+ short_url = doc.at('a#copy_div')['href']
37
+ end
38
+ short_url
23
39
  end
24
40
 
41
+ def shorten_rebrandly(long_url)
42
+
43
+ end
44
+
45
+
25
46
  end
26
47
  end
@@ -1,3 +1,3 @@
1
1
  module ShorturlAt
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/shorturl_at.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Marlon Santos"]
9
9
  spec.email = ["marlonsantos.au@gmail.com"]
10
10
 
11
- spec.summary = %q{A simple long URL shortener that uses http://www.shorturl.at/ service.}
12
- spec.description = %q{Shorten your URLs with this simple url shortener built with Ruby.}
11
+ spec.summary = %q{A simple long URL shortener.}
12
+ spec.description = %q{Shorten your URLs with this simple url shortener written in Ruby.}
13
13
  spec.homepage = "http://github.com/matr1xp/shorturl_at"
14
14
  spec.license = "MIT"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shorturl_at
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marlon Santos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-05 00:00:00.000000000 Z
11
+ date: 2019-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.10'
83
- description: Shorten your URLs with this simple url shortener built with Ruby.
83
+ description: Shorten your URLs with this simple url shortener written in Ruby.
84
84
  email:
85
85
  - marlonsantos.au@gmail.com
86
86
  executables: []
@@ -92,7 +92,6 @@ files:
92
92
  - ".travis.yml"
93
93
  - CODE_OF_CONDUCT.md
94
94
  - Gemfile
95
- - Gemfile.lock
96
95
  - LICENSE.txt
97
96
  - README.md
98
97
  - Rakefile
@@ -126,5 +125,5 @@ requirements: []
126
125
  rubygems_version: 3.0.6
127
126
  signing_key:
128
127
  specification_version: 4
129
- summary: A simple long URL shortener that uses http://www.shorturl.at/ service.
128
+ summary: A simple long URL shortener.
130
129
  test_files: []
data/Gemfile.lock DELETED
@@ -1,62 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- shorturl_at (0.1.0)
5
- http (~> 4.2)
6
- nokogiri (~> 1.10)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.7.0)
12
- public_suffix (>= 2.0.2, < 5.0)
13
- diff-lcs (1.3)
14
- domain_name (0.5.20190701)
15
- unf (>= 0.0.5, < 1.0.0)
16
- ffi (1.11.3)
17
- ffi-compiler (1.0.1)
18
- ffi (>= 1.0.0)
19
- rake
20
- http (4.2.0)
21
- addressable (~> 2.3)
22
- http-cookie (~> 1.0)
23
- http-form_data (~> 2.0)
24
- http-parser (~> 1.2.0)
25
- http-cookie (1.0.3)
26
- domain_name (~> 0.5)
27
- http-form_data (2.1.1)
28
- http-parser (1.2.1)
29
- ffi-compiler (>= 1.0, < 2.0)
30
- mini_portile2 (2.4.0)
31
- nokogiri (1.10.7)
32
- mini_portile2 (~> 2.4.0)
33
- public_suffix (4.0.1)
34
- rake (10.5.0)
35
- rspec (3.9.0)
36
- rspec-core (~> 3.9.0)
37
- rspec-expectations (~> 3.9.0)
38
- rspec-mocks (~> 3.9.0)
39
- rspec-core (3.9.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-expectations (3.9.0)
42
- diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-mocks (3.9.0)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.9.0)
47
- rspec-support (3.9.0)
48
- unf (0.1.4)
49
- unf_ext
50
- unf_ext (0.0.7.6)
51
-
52
- PLATFORMS
53
- ruby
54
-
55
- DEPENDENCIES
56
- bundler (~> 2.0)
57
- rake (~> 10.0)
58
- rspec (~> 3.0)
59
- shorturl_at!
60
-
61
- BUNDLED WITH
62
- 2.0.2