page_by_page 0.1.8 → 0.1.9

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: e272639f27ba7c77e9c211f7189099dedade9d8f
4
- data.tar.gz: b4571013bb77691327b37fe8a646cf162469d394
3
+ metadata.gz: b7b7ac7eab723d81c77692420ccd3fd3e6a69d55
4
+ data.tar.gz: cfc4977c9d1e3f635e0bc0bded551eb29ee97195
5
5
  SHA512:
6
- metadata.gz: 12888cf1ddf115bfe0866339fc1c574176c757bfa13154a34d0c1c777c709c2ef083037018f08584a6550c14d9e22522a1cbed0e2dc7f981759af4c9bf28a9a9
7
- data.tar.gz: 53de9357b1c06ce217e92ff3619b45455280fe351b281e37450ad17b7041737985a187cace0305dda93a62d284dc588393ab4de9fb1aa43e575dc41894a4ff8b
6
+ metadata.gz: 1840cd52ed71ad5f21c9647a75a9a8630d5df17c6c731e16220d7b8c92361711fe2fdc8eefa2afa458dc106342c133f46c9fde0246e21d6cd0cb7fac279e7be9
7
+ data.tar.gz: c9625120e03c85610165c6f0b791a9f00ba9939c31c3097371bcd0a0756f62afab99001b976bfbb23beffec977eb3a3158afcffa3e3b383a2c7817c0a84748f1
data/README.md CHANGED
@@ -32,3 +32,16 @@ nodes = PageByPage.fetch do
32
32
  end
33
33
  ```
34
34
 
35
+ Or just passing parameters:
36
+
37
+ ```ruby
38
+ nodes = PageByPage.fetch(
39
+ url: 'https://book.douban.com/subject/25846075/comments/hot?p=<%= n %>',
40
+ selector: '.comment-item',
41
+ # from: 2,
42
+ # step: 2,
43
+ # to: 100,
44
+ # threads: 4,
45
+ # no_progress: true
46
+ )
47
+ ```
@@ -1,3 +1,3 @@
1
1
  class PageByPage
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
data/lib/page_by_page.rb CHANGED
@@ -8,16 +8,17 @@ require 'erb'
8
8
  class PageByPage
9
9
 
10
10
  class << self
11
- def fetch &block
12
- pbp = self.new &block
11
+ def fetch(opt ={}, &block)
12
+ pbp = self.new(opt, &block)
13
13
  pbp.fetch
14
14
  end
15
15
  end
16
16
 
17
- def initialize &block
17
+ def initialize(opt = {}, &block)
18
18
  @from, @step, @to = 1, 1, Float::INFINITY
19
19
  @progress = {}
20
- instance_eval &block
20
+ opt.each{ |name, value| send name, value }
21
+ instance_eval &block if block
21
22
  end
22
23
 
23
24
  def url tmpl
@@ -44,7 +45,7 @@ class PageByPage
44
45
  @threads = n
45
46
  end
46
47
 
47
- def no_progress
48
+ def no_progress *arg
48
49
  @progress = nil
49
50
  end
50
51
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_by_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-30 00:00:00.000000000 Z
11
+ date: 2017-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler