redd 0.9.0.pre.1 → 0.9.0.pre.2

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
  SHA1:
3
- metadata.gz: 2390ae91194cc27f480a767e8d3c6aeaf8f4d649
4
- data.tar.gz: ff8f69a3280a4403094fb6f5836167a6810704df
3
+ metadata.gz: c5ff3c5e42a08a8f210131a46183225be92037b9
4
+ data.tar.gz: 8f85fe4a62585429fae41baad34db469a16f67e4
5
5
  SHA512:
6
- metadata.gz: 24cb20848f3d9c6b863b6b37f91b44380dca1eeacbfd1387568ee4b745e85e3e6e87c960a8cdd43e41a6ce821ab0a31fa68447629aa58d33656c86bce7959dfd
7
- data.tar.gz: d3ece323ea83e671ea7f618fad231a29fbf9ba50b5cb1fdf138f49636907280fe8b9b726c41fb10acdb07830f50253f56269a6b13d713149edba06cffe2d2f86
6
+ metadata.gz: b79d75476d5c42f61afc58faad3f634823cde21372545c08dfa087dac3ae2c4cbeda2e6f820acee12e49fd19b198256212537da3fdc71cb4f37a12ab8e9fb2b6
7
+ data.tar.gz: dbf251810dd76b1da875f3659bf95243dfdf1e60692bfa891c1dfa18c1c22a3e5959d28bf90066b457c68fcec9139092e7ee3f5857185a947065bc991772de78
@@ -69,15 +69,17 @@ module Redd
69
69
  # Go backward through the listing.
70
70
  # @yield [Object] the object returned in the listings
71
71
  def _stream(&block)
72
- reverse_each(&block) if @limit > 0
73
72
  buffer = RingBuffer.new(100)
73
+ remaining = @limit > 0 ? reverse_each.to_a : []
74
+
74
75
  loop do
75
- remaining = fetch_prev_listing
76
+ remaining.push(*fetch_prev_listing)
76
77
  remaining.reverse_each do |o|
77
- next if buffer.include?(o)
78
+ next if buffer.include?(o.id)
79
+ buffer.add(o.id)
78
80
  yield o
79
- buffer.add(o)
80
81
  end
82
+ remaining.clear
81
83
  end
82
84
  end
83
85
 
@@ -9,9 +9,19 @@ module Redd
9
9
  class Session < Model
10
10
  include Searchable
11
11
 
12
+ # @return [User] the logged-in user
13
+ def me
14
+ @me ||= Self.new(client)
15
+ end
16
+
17
+ # @return [FrontPage] the user's front page
18
+ def front_page
19
+ @front_page ||= FrontPage.new(client)
20
+ end
21
+
12
22
  # @return [Modmail] the new modmail
13
23
  def modmail
14
- Modmail.new(client)
24
+ @modmail ||= Modmail.new(client)
15
25
  end
16
26
 
17
27
  # @return [LiveThread] the live thread
@@ -19,21 +29,11 @@ module Redd
19
29
  LiveThread.new(client, id: id)
20
30
  end
21
31
 
22
- # @return [FrontPage] the user's front page
23
- def front_page
24
- FrontPage.new(client)
25
- end
26
-
27
32
  # @return [Hash] a breakdown of karma over subreddits
28
33
  def karma_breakdown
29
34
  client.get('/api/v1/me/karma').body[:data]
30
35
  end
31
36
 
32
- # @return [User] the logged-in user
33
- def me
34
- Self.new(client)
35
- end
36
-
37
37
  # Get a (lazily loaded) reddit user by their name.
38
38
  # @param name [String] the username
39
39
  # @return [User]
@@ -38,7 +38,7 @@ module Redd
38
38
  def js_listing(res)
39
39
  # One day I'll get to deprecate Ruby 2.2 and jump into the world of Hash#dig.
40
40
  return nil unless res[:json] && res[:json][:data] && res[:json][:data][:things]
41
- Models::Listing.new(@client, children: res[:json][:data][:things].map { |t| unmarshal(t) })
41
+ Models::Listing.new(@client, children: res[:json][:data][:things])
42
42
  end
43
43
 
44
44
  # Unmarshal frontend API-style models.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Redd
4
- VERSION = '0.9.0.pre.1'
4
+ VERSION = '0.9.0.pre.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.pre.1
4
+ version: 0.9.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avinash Dwarapu