page_by_page 0.1.0 → 0.1.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: 1caf9eb5db3b666affd8d965eeda90581829cc0c
4
- data.tar.gz: 50d38d6016992599ca2e3338f922836cc9007160
3
+ metadata.gz: 5fa944dd4b26a3928521fab9ab0715912b5b41da
4
+ data.tar.gz: ec53a56c45380b0a95994ab056bbf1d0e33b2fc1
5
5
  SHA512:
6
- metadata.gz: 4ffc3556b738790cf827a69b185d827230f08a63558d3d417de62c609e916ad0f0f2d60437f22199e82b915356b662c4a1de072b31477ace04e1f6181db40bec
7
- data.tar.gz: c8ddaa7f047288edffdac0568de7ffe2aa60e964163adf9a9ebb8cc94130afb447886c22df2469e4043ca75e8450cfc3c3ec13e97a7bd3e442392007b422e5a5
6
+ metadata.gz: ea009729e29a8bd6922992d9afcddec3dfe5cf1dc9003cbae7bb24e1c1c2a8b4fddd521adf7f879d298a25431db18ae8f8fbf22bd6b382a90244ad385d298c5a
7
+ data.tar.gz: 254f829aa7fc8b08e280c00f0c640c96740893e6f8c564403a0b9b2d50f03465318739ecb383f650c71104adbbe3a2fdb6389832a28ed312f74479ee45771c40
data/lib/page_by_page.rb CHANGED
@@ -26,10 +26,12 @@ class PageByPage
26
26
 
27
27
  def fetch
28
28
  items, all_items = [nil], []
29
- until items.empty?
30
- doc = parse @url.next
31
- items = doc.css @selector
32
- all_items << items
29
+ catch :no_more do
30
+ until items.empty?
31
+ doc = parse @url.next
32
+ items = doc.css @selector
33
+ all_items << items
34
+ end
33
35
  end
34
36
  all_items.flatten
35
37
  end
@@ -38,6 +40,12 @@ class PageByPage
38
40
 
39
41
  def parse url
40
42
  Nokogiri::HTML open url
43
+ rescue OpenURI::HTTPError => e
44
+ if e.message == '404 Not Found'
45
+ throw :no_more
46
+ else
47
+ raise e
48
+ end
41
49
  end
42
50
 
43
51
  end
@@ -1,3 +1,3 @@
1
1
  class PageByPage
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_by_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken