embiggen 1.5.0 → 1.7.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: b038ceb25cecb37ad16def4b35e4a4b3387df36056a4d3388b473b7282371dc2
4
- data.tar.gz: c9d57f7c5904f13ba6d7b4ed2eeb1edfc5e88c2c6ea17d5e758fe054c804bc2b
3
+ metadata.gz: 69f8ac1c0eb0aef13e8eeba8fc0f221c585ff3320f63dfe2435705313ad9e8c5
4
+ data.tar.gz: 448daaffc9709b857ba9800ac9f04011abde20410750895fc13fb9cfac12d453
5
5
  SHA512:
6
- metadata.gz: 19b0f8551a389fecc9fb31bf4053eed73805dc1ceba688b9c3c5b442bba2a613d8a2999576a1550292c2fc32ab55488db79a1db55d1fa2e6b6f04d97bc8ce2d7
7
- data.tar.gz: 3f85016ac86cf629b56f78c0975ba22f5a038ae861f39fca5db1b7bcbd044b1595f6e7321b91130e2ce74a3f8d28f697af97fedfe76f13c9dcd24a1e015a7d9f
6
+ metadata.gz: 0b11c31be2eb16103312bc0c69d397145001cabab566b43cca9f287cd11b3cff446f964743088867f140ed679753011373fd50d17297a2959a7de1e220ca4f32
7
+ data.tar.gz: ca096318601a7b30dbb6a0a29d0555071e0b910debbd96a943f0712342e3f77be49870add459b4d4e4ceb05b6c5c122f33330c9ba87383b9b323381af696a6d3
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2018 Altmetric LLP
3
+ Copyright (c) 2015-2024 Altmetric LLP
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
  A Ruby library to expand shortened URLs.
4
4
 
5
- **Current version:** 1.5.0
6
- **Supported Ruby versions:** 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2
5
+ **Current version:** 1.7.0
6
+ **Supported Ruby versions:** >= 2.7
7
7
 
8
8
  ## Installation
9
9
 
10
10
  ```
11
- gem install embiggen -v '~> 1.5'
11
+ gem install embiggen -v '~> 1.7'
12
12
  ```
13
13
 
14
14
  Or, in your `Gemfile`:
15
15
 
16
16
  ```ruby
17
- gem 'embiggen', '~> 1.5'
17
+ gem 'embiggen', '~> 1.7'
18
18
  ```
19
19
 
20
20
  ## Usage
@@ -203,11 +203,12 @@ Override the following settings:
203
203
  * [Bit.do's](http://bit.do/list-of-url-shorteners.php) curated list
204
204
  * [Hongkiat's](http://www.hongkiat.com/blog/url-shortening-services-the-ultimate-list/)
205
205
  curated list
206
+ * [PeterDaveHello's](https://github.com/PeterDaveHello/url-shorteners) curated list
206
207
  * A list of branded [Bitly](https://bitly.com/) domains collected by Altmetric
207
208
 
208
209
  ## License
209
210
 
210
- Copyright © 2015-2018 Altmetric LLP
211
+ Copyright © 2015-2024 Altmetric LLP
211
212
 
212
213
  Distributed under the MIT License.
213
214
 
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require 'set'
3
2
  require 'embiggen/shortener_list'
4
3
 
5
4
  module Embiggen
@@ -22,7 +21,7 @@ module Embiggen
22
21
  end
23
22
 
24
23
  def self.shorteners_from_file
25
- file_path = File.expand_path('../../../shorteners.txt', __FILE__)
24
+ file_path = File.expand_path('../../shorteners.txt', __dir__)
26
25
  File.readlines(file_path).map(&:chomp)
27
26
  end
28
27
  end
@@ -22,9 +22,14 @@ module Embiggen
22
22
  return unless response.is_a?(::Net::HTTPRedirection)
23
23
 
24
24
  response.fetch('Location')
25
- rescue StandardError, ::Timeout::Error => e
25
+ rescue ::Timeout::Error => e
26
26
  raise NetworkError.new(
27
- "could not follow #{uri}: #{e.message}", uri)
27
+ "Timeout::Error: could not follow #{uri}: #{e.message}", uri
28
+ )
29
+ rescue StandardError => e
30
+ raise NetworkError.new(
31
+ "StandardError: could not follow #{uri}: #{e.message}", uri
32
+ )
28
33
  end
29
34
 
30
35
  private
@@ -1,5 +1,4 @@
1
1
  require 'forwardable'
2
- require 'set'
3
2
 
4
3
  module Embiggen
5
4
  class ShortenerList
data/lib/embiggen/uri.rb CHANGED
@@ -19,8 +19,8 @@ module Embiggen
19
19
  redirects = extract_redirects(request_options)
20
20
  location = follow(request_options)
21
21
 
22
- self.class.new(location).
23
- expand(request_options.merge(:redirects => redirects - 1))
22
+ self.class.new(location)
23
+ .expand(request_options.merge(redirects: redirects - 1))
24
24
  end
25
25
 
26
26
  def shortened?
@@ -31,8 +31,11 @@ module Embiggen
31
31
 
32
32
  def extract_redirects(request_options = {})
33
33
  redirects = request_options.fetch(:redirects) { Configuration.redirects }
34
- fail TooManyRedirects.new(
35
- "following #{uri} reached the redirect limit", uri) if redirects.zero?
34
+ if redirects.zero?
35
+ fail TooManyRedirects.new(
36
+ "following #{uri} reached the redirect limit", uri
37
+ )
38
+ end
36
39
 
37
40
  redirects
38
41
  end
@@ -41,8 +44,11 @@ module Embiggen
41
44
  timeout = request_options.fetch(:timeout) { Configuration.timeout }
42
45
 
43
46
  location = http_client.follow(timeout)
44
- fail BadShortenedURI.new(
45
- "following #{uri} did not redirect", uri) unless followable?(location)
47
+ unless followable?(location)
48
+ fail BadShortenedURI.new(
49
+ "following #{uri} did not redirect", uri
50
+ )
51
+ end
46
52
 
47
53
  location
48
54
  end
@@ -53,7 +59,8 @@ module Embiggen
53
59
  Addressable::URI.parse(location).absolute?
54
60
  rescue Addressable::URI::InvalidURIError => e
55
61
  raise BadShortenedURI.new(
56
- "following #{uri} returns an invalid URI: #{e}", uri)
62
+ "following #{uri} returns an invalid URI: #{e}", uri
63
+ )
57
64
  end
58
65
  end
59
66
  end
data/lib/embiggen.rb CHANGED
@@ -2,7 +2,7 @@ require 'embiggen/configuration'
2
2
  require 'embiggen/uri'
3
3
 
4
4
  module Embiggen
5
- def URI(uri)
5
+ def URI(uri) # rubocop:disable Naming/MethodName
6
6
  uri.is_a?(URI) ? uri : URI.new(uri)
7
7
  end
8
8
 
@@ -10,5 +10,6 @@ module Embiggen
10
10
  yield(Configuration)
11
11
  end
12
12
 
13
- module_function :URI, :configure
13
+ module_function :URI
14
+ module_function :configure
14
15
  end