shamebot 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/VERSION +1 -1
  4. data/bin/shamebot +8 -8
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b2ee07b476080c883e634f018cb592c6711bdd2
4
- data.tar.gz: 5ada437031bfef93ae685e07b493881d320516ca
3
+ metadata.gz: f4c337743fe604dd67dcf0fdb9a30697de4e2540
4
+ data.tar.gz: 9f41d2fd91f6f7732c44c6cbcdd621951a4228cf
5
5
  SHA512:
6
- metadata.gz: c0197735f7035b1ba8b4e74d92da55274ac6a3044115aa0115d27f5312181720fb4a6082c576dc47c44f379f0faee22861d501d04d1239bf02eb735b86b1bc76
7
- data.tar.gz: 4794f144c0b6b8dc9169ebee977d0f4d39de63e7b3aad568e85ead6f57a1e3f84d2ee29eaf6c52b7ff66f8063465587558807ae6a58b161a8995bdcc9a66eac3
6
+ metadata.gz: c62d461f3fd41f3dbd2c0b50cf8443424d5a7c4f2ac7428e568100ab095909e91c5852f54c560c50e5a12011f941c8d9343d35c3988d9352927ada1997cc3827
7
+ data.tar.gz: 6cda43d88380c397934288ec99902432294a4190365d5f29f36d4c98daae3f2ce92df43b1c0efc0714f21261cb5d56ee496b8398d2077dbb2e918e75ceedba61
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shamebot (0.0.0)
4
+ shamebot (1.0.0)
5
5
  gitlab (~> 3.1.0)
6
6
  hipchat (~> 1)
7
7
  sinatra (~> 1)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.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: 'b'
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[:config]}'"
31
- File.open(Opts[:config], 'w') do |f|
32
- f.puts JSON.pretty_generate(CONFIG)
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 CONFIG['shamings'].has_key? commit['id']
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
- CONFIG['shamings'][commit['id']] = true
158
+ DB[commit['id']] = true
159
159
  end
160
160
 
161
161
  # Shame the user with a random template
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shamebot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer