brutalismbot 1.6.0 → 1.6.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: 28218fbe0be73eed7c6f58124f4845c2ddcbcd5734055295c93ab544767455cf
4
- data.tar.gz: 304ae833546888f31d9177e907bc6caba0f486a11048b8a16b2fcbe71ec2166b
3
+ metadata.gz: c8083bff6e181d2ce309970c131600644d99fa239887aeb9fd1cba8dbc296171
4
+ data.tar.gz: 837c725df3d2fc0b6565eb1d386d581350c0881ef911e9c026178c2f5ae072b5
5
5
  SHA512:
6
- metadata.gz: dd8b2c2d014f52ce4a4d845e7342b4c5c8c4e5d62269b390376ea7de198b2098f800e9dea9931ec55e4c0ce17a4ca8badb66a2c92113c95c89901600cfbf2127
7
- data.tar.gz: 254fed1155712f30f0440f38fb05576aabda571a9f6a592b8598f27f6b3bce4dbe27ac798b31aa37a6bfef200a07df5045c4633383471726751fbf34af3a6e98
6
+ metadata.gz: 886e816a00e86b60f31109dc8130388546f71acf2dc549815cc143040a7c828a159f38e5105ff62670115602cf1defda4cfc26ddfffd728afa3328b558792892
7
+ data.tar.gz: 5809c0a14b366fdf389da65d74579993ca6cf9ecace98c4cfff80562d643c26701a047ae709f2903d73477553850ba3bfb70ef2ef751ed62a3bb2e80f31f81b3
@@ -4,7 +4,8 @@ require "json"
4
4
  module Brutalismbot
5
5
  module Parser
6
6
  def parse(source, opts = {})
7
- new JSON.parse(source, opts)
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
- @mime ||= begin
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,
@@ -1,3 +1,3 @@
1
1
  module Brutalismbot
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brutalismbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Mancevice