rack-webprofiler 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/lib/rack/web_profiler/collectors/rack_collector.rb +1 -11
- data/lib/rack/web_profiler/collectors/request_collector.rb +1 -6
- data/lib/rack/web_profiler/config.rb +3 -0
- data/lib/rack/web_profiler/engine.rb +18 -18
- data/lib/rack/web_profiler/model.rb +1 -3
- data/lib/rack/web_profiler/utils.rb +13 -0
- data/lib/rack/web_profiler/version.rb +1 -1
- data/lib/rack/web_profiler.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd396a0c74f2907da4a53e8ecd201d49b90cca65
|
4
|
+
data.tar.gz: f5f48a8a2545e4721ebed61e239dc645632525fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42a65d8ce8ab998d31d367ef4f66b9baa0ea85151c00b729104bf631b4c6c1211f309185c728db938fbf3e960244c9ff80d95a019d689ffeaee0c0b43687b6cc
|
7
|
+
data.tar.gz: dae12374c57ec4984b0744886681925e87e79a21f7f6dbd662c1188d52584cd2ecf28f09e687df1826df4d6e2bf8bf7bb172860738c271200f2aab3f3efb7a5a
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,13 @@
|
|
11
11
|
* Catch 500 or exceptions.
|
12
12
|
|
13
13
|
|
14
|
+
## v0.1.2
|
15
|
+
|
16
|
+
### Fixes
|
17
|
+
|
18
|
+
* Optimize the process of saving collected datas.
|
19
|
+
* Truncate table instead delete db file (#31).
|
20
|
+
* Small code cleanup.
|
14
21
|
|
15
22
|
|
16
23
|
## v0.1.1
|
@@ -34,7 +41,7 @@
|
|
34
41
|
|
35
42
|
### Fixes
|
36
43
|
|
37
|
-
|
44
|
+
* Debug SQLite database stabilty by using a single thread.
|
38
45
|
|
39
46
|
|
40
47
|
## v0.1.0.beta2
|
@@ -12,20 +12,10 @@ ICON
|
|
12
12
|
|
13
13
|
collect do |request, _response|
|
14
14
|
store :rack_version, Rack.release
|
15
|
-
store :rack_env, hash_stringify_values(request.env)
|
15
|
+
store :rack_env, Rack::WebProfiler::Utils.hash_stringify_values(request.env)
|
16
16
|
end
|
17
17
|
|
18
18
|
template __FILE__, type: :DATA
|
19
|
-
|
20
|
-
class << self
|
21
|
-
def hash_stringify_values(hash)
|
22
|
-
return {} unless hash.kind_of?(Hash)
|
23
|
-
hash.collect do |k,v|
|
24
|
-
v = v.inspect unless v.kind_of?(String)
|
25
|
-
[k, v]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
19
|
end
|
30
20
|
end
|
31
21
|
|
@@ -17,7 +17,7 @@ ICON
|
|
17
17
|
store :request_cookies, request.cookies
|
18
18
|
store :request_get, request.GET
|
19
19
|
store :request_post, request_post(request)
|
20
|
-
store :request_session, hash_stringify_values(request.session)
|
20
|
+
store :request_session, Rack::WebProfiler::Utils.hash_stringify_values(request.session)
|
21
21
|
store :request_cookies, request.cookies
|
22
22
|
store :request_body, request.body_string
|
23
23
|
store :request_mediatype, request.media_type
|
@@ -44,11 +44,6 @@ ICON
|
|
44
44
|
rescue Exception
|
45
45
|
nil
|
46
46
|
end
|
47
|
-
|
48
|
-
def hash_stringify_values(hash)
|
49
|
-
return {} unless hash.kind_of?(Hash)
|
50
|
-
hash.collect {|k,v| [k, v.to_s]}
|
51
|
-
end
|
52
47
|
end
|
53
48
|
end
|
54
49
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "fileutils"
|
2
|
+
require "tmpdir"
|
2
3
|
|
3
4
|
module Rack
|
4
5
|
# Config
|
@@ -11,6 +12,8 @@ module Rack
|
|
11
12
|
Rack::WebProfiler::Collectors::RubyCollector,
|
12
13
|
Rack::WebProfiler::Collectors::TimeCollector,
|
13
14
|
].freeze
|
15
|
+
|
16
|
+
# Initialize Config.
|
14
17
|
def initialize
|
15
18
|
@collectors = Rack::WebProfiler::Collectors.new
|
16
19
|
|
@@ -73,40 +73,40 @@ module Rack
|
|
73
73
|
attr_reader :record
|
74
74
|
|
75
75
|
def initialize(request, response)
|
76
|
-
@
|
77
|
-
@request = request.clone.freeze
|
78
|
-
@response = response.clone.freeze
|
79
|
-
@record = nil
|
76
|
+
@record = new_record(request.clone.freeze, response.clone.freeze)
|
80
77
|
end
|
81
78
|
|
82
79
|
def save!
|
83
|
-
create_record!
|
84
|
-
save_collected_datas!
|
85
|
-
|
86
80
|
@record.save({ transaction: true })
|
81
|
+
rescue => e
|
82
|
+
# @todo raise_if_debug WebProfiler::RuntimeError, "Error while processing to save datas", e.backtrace
|
87
83
|
end
|
88
84
|
|
89
85
|
private
|
90
86
|
|
91
|
-
def
|
92
|
-
|
93
|
-
url:
|
94
|
-
ip:
|
95
|
-
http_method:
|
96
|
-
http_status:
|
97
|
-
content_type:
|
98
|
-
datas:
|
87
|
+
def new_record(request, response)
|
88
|
+
WebProfiler::Model::CollectionRecord.new({
|
89
|
+
url: request.url,
|
90
|
+
ip: request.ip,
|
91
|
+
http_method: request.request_method,
|
92
|
+
http_status: response.status,
|
93
|
+
content_type: response.content_type,
|
94
|
+
datas: collect_datas(request, response),
|
99
95
|
})
|
100
96
|
end
|
101
97
|
|
102
|
-
def
|
98
|
+
def collect_datas(request, response)
|
103
99
|
datas = {}
|
104
100
|
|
105
101
|
Rack::WebProfiler.config.collectors.all.each do |name, definition|
|
106
|
-
|
102
|
+
begin
|
103
|
+
datas[name.to_sym] = definition.collect!(request, response).to_h
|
104
|
+
rescue => e
|
105
|
+
# @todo raise_if_debug WebProfiler::RuntimeError, "Error while collecting datas of collector '#{name}'"
|
106
|
+
end
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
datas
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
data/lib/rack/web_profiler.rb
CHANGED
@@ -13,6 +13,7 @@ module Rack
|
|
13
13
|
autoload :Response, "rack/web_profiler/response"
|
14
14
|
autoload :Request, "rack/web_profiler/request"
|
15
15
|
autoload :Router, "rack/web_profiler/router"
|
16
|
+
autoload :Utils, "rack/web_profiler/utils"
|
16
17
|
autoload :View, "rack/web_profiler/view"
|
17
18
|
|
18
19
|
# Classes about Rouge gem customization.
|
@@ -20,6 +21,9 @@ module Rack
|
|
20
21
|
autoload :HTMLFormatter, "rack/web_profiler/rouge/html_formatter"
|
21
22
|
end
|
22
23
|
|
24
|
+
# Exceptions
|
25
|
+
class RuntimeError < ::RuntimeError; end
|
26
|
+
|
23
27
|
# Env key constants.
|
24
28
|
ENV_RUNTIME_START = "rack_webprofiler.runtime_start".freeze
|
25
29
|
ENV_RUNTIME = "rack_webprofiler.runtime".freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-webprofiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Brousse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/rack/web_profiler/response.rb
|
169
169
|
- lib/rack/web_profiler/rouge/html_formatter.rb
|
170
170
|
- lib/rack/web_profiler/router.rb
|
171
|
+
- lib/rack/web_profiler/utils.rb
|
171
172
|
- lib/rack/web_profiler/version.rb
|
172
173
|
- lib/rack/web_profiler/view.rb
|
173
174
|
- lib/rack/webprofiler.rb
|