brutalismbot 1.6.0 → 1.6.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8083bff6e181d2ce309970c131600644d99fa239887aeb9fd1cba8dbc296171
|
4
|
+
data.tar.gz: 837c725df3d2fc0b6565eb1d386d581350c0881ef911e9c026178c2f5ae072b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 886e816a00e86b60f31109dc8130388546f71acf2dc549815cc143040a7c828a159f38e5105ff62670115602cf1defda4cfc26ddfffd728afa3328b558792892
|
7
|
+
data.tar.gz: 5809c0a14b366fdf389da65d74579993ca6cf9ecace98c4cfff80562d643c26701a047ae709f2903d73477553850ba3bfb70ef2ef751ed62a3bb2e80f31f81b3
|
data/lib/brutalismbot/base.rb
CHANGED
@@ -4,7 +4,8 @@ require "json"
|
|
4
4
|
module Brutalismbot
|
5
5
|
module Parser
|
6
6
|
def parse(source, opts = {})
|
7
|
-
|
7
|
+
item = JSON.parse(source, opts)
|
8
|
+
new(**item)
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
@@ -14,7 +15,7 @@ module Brutalismbot
|
|
14
15
|
|
15
16
|
def_delegators :@item, :[], :dig, :fetch, :to_h, :to_json
|
16
17
|
|
17
|
-
def initialize(item
|
18
|
+
def initialize(**item)
|
18
19
|
@item = JSON.parse(item.to_json)
|
19
20
|
end
|
20
21
|
end
|
@@ -7,6 +7,11 @@ require "brutalismbot/base"
|
|
7
7
|
module Brutalismbot
|
8
8
|
module Reddit
|
9
9
|
class Post < Base
|
10
|
+
def initialize(**item)
|
11
|
+
@mime_type = item.delete(:mime_type)
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
10
15
|
def created_after?(time = nil)
|
11
16
|
time.nil? || created_utc.to_i > time.to_i
|
12
17
|
end
|
@@ -67,7 +72,7 @@ module Brutalismbot
|
|
67
72
|
end
|
68
73
|
|
69
74
|
def mime_type
|
70
|
-
@
|
75
|
+
@mime_type ||= begin
|
71
76
|
uri = URI.parse(data["url"])
|
72
77
|
ssl = uri.scheme == "https"
|
73
78
|
Brutalismbot.logger.info("HEAD #{uri}")
|
@@ -24,7 +24,7 @@ module Brutalismbot
|
|
24
24
|
response = JSON.parse(http.request(request).body)
|
25
25
|
children = response.dig("data", "children") || []
|
26
26
|
children.each do |child|
|
27
|
-
post = Post.new(child)
|
27
|
+
post = Post.new(**child)
|
28
28
|
Brutalismbot.logger.warn("NO PHOTO URL for #{post.permalink}") if post.url.nil?
|
29
29
|
yield post
|
30
30
|
end
|
@@ -4,12 +4,13 @@ module Brutalismbot
|
|
4
4
|
module Reddit
|
5
5
|
class Post
|
6
6
|
class << self
|
7
|
-
def stub(created_utc:nil, post_id:nil, permalink_id:nil, image_id:nil)
|
7
|
+
def stub(created_utc:nil, post_id:nil, permalink_id:nil, image_id:nil, mime_type:nil)
|
8
8
|
created_utc ||= Time.now.utc - rand(86400) - 86400
|
9
9
|
post_id ||= SecureRandom.alphanumeric(6).downcase
|
10
10
|
permalink_id ||= SecureRandom.alphanumeric.downcase
|
11
11
|
image_id ||= SecureRandom.alphanumeric
|
12
12
|
new(
|
13
|
+
mime_type: mime_type,
|
13
14
|
kind: "t3",
|
14
15
|
data: {
|
15
16
|
id: post_id,
|
data/lib/brutalismbot/version.rb
CHANGED