fb_scrape 0.0.5 → 0.0.6

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: 6c8ee7a39b2206dd1a81a1a5cb63bad79576d62d
4
- data.tar.gz: 6007835efa4e40368fa8cbcf210ea9209e837218
3
+ metadata.gz: d1a9ddf896ea4be8199af9719cad12ac839bcdea
4
+ data.tar.gz: 27174503c585c683b16a91afa8a7e85b9261b994
5
5
  SHA512:
6
- metadata.gz: be7eb5fc04239dba07944d6a21a9697896ace34336ad51a62675bc8b89037da7d2a2e12c26b8213c27a787604cacb092030486368f02179fd5102afca976be2a
7
- data.tar.gz: 854edabfbc131bce88a1d87d9aa2358100b253b703f0eca483e54491ceec3df76cba2893f093a1fcf5069e39b678926ad06552f685cf3baa77ce09a6d44b8b57
6
+ metadata.gz: 511e6752cf92cff996cf2592223696cdd9a165ffb109ab54728bb9c43840de695a242ae60c970f042f0fde09fdd2260e88001f0d7717c0008463b137bbfa8a21
7
+ data.tar.gz: 9bec19ff984f8641fe08ee04826136be28e69648a7b0d0c9583581e5346ee4b55bebe72f0c93350a23834bc260411aefa4fe306ed2908dc221e832e321cafdde
@@ -25,8 +25,8 @@ class FBScrape::Comment
25
25
  @page_info && next_cursor
26
26
  end
27
27
 
28
- def load_all_replies
29
- while has_more_replies? do
28
+ def load_all_replies(limit=nil)
29
+ while has_more_replies? && is_below_limit?(limit) do
30
30
  load_more_replies
31
31
  end
32
32
  end
@@ -44,6 +44,11 @@ class FBScrape::Comment
44
44
 
45
45
  private
46
46
 
47
+ def is_below_limit?(limit)
48
+ is_below_limit = limit.nil? || @replies.length < limit
49
+ end
50
+
51
+
47
52
  def next_cursor
48
53
  @page_info["cursors"]["next"]
49
54
  end
@@ -29,12 +29,14 @@ class FBScrape::Post
29
29
  @page_info && next_cursor
30
30
  end
31
31
 
32
- def load_all_comments
33
- while has_more_comments? do
32
+ def load_all_comments(limit=nil)
33
+ while has_more_comments? && is_below_limit?(limit) do
34
34
  load_more_comments
35
35
  end
36
36
  end
37
37
 
38
+
39
+
38
40
  def to_json(*args)
39
41
  JSON.pretty_generate({
40
42
  id: @id,
@@ -47,6 +49,10 @@ class FBScrape::Post
47
49
 
48
50
  private
49
51
 
52
+ def is_below_limit?(limit)
53
+ is_below_limit = limit.nil? || @comments.length < limit
54
+ end
55
+
50
56
  def load_from_url url
51
57
  resp = HTTParty.get(url)
52
58
  case resp.code
@@ -1,3 +1,3 @@
1
1
  module FBScrape
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_scrape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Kimenye
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-15 00:00:00.000000000 Z
11
+ date: 2017-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler