url_fetcher 1.1.2 → 1.1.3

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
  SHA1:
3
- metadata.gz: dc714df3af393f211fd3e12077866febbf042207
4
- data.tar.gz: ba8d4c2950a2e578337f9b39e816c16638078bf1
3
+ metadata.gz: d402920ce67afd407a5fbf92187b5e76ec3ae8c9
4
+ data.tar.gz: a5493b15b2fa71c9f8be671c17098eebd4a02554
5
5
  SHA512:
6
- metadata.gz: 3c6ab837a920bf0e01b637e07c2e8b08ae35db374649e1d0743afdd2e82981eb1c2b300c31e6cec6e9bc53197d9d49a853de366e40a1c19a23152b995c2bcdfe
7
- data.tar.gz: 1edfda68b43d76138e98d37ea4715077f374c95f042f025706181f60e0b250ac3932b3936b9c7262e7281c16cfa9929c423e9e138375eb69db26f0575d665923
6
+ metadata.gz: aa95ce46a2425e428d3dca7f8f9204e5a0e2c5c773f34860485af92356ca6a3260287798322dde569b019715088145477a0fa81a0f20b30d68acfdf5d0338564
7
+ data.tar.gz: 73b1c388e02dcd0298e03512c69c49661793ed2d3992aa15191e1c9e772421552e05e01faf78d8c09ea0a3754b46096c8853bd231856e34649425f27a7325249
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
data/lib/url_fetcher.rb CHANGED
@@ -11,7 +11,7 @@ class UrlFetcher
11
11
  MEGABYTE = 1048576
12
12
  MAX_ATTEMPTS = 5.freeze
13
13
 
14
- attr_reader :url
14
+ attr_reader :url, :resolved_url
15
15
 
16
16
  # Create a fetcher for the specified URL.
17
17
  #
@@ -74,6 +74,7 @@ class UrlFetcher
74
74
 
75
75
  previous_attempts << url
76
76
  uri = URI(url)
77
+ @resolved_url = uri.to_s
77
78
 
78
79
  http = Net::HTTP.new(uri.host, uri.port)
79
80
  http.read_timeout = options[:read_timeout] || 20 # This is seconds. Default is 60.
@@ -14,6 +14,7 @@ describe UrlFetcher do
14
14
  url_fetcher.close
15
15
  expect(url_fetcher).to be_closed
16
16
  expect(url_fetcher.body).to be_closed
17
+ expect(url_fetcher.resolved_url).to eq("http://example.com/test")
17
18
  end
18
19
 
19
20
  it "should perform a POST request" do
@@ -47,19 +48,19 @@ describe UrlFetcher do
47
48
  WebMock.stub_request(:get, "http://example.com/test1").to_return(:status => 301, :headers => {"Location" => "http://example.com/test2"})
48
49
  WebMock.stub_request(:get, "http://example.com/test2").to_return(:status => 200, :body => "Hello", :headers => {"Content-Length" => 5})
49
50
  url_fetcher = UrlFetcher.new("http://example.com/test1")
50
-
51
51
  expect(url_fetcher).to be_success
52
52
  expect(url_fetcher).not_to be_redirect
53
53
  expect(url_fetcher.header("content-length")).to eql("5")
54
54
  expect(url_fetcher.body.read).to eql("Hello")
55
+ expect(url_fetcher.resolved_url).to eq("http://example.com/test2")
55
56
  end
56
57
 
57
58
  it "should not honor redirects if :follow_redirects == false" do
58
59
  WebMock.stub_request(:get, "http://example.com/test1").to_return(:status => 301, :headers => {"Location" => "http://example.com/test2"})
59
60
  url_fetcher = UrlFetcher.new("http://example.com/test1", :follow_redirects => false)
60
-
61
61
  expect(url_fetcher).not_to be_success
62
62
  expect(url_fetcher).to be_redirect
63
+ expect(url_fetcher.resolved_url).to eq("http://example.com/test1")
63
64
  end
64
65
 
65
66
  it "should call a block before each redirect with the new location" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_fetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - weheartit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-14 00:00:00.000000000 Z
11
+ date: 2015-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable