richurls 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db4d6b2a40debb931cb10f2ff022d85743502f486b316f1046837a28d99275c4
4
- data.tar.gz: 7ab58ccab0303530fe78c23d33f8e9b58c27131f41267df2428e7a1a4ab1ca18
3
+ metadata.gz: ffe4a9521f5ba179be0019c5e21f5d2c72fed6996e00256fef275d6234874370
4
+ data.tar.gz: c65e5d58fd91158a19273b3f12470e4cd781d8e67726a229b654efba74904ef4
5
5
  SHA512:
6
- metadata.gz: e45af9667708ee4e787dba1b01da0a341557eac3c76f7ad2cea685282de862b6fdcb6e178365064514ced571bd79133205a393416e27d8eb71cd9bbb010741fb
7
- data.tar.gz: fbc11283743e3198bb60469d7c592aac515134f18ce13937b9d804b8fb12ecde82e2dc81224ae81af1933fbc6ab7e402a66a02d07a2f084d6e4364d562785818
6
+ metadata.gz: b594e90b8c1b184ccc63ef0f209965f7dbb031eaec4f6e58430547bd673989417d5db6f339b1d7ef193432b193727e3d3b1ecf9b82e18a8c6b2818008b80b112
7
+ data.tar.gz: 9c6e6b80db7bc47ae3a368bede001b0903171314bd61d852cd30c0f66dd3fc8cb2804ad3c2684db89a39f8e14e8445833f1eed6ff7891795ac3922c084aa00ba
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- richurls (0.5.6)
4
+ richurls (0.5.7)
5
5
  addressable (~> 2)
6
6
  oj (~> 3)
7
7
  ox (~> 2)
@@ -14,16 +14,15 @@ GEM
14
14
  public_suffix (>= 2.0.2, < 5.0)
15
15
  ast (2.4.0)
16
16
  diff-lcs (1.3)
17
- jaro_winkler (1.5.4)
18
17
  oj (3.10.6)
19
18
  ox (2.13.2)
20
19
  parallel (1.19.1)
21
- parser (2.7.1.1)
20
+ parser (2.7.1.2)
22
21
  ast (~> 2.4.0)
23
22
  patron (0.13.3)
24
23
  public_suffix (4.0.5)
25
24
  rainbow (3.0.0)
26
- redis (4.1.4)
25
+ redis (4.2.1)
27
26
  rexml (3.2.4)
28
27
  rspec (3.9.0)
29
28
  rspec-core (~> 3.9.0)
@@ -38,8 +37,7 @@ GEM
38
37
  diff-lcs (>= 1.2.0, < 2.0)
39
38
  rspec-support (~> 3.9.0)
40
39
  rspec-support (3.9.2)
41
- rubocop (0.82.0)
42
- jaro_winkler (~> 1.5.1)
40
+ rubocop (0.83.0)
43
41
  parallel (~> 1.10)
44
42
  parser (>= 2.7.0.1)
45
43
  rainbow (>= 2.2.2, < 4.0)
@@ -7,6 +7,7 @@ require_relative 'url_fetcher'
7
7
  require_relative 'body_decorator'
8
8
 
9
9
  module RichUrls
10
+ DEFAULT_USER_AGENT = 'richurls'.freeze
10
11
  class MalformedURLError < StandardError; end
11
12
 
12
13
  def self.cache
@@ -22,6 +23,14 @@ module RichUrls
22
23
  @cache ||= wrapper
23
24
  end
24
25
 
26
+ def self.user_agent=(user_agent)
27
+ @user_agent ||= user_agent
28
+ end
29
+
30
+ def self.user_agent
31
+ @user_agent || DEFAULT_USER_AGENT
32
+ end
33
+
25
34
  def self.enrich(url, filter: [], cache_time: nil)
26
35
  unless URI::DEFAULT_PARSER.make_regexp.match?(url)
27
36
  raise MalformedURLError, "this url is malformed: #{url}"
@@ -36,7 +36,13 @@ module RichUrls
36
36
  end
37
37
 
38
38
  def patron_call
39
- session = Patron::Session.new(timeout: DEFAULT_TIMEOUT)
39
+ session = Patron::Session.new(
40
+ timeout: DEFAULT_TIMEOUT,
41
+ headers: {
42
+ 'User-Agent' => RichUrls.user_agent
43
+ }
44
+ )
45
+
40
46
  response = session.get(@url)
41
47
 
42
48
  if response.status < 400
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'richurls'
6
- spec.version = '0.5.6'
6
+ spec.version = '0.5.7'
7
7
  spec.authors = ['grdw']
8
8
  spec.email = ['gerard@wetransfer.com']
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: richurls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - grdw
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-11 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -165,7 +165,7 @@ metadata:
165
165
  homepage_uri: https://github.com/wetransfer/richurls
166
166
  source_code_uri: https://github.com/wetransfer/richurls
167
167
  changelog_uri: https://github.com/wetransfer/richurls/CHANGELOG.md
168
- post_install_message:
168
+ post_install_message:
169
169
  rdoc_options: []
170
170
  require_paths:
171
171
  - lib
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubygems_version: 3.1.2
184
- signing_key:
184
+ signing_key:
185
185
  specification_version: 4
186
186
  summary: Service which enriches URLs
187
187
  test_files: []