polipus 0.5.0 → 0.5.1

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: 0e3c15f4ab5c3b4eca8f4703b80d7d8fa74210c3
4
- data.tar.gz: ae0dd32d81bbcbef350949e0c51fecaaf59ac8ff
3
+ metadata.gz: ac053145ab327da9f8807deb635759ebb81019f1
4
+ data.tar.gz: 4b9cbdf6a33783f9443ebe07c3c424e887c348ee
5
5
  SHA512:
6
- metadata.gz: c3a57d1cbfbab4c77cf3b746c7b73eb84cf675e7998eb5979af6d17d997ee26781803e519eae50de6762590fc7287d09ccf4ac0d640dff40602b8a507a356de2
7
- data.tar.gz: 743b128ee0dd8fefbbdd1bd7443afbc4a2c62dd2f3d3751d3d693719e9a8e2e145668ccd58945b77f5f780f50757a11248df2b1963c8e7cc35706e937627e5e0
6
+ metadata.gz: faedd0cc2b0c085fcda3337ab52b06abb7fe9b07f51df3ecff4bedfdbd97c40df939a12e5cd52253e6006aa22862f6bb372957c9eeb2a01496089652163eeb02
7
+ data.tar.gz: c62335cefa15204d304407a2248b62faa2e29aa060bf4513e42a984cb04b32ce5f11df69025c9a9760c6c611ff976bdf78cf9e82f4b8a47d1c9927ab4afa90fc
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.1 (2015-07-17)
4
+
5
+ [Compare changes in gem](https://github.com/taganaka/polipus/compare/0.5.0...0.5.1)
6
+
7
+ * Propagate user_data values from Redis message to fetched pages
8
+
3
9
  ## 0.5.0 (2015-07-08)
4
10
 
5
11
  [Compare changes in gem](https://github.com/taganaka/polipus/compare/0.4.0...0.5.0)
@@ -200,7 +200,7 @@ module Polipus
200
200
 
201
201
  execute_plugin 'on_before_download'
202
202
 
203
- pages = http.fetch_pages(url, page.referer, page.depth)
203
+ pages = http.fetch_pages(url, page.referer, page.depth, page.user_data)
204
204
  if pages.count > 1
205
205
  rurls = pages.map { |e| e.url.to_s }.join(' --> ')
206
206
  @logger.info { "Got redirects! #{rurls}" }
@@ -35,37 +35,39 @@ module Polipus
35
35
  # Fetch a single Page from the response of an HTTP request to *url*.
36
36
  # Just gets the final destination page.
37
37
  #
38
- def fetch_page(url, referer = nil, depth = nil)
39
- fetch_pages(url, referer, depth).last
38
+ def fetch_page(url, referer = nil, depth = nil, user_data = nil)
39
+ fetch_pages(url, referer, depth, user_data).last
40
40
  end
41
41
 
42
42
  #
43
43
  # Create new Pages from the response of an HTTP request to *url*,
44
44
  # including redirects
45
45
  #
46
- def fetch_pages(url, referer = nil, depth = nil)
46
+ def fetch_pages(url, referer = nil, depth = nil, user_data = nil)
47
47
  url = URI(url)
48
48
  pages = []
49
49
  get(url, referer) do |response, code, location, redirect_to, response_time|
50
50
  handle_compression response
51
- pages << Page.new(location, body: response.body,
52
- code: code,
53
- headers: response.to_hash,
54
- referer: referer,
55
- depth: depth,
56
- redirect_to: redirect_to,
57
- response_time: response_time,
58
- fetched_at: Time.now.to_i)
51
+ page = Page.new(location, body: response.body,
52
+ code: code,
53
+ headers: response.to_hash,
54
+ referer: referer,
55
+ depth: depth,
56
+ redirect_to: redirect_to,
57
+ response_time: response_time,
58
+ fetched_at: Time.now.to_i)
59
+ page.user_data = user_data unless user_data.nil?
60
+ pages << page
59
61
  end
60
-
61
62
  pages
62
63
  rescue *RESCUABLE_ERRORS => e
63
64
  if verbose?
64
65
  puts e.inspect
65
66
  puts e.backtrace
66
67
  end
67
-
68
- [Page.new(url, error: e, referer: referer, depth: depth)]
68
+ page = Page.new(url, error: e, referer: referer, depth: depth)
69
+ page.user_data = user_data unless user_data.nil?
70
+ [page]
69
71
  end
70
72
 
71
73
  #
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
  module Polipus
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
  HOMEPAGE = 'https://github.com/taganaka/polipus'
5
5
  end
@@ -8,11 +8,15 @@ describe Polipus::HTTP do
8
8
  it 'should download a page' do
9
9
  VCR.use_cassette('http_test') do
10
10
  http = Polipus::HTTP.new
11
- page = http.fetch_page('http://sfbay.craigslist.org/apa/')
11
+ user_data = {
12
+ 'mydata' => 'myvalue'
13
+ }
14
+ page = http.fetch_page('http://sfbay.craigslist.org/apa/', '', 0, user_data)
12
15
  expect(page).to be_an_instance_of(Polipus::Page)
13
16
  expect(page.doc.search('title').text.strip).to eq 'SF bay area apts/housing for rent classifieds - craigslist'
14
17
  expect(page.fetched_at).not_to be_nil
15
18
  expect(page.fetched?).to be_truthy
19
+ expect(page.user_data).to eq user_data
16
20
  end
17
21
  end
18
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polipus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Laurita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -385,3 +385,4 @@ test_files:
385
385
  - spec/polipus/url_tracker_spec.rb
386
386
  - spec/polipus_spec.rb
387
387
  - spec/spec_helper.rb
388
+ has_rdoc: