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 +4 -4
- data/lib/brutalismbot/r.rb +7 -2
- data/lib/brutalismbot/s3.rb +9 -4
- data/lib/brutalismbot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be53787b4a66246a55340d428e7eb53ad19c3303254e91c62fd4fcfc7a6281b1
|
4
|
+
data.tar.gz: 8a996c1e79b2d699cd32fc7befdafc4834d996aa5a4b3695477afe21226a2328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63c3676a56eca6620103aeb08a90d4b269f477aa153f55b2e5da5b2006491ea33b295b03d4af1624aa525faff5e6124e34cd30ed5a4e014668c382faade8e425
|
7
|
+
data.tar.gz: af4f64a09bfab5e8903a74d05f1c7f6724d489485d857b506a2908ad0c92d7e29e4a4e56928e4ea18ac9fc0d5c05571996c06c29271ec4b72d0ffde56d9c67d9
|
data/lib/brutalismbot/r.rb
CHANGED
@@ -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
|
data/lib/brutalismbot/s3.rb
CHANGED
@@ -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
|
-
#
|
162
|
-
|
165
|
+
# Return max by key
|
166
|
+
keys.max{|a,b| a.key <=> b.key }
|
167
|
+
end
|
163
168
|
|
164
|
-
|
165
|
-
|
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 = {})
|
data/lib/brutalismbot/version.rb
CHANGED
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.
|
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-
|
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
|