reddit_get 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10171c0f2446ba66686862c922b20a8bcd9212f15c3134e0af72652fa4e6f0dd
4
- data.tar.gz: 61563a46f484e8dc9125febbb68c8e988774506b6037beb784c54e686c42dbed
3
+ metadata.gz: 057a04b80205a58ed0ee9e2407a54bee883af1fbd33121038c7f7722c558f26c
4
+ data.tar.gz: 926ba4df4ba2e52ec5eb3d387d846737a8eadf00a48f48d56101ba89a5117b28
5
5
  SHA512:
6
- metadata.gz: 602c9bdd9377205c787d6c573ac27d14781b30c1505fc5ac2beabde6a607fb27c7274745ee958567612c2413bc231c20dbd9f7b352117f4615be375baa73d17a
7
- data.tar.gz: e32b9aeeb505c44f0d1573e0cdf33748cb0c203216a51a87e6fc006d82fd7503c0f398c9356a44914b357b8729381d57b92d78dfbb85893b54f844f4d8df19fe
6
+ metadata.gz: d45b5bb70c460b87f2b5c448db61aa71e4f1ce33b9af3e0e27fe9c262b3a206e4c78225166da6ee2e9207ed820aedcd7a6edb651d39db3ddceac972ed0b31fbd
7
+ data.tar.gz: 9117c60faa7302e55275b327a81877f68b74f52231e77fa3dac2ab5a3e33733e177cd4459d68854fd260c4c8ea1f60b907f47316efffe3dee7a7416015619b21
data/Gemfile.lock CHANGED
@@ -8,12 +8,12 @@ GEM
8
8
  specs:
9
9
  ast (2.4.2)
10
10
  parallel (1.20.1)
11
- parser (3.0.0.0)
11
+ parser (3.0.1.0)
12
12
  ast (~> 2.4.1)
13
13
  rainbow (3.0.0)
14
- regexp_parser (2.0.3)
15
- rexml (3.2.4)
16
- rubocop (1.9.1)
14
+ regexp_parser (2.1.1)
15
+ rexml (3.2.5)
16
+ rubocop (1.13.0)
17
17
  parallel (~> 1.10)
18
18
  parser (>= 3.0.0.0)
19
19
  rainbow (>= 2.2.2, < 4.0)
data/README.md CHANGED
@@ -4,6 +4,7 @@ This gem allows you to grab posts and comments from Reddit without any auth.
4
4
  It concurrently grabs multiple subbreddits at a time to utilize your machine as much as possible and increase throughput.
5
5
 
6
6
  No setup and a clean interface makes this gem ideal when you just want to process public reddit data.
7
+
7
8
  Zero dependencies.
8
9
 
9
10
  The [Redd gem](https://github.com/avinashbot/redd) seems to be abandoned so I created this gem to meet my needs.
@@ -28,29 +29,29 @@ Or install it yourself as:
28
29
  ```ruby
29
30
  results = RedditGet::Subreddit.collect_all %w[gaming videos movies funny]
30
31
  results # will hold RedditGet::Data which acts like a hash
31
- results['gaming'].each do |post|
32
+ results.gaming.each do |post|
32
33
  puts post['title']
33
34
  end
34
- results.gaming
35
35
  ```
36
36
 
37
37
  ### You want to grab one subreddit
38
38
  ```ruby
39
39
  result = RedditGet::Subreddit.collect('gaming')
40
40
 
41
- results.gaming.each do |post|
41
+ result.gaming.each do |post|
42
42
  puts post.title # all gaming posts titles
43
- end
44
- results['gaming'] # works too!
43
+ end
44
+ result['gaming'] # works too!
45
45
  ```
46
46
 
47
- ## You want to grab comments for each post
47
+ ### You want to grab comments as well
48
+ Note: This grabs X subreddits M posts and N comments per post. So it is making X\*M\*N HTTP requests.
48
49
  ```ruby
49
50
  results = RedditGet::Subreddit.collect_all %w[gaming videos movies funny], with_comments: true
50
51
  results.gaming.each do |post|
51
52
  puts post.title
52
53
  post.comments.each do |comment|
53
- puts comment.body
54
+ puts comment.body rescue nil
54
55
  end
55
56
  end
56
57
 
data/lib/reddit_get.rb CHANGED
@@ -58,7 +58,7 @@ module RedditGet
58
58
  def self.collect_all(subreddits, with_comments: false)
59
59
  raise TypeError, 'Must pass an array of subreddits' unless subreddits.is_a?(Array)
60
60
 
61
- results = Hash[subreddits.zip([])]
61
+ results = subreddits.zip([]).to_h
62
62
  subreddits.uniq.each do |subreddit|
63
63
  grab_posts(results, subreddit, with_comments: with_comments)
64
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RedditGet
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddit_get
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
  - Alessandro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-13 00:00:00.000000000 Z
11
+ date: 2021-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop