shamebot 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/bin/shamebot +8 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c337743fe604dd67dcf0fdb9a30697de4e2540
|
4
|
+
data.tar.gz: 9f41d2fd91f6f7732c44c6cbcdd621951a4228cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c62d461f3fd41f3dbd2c0b50cf8443424d5a7c4f2ac7428e568100ab095909e91c5852f54c560c50e5a12011f941c8d9343d35c3988d9352927ada1997cc3827
|
7
|
+
data.tar.gz: 6cda43d88380c397934288ec99902432294a4190365d5f29f36d4c98daae3f2ce92df43b1c0efc0714f21261cb5d56ee496b8398d2077dbb2e918e75ceedba61
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/bin/shamebot
CHANGED
@@ -16,20 +16,22 @@ Opts = Trollop::options do
|
|
16
16
|
Options:
|
17
17
|
EOS
|
18
18
|
opt :config, 'Path to configuration', type: :string, required: true, short: 'c'
|
19
|
+
opt :db, 'Path to shamings database', default: '/tmp/shamebot.db', short: 'b'
|
19
20
|
opt :debug, 'Enable debugging', default: false, short: 'd'
|
20
21
|
opt :port, 'Port to listen on', default: 4567, short: 'p'
|
21
22
|
opt :env, 'Sinatra environment', default: 'production', short: 'e'
|
22
|
-
opt :bind, 'Interface to listen on', default: '0.0.0.0', short: '
|
23
|
+
opt :bind, 'Interface to listen on', default: '0.0.0.0', short: 'i'
|
23
24
|
end
|
24
25
|
|
25
26
|
DEBUG = Opts[:debug]
|
26
27
|
CONFIG = JSON.parse File.read(Opts[:config])
|
28
|
+
DB = File::exists?(Opts[:db]) ? JSON::parse(File.read(Opts[:db])) : {}
|
27
29
|
|
28
30
|
unless DEBUG
|
29
31
|
at_exit do
|
30
|
-
puts "Writing back to '#{Opts[:
|
31
|
-
File.open(Opts[:
|
32
|
-
f.puts JSON.pretty_generate(
|
32
|
+
puts "Writing back to '#{Opts[:db]}'"
|
33
|
+
File.open(Opts[:db], 'w') do |f|
|
34
|
+
f.puts JSON.pretty_generate(DB)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -67,8 +69,6 @@ def random_template
|
|
67
69
|
TEMPLATES[rand(0...TEMPLATES.length)]
|
68
70
|
end
|
69
71
|
|
70
|
-
CONFIG['shamings'] = CONFIG.has_key?('shamings') ? CONFIG['shamings'] : {}
|
71
|
-
|
72
72
|
|
73
73
|
|
74
74
|
|
@@ -150,12 +150,12 @@ post '/' do
|
|
150
150
|
new_bad_commits = []
|
151
151
|
bad_commits.each do |commit|
|
152
152
|
unless DEBUG
|
153
|
-
next if
|
153
|
+
next if DB.has_key? commit['id']
|
154
154
|
commit_time = DateTime.strptime(commit['timestamp']).to_time
|
155
155
|
next unless commit_time >= last_half_hour
|
156
156
|
end
|
157
157
|
new_bad_commits << commit
|
158
|
-
|
158
|
+
DB[commit['id']] = true
|
159
159
|
end
|
160
160
|
|
161
161
|
# Shame the user with a random template
|