brutalismbot 0.5.0 → 0.5.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
  SHA256:
3
- metadata.gz: 0cf18d4d7ec09728b41cd4bc32f1208565ee8a8e29df981a950cc12a022ebe05
4
- data.tar.gz: a57aeccee651d4bbd95c8f775af885400b33c00b817759d65ae36129c0e9eaa5
3
+ metadata.gz: be53787b4a66246a55340d428e7eb53ad19c3303254e91c62fd4fcfc7a6281b1
4
+ data.tar.gz: 8a996c1e79b2d699cd32fc7befdafc4834d996aa5a4b3695477afe21226a2328
5
5
  SHA512:
6
- metadata.gz: 19a19b76a2102521cd1280c9b079013adbacc9828e10f1af5983a717e09e6c4f608777e485ab37ba670602d9119e6c29e06c5e67781002143dd93e20f28de652
7
- data.tar.gz: 7263c86e3380544e031843c750e20f69a7eade16bbea7d73c8953b9eadef8930d846a2b186cdadf1d74b45620127272118abe80dbaaa0f6ae462801eb485ea5d
6
+ metadata.gz: 63c3676a56eca6620103aeb08a90d4b269f477aa153f55b2e5da5b2006491ea33b295b03d4af1624aa525faff5e6124e34cd30ed5a4e014668c382faade8e425
7
+ data.tar.gz: af4f64a09bfab5e8903a74d05f1c7f6724d489485d857b506a2908ad0c92d7e29e4a4e56928e4ea18ac9fc0d5c05571996c06c29271ec4b72d0ffde56d9c67d9
@@ -19,10 +19,11 @@ module Brutalismbot
19
19
  class PostCollection
20
20
  include Enumerable
21
21
 
22
- def initialize(uri:, user_agent:)
22
+ def initialize(uri:, user_agent:, min_time:nil)
23
23
  @uri = uri
24
24
  @ssl = uri.scheme == "https"
25
25
  @user_agent = user_agent
26
+ @min_time = min_time.to_i
26
27
  end
27
28
 
28
29
  def each
@@ -33,7 +34,7 @@ module Brutalismbot
33
34
  children = response.dig("data", "children") || []
34
35
  children.each do |child|
35
36
  post = Post[child]
36
- yield post
37
+ yield post if post.created_after? @min_time
37
38
  end
38
39
  end
39
40
  end
@@ -45,6 +46,10 @@ module Brutalismbot
45
46
  def last
46
47
  to_a.last
47
48
  end
49
+
50
+ def since(time)
51
+ PostCollection.new uri: @uri, user_agent: @user_agent, min_time: time
52
+ end
48
53
  end
49
54
 
50
55
  class Brutalism < Subreddit
@@ -148,6 +148,10 @@ module Brutalismbot
148
148
  end
149
149
 
150
150
  def last
151
+ Post[JSON.parse max_key.get.body.read]
152
+ end
153
+
154
+ def max_key
151
155
  # Dig for max key
152
156
  prefix = Time.now.utc.strftime "#{@prefix}year=%Y/month=%Y-%m/day=%Y-%m-%d/"
153
157
  Brutalismbot.logger.info "GET s3://#{@bucket}/#{prefix}*"
@@ -158,11 +162,12 @@ module Brutalismbot
158
162
  Brutalismbot.logger.info "GET s3://#{@bucket}/#{prefix}*"
159
163
  end
160
164
 
161
- # Get max by key
162
- max_key = keys.max{|a,b| a.key <=> b.key }
165
+ # Return max by key
166
+ keys.max{|a,b| a.key <=> b.key }
167
+ end
163
168
 
164
- # Parse as Post
165
- Post[JSON.parse max_key.get.body.read]
169
+ def max_time
170
+ max_key.key.match(/(\d+).json\z/).to_a.last.to_i
166
171
  end
167
172
 
168
173
  def pull(options = {})
@@ -1,3 +1,3 @@
1
1
  module Brutalismbot
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brutalismbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Mancevice
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-05 00:00:00.000000000 Z
11
+ date: 2019-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3