brutalismbot 1.6.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/brutalismbot/base.rb +3 -2
- data/lib/brutalismbot/client.rb +3 -8
- data/lib/brutalismbot/reddit/post.rb +5 -1
- data/lib/brutalismbot/reddit/resource.rb +2 -1
- data/lib/brutalismbot/version.rb +1 -1
- metadata +2 -114
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 330b378211b26eab38e4c41fc8016b5939266cf66c6e00e81d6b96e23f448ba4
|
4
|
+
data.tar.gz: 761046e07bf707bb25bd6ced9887aee73389febb877cd85b51b568e1d714bed1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e77f992ec2e4a2a599109af96c6d4d93ad086eacba4efbfbbf83e6d921c883b69dff9e92e1920a40574c4304b71e894d7eb393e40918fd9c82a2f3a029a23ae5
|
7
|
+
data.tar.gz: 787d16aed3f829819106b6608318790eac5ae72ab03151a063d5cc72bb491c953678d09439b93001d2b58984ba0b172740e1bea3d1eda36746c73766e835c179
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
<img alt="brutalismbot" src="https://brutalismbot.com/banner.png"/>
|
2
2
|
|
3
|
-
|
4
|
-
[![
|
5
|
-
[![
|
6
|
-
[![
|
3
|
+
![gem](https://img.shields.io/gem/v/brutalismbot?logo=rubygems&logoColor=eee&style=flat-square)
|
4
|
+
[![rspec](https://img.shields.io/github/workflow/status/brutalismbot/gem/rspec?logo=github&style=flat-square)](https://github.com/brutalismbot/gem/actions)
|
5
|
+
[![coverage](https://img.shields.io/codeclimate/coverage/brutalismbot/gem?logo=code-climate&style=flat-square)](https://codeclimate.com/github/brutalismbot/gem/test_coverage)
|
6
|
+
[![maintainability](https://img.shields.io/codeclimate/maintainability/brutalismbot/gem?logo=code-climate&style=flat-square)](https://codeclimate.com/github/brutalismbot/gem/maintainability)
|
7
7
|
|
8
8
|
Brutalismbot RubyGem
|
9
9
|
|
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.transform_keys(&:to_sym))
|
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
|
data/lib/brutalismbot/client.rb
CHANGED
@@ -14,16 +14,11 @@ module Brutalismbot
|
|
14
14
|
@twitter = twitter || Twitter::Client.new
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
lag = ENV["BRUTALISMBOT_LAG_TIME"].to_s
|
19
|
-
lag.empty? ? 9000 : lag.to_i
|
20
|
-
end
|
21
|
-
|
22
|
-
def pull(limit:nil, min_time:nil, max_time:nil, lag:nil, dryrun:nil)
|
17
|
+
def pull(limit:nil, min_time:nil, max_time:nil, min_age:nil, dryrun:nil)
|
23
18
|
# Get time window for new posts
|
24
|
-
|
19
|
+
min_age ||= 9000
|
25
20
|
min_time ||= @posts.max_time
|
26
|
-
max_time ||= Time.now.utc.to_i -
|
21
|
+
max_time ||= Time.now.utc.to_i - min_age.to_i
|
27
22
|
|
28
23
|
# Get posts
|
29
24
|
opts = {q:"self:no AND nsfw:no", restrict_sr: true, sort: "new"}
|
@@ -67,7 +67,7 @@ module Brutalismbot
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def mime_type
|
70
|
-
@
|
70
|
+
@mime_type ||= begin
|
71
71
|
uri = URI.parse(data["url"])
|
72
72
|
ssl = uri.scheme == "https"
|
73
73
|
Brutalismbot.logger.info("HEAD #{uri}")
|
@@ -78,6 +78,10 @@ module Brutalismbot
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
def mime_type=(value)
|
82
|
+
@mime_type = value
|
83
|
+
end
|
84
|
+
|
81
85
|
def path
|
82
86
|
created_utc.strftime("year=%Y/month=%Y-%m/day=%Y-%m-%d/%s.json")
|
83
87
|
end
|
@@ -24,7 +24,8 @@ 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
|
-
|
27
|
+
item = child.transform_keys(&:to_sym)
|
28
|
+
post = Post.new(**item)
|
28
29
|
Brutalismbot.logger.warn("NO PHOTO URL for #{post.permalink}") if post.url.nil?
|
29
30
|
yield post
|
30
31
|
end
|
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: 1.
|
4
|
+
version: 1.7.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: 2020-
|
11
|
+
date: 2020-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twitter
|
@@ -24,118 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '7.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: aws-sdk-s3
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: dotenv
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.7'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.7'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.13'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.13'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rake
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '13.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '13.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '3.8'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '3.8'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: simplecov
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "<"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.18'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "<"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.18'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: webmock
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '3.6'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '3.6'
|
139
27
|
description: 'A Slack app that mirrors posts from /r/brutalism to a #channel of your
|
140
28
|
choosing using incoming webhooks.'
|
141
29
|
email:
|