harrods 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/harrods.gemspec +2 -0
- data/lib/harrods.rb +2 -0
- data/lib/harrods/basic_middleware.rb +25 -0
- data/lib/harrods/logger.rb +18 -0
- data/lib/harrods/version.rb +1 -1
- data/templates/toolbar.erb +1 -5
- metadata +20 -2
data/harrods.gemspec
CHANGED
data/lib/harrods.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Harrods
|
2
|
+
class BasicMiddleware
|
3
|
+
|
4
|
+
def initialize(app)
|
5
|
+
@db = Harrods::Database.new Rails.root.join("db","harrods.db")
|
6
|
+
@logger = Harrods::Logger.new
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
tracer = Harrods::Tracer.new(@db)
|
12
|
+
status, headers, response, output, ram, objects, gc_runs, gc_time = nil, nil, nil, nil, nil, nil, nil
|
13
|
+
if env['ORIGINAL_FULLPATH'].split("/")[1] == "assets"
|
14
|
+
status, headers, response = @app.call(env)
|
15
|
+
[status, headers, response]
|
16
|
+
else
|
17
|
+
ram, objects, gc_runs, gc_time = tracer.record(env['ORIGINAL_FULLPATH']) do
|
18
|
+
status, headers, response = @app.call(env)
|
19
|
+
end
|
20
|
+
@logger.log(ram, objects, gc_runs, gc_time)
|
21
|
+
[status, headers, response]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
module Harrods
|
4
|
+
class Logger
|
5
|
+
include Presenter
|
6
|
+
extend Presenter
|
7
|
+
|
8
|
+
def initialize(colour=:red, destination=$stdout)
|
9
|
+
@logger = destination
|
10
|
+
@colour = colour
|
11
|
+
end
|
12
|
+
|
13
|
+
def log(ram, objects, gc_runs, gc_time)
|
14
|
+
@logger.write "[HARRODS] RAM: #{present_storage_size(ram)}, OBJECTS: #{present_with_commas(objects)}, GC RUNS: #{gc_runs}, GC TIME: #{gc_time}\n".colorize(@colour)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/harrods/version.rb
CHANGED
data/templates/toolbar.erb
CHANGED
@@ -5,8 +5,4 @@
|
|
5
5
|
<p class="ram-usage">RAM <%= @ram %>/<%= @stats[:ram_formatted] %></p><p class="object-usage">OBJECTS <%= @objects %>/<%= @stats[:objects_formatted] %></p>
|
6
6
|
<div class="sparkline"></div>
|
7
7
|
</div>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<script type="text/javascript">
|
11
|
-
$('.sparkline').sparkline([<%= @raw_ram_usage.join(",") %>], {type: 'bar'});
|
12
|
-
</script>
|
8
|
+
</div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harrods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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: 2012-12-
|
12
|
+
date: 2012-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: colorize
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
description: How much does that cost?!
|
95
111
|
email:
|
96
112
|
- john@musicglue.com
|
@@ -106,8 +122,10 @@ files:
|
|
106
122
|
- Rakefile
|
107
123
|
- harrods.gemspec
|
108
124
|
- lib/harrods.rb
|
125
|
+
- lib/harrods/basic_middleware.rb
|
109
126
|
- lib/harrods/configuration.rb
|
110
127
|
- lib/harrods/database.rb
|
128
|
+
- lib/harrods/logger.rb
|
111
129
|
- lib/harrods/middleware.rb
|
112
130
|
- lib/harrods/presenter.rb
|
113
131
|
- lib/harrods/redis_client.rb
|