repsheet_visualizer 0.0.3 → 0.0.4

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.
@@ -2,11 +2,19 @@
2
2
 
3
3
  begin
4
4
  require 'repsheet_visualizer/application/app.rb'
5
+ if ARGV.count == 2
6
+ RepsheetVisualizer.set :redis_host, ARGV[0]
7
+ RepsheetVisualizer.set :redis_port, ARGV[1]
8
+ end
5
9
  RepsheetVisualizer.run!
6
10
  rescue LoadError => e
7
11
  require 'rubygems'
8
12
  path = File.expand_path '../../lib', __FILE__
9
13
  $:.unshift(path) if File.directory?(path) && !$:.include?(path)
10
14
  require 'repsheet_visualizer/application/app.rb'
15
+ if ARGV.count == 2
16
+ RepsheetVisualizer.set :redis_host, ARGV[0]
17
+ RepsheetVisualizer.set :redis_port, ARGV[1]
18
+ end
11
19
  RepsheetVisualizer.run!
12
20
  end
@@ -13,8 +13,15 @@ class RepsheetVisualizer < Sinatra::Base
13
13
  end
14
14
  end
15
15
 
16
+ def redis_connection
17
+ host = defined?(settings.redis_host) ? settings.redis_host : "localhost"
18
+ port = defined?(settings.redis_port) ? settings.redis_port : 6379
19
+
20
+ Redis.new(:host => host, :port => port)
21
+ end
22
+
16
23
  get '/' do
17
- redis = Redis.new(:host => "localhost", :port => 6379)
24
+ redis = redis_connection
18
25
  data = redis.keys("*:requests").map {|d| d.split(":").first}.reject {|ip| ip.empty?}
19
26
  @actors = {}
20
27
  data.each do |actor|
@@ -27,14 +34,14 @@ class RepsheetVisualizer < Sinatra::Base
27
34
  end
28
35
 
29
36
  get '/activity/:ip' do
30
- redis = Redis.new(:host => "localhost", :port => 6379)
37
+ redis = redis_connection
31
38
  @ip = params[:ip]
32
39
  @activity = redis.lrange("#{@ip}:requests", 0, -1)
33
40
  erb :activity
34
41
  end
35
42
 
36
43
  post '/action' do
37
- redis = Redis.new(:host => "localhost", :port => 6379)
44
+ redis = redis_connection
38
45
  if params["action"] == "allow"
39
46
  redis.set("#{params[:ip]}:repsheet:blacklist", "false")
40
47
  else
@@ -44,7 +51,7 @@ class RepsheetVisualizer < Sinatra::Base
44
51
  end
45
52
 
46
53
  get '/breakdown' do
47
- redis = Redis.new(:host => "localhost", :port => 6379)
54
+ redis = redis_connection
48
55
  @data = {}
49
56
  offenders = redis.keys("*:repsheet").map {|o| o.split(":").first}
50
57
  offenders.each do |offender|
@@ -1,3 +1,3 @@
1
1
  module RepsheetVisualizer
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repsheet_visualizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-20 00:00:00.000000000 Z
12
+ date: 2013-05-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis