rack-webprofiler 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd396a0c74f2907da4a53e8ecd201d49b90cca65
4
- data.tar.gz: f5f48a8a2545e4721ebed61e239dc645632525fc
3
+ metadata.gz: d2995d0dfb44e3b0425c0f51f1d16dbc1e7a64e0
4
+ data.tar.gz: 6ef39dc746478b470ef19a106e55b2ca9c61e836
5
5
  SHA512:
6
- metadata.gz: 42a65d8ce8ab998d31d367ef4f66b9baa0ea85151c00b729104bf631b4c6c1211f309185c728db938fbf3e960244c9ff80d95a019d689ffeaee0c0b43687b6cc
7
- data.tar.gz: dae12374c57ec4984b0744886681925e87e79a21f7f6dbd662c1188d52584cd2ecf28f09e687df1826df4d6e2bf8bf7bb172860738c271200f2aab3f3efb7a5a
6
+ metadata.gz: 8f1a0c68cdcc7d3e94739ebdec5253e0aca96251cb7cf9413d8813e769400e3595093d17cbe4cb6a5e23adf55172ea41ecfd13f51c6a5faea36e282b7936fd94
7
+ data.tar.gz: 783944e423468299ae22e53288d0220ec99f1c62a5c641caf8cc96b3c93e7d1c6a75b7ab0080d141a4643dfd2d8b7b88949e9ff832a927167b8e0b1ecd43ced2
@@ -11,6 +11,16 @@
11
11
  * Catch 500 or exceptions.
12
12
 
13
13
 
14
+ ## v0.1.3
15
+
16
+ ### Fixes
17
+
18
+ * Do request and response optional on DSL for collect method (#34).
19
+ * Create a method to reset collectors list.
20
+ * Debug `erb` method of Controller.
21
+ * Small code cleanup.
22
+
23
+
14
24
  ## v0.1.2
15
25
 
16
26
  ### Fixes
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  A Rack profiler for web application.
4
4
 
5
5
  [![Version ](http://img.shields.io/gem/v/rack-webprofiler.svg) ](https://rubygems.org/gems/rack-webprofiler)
6
- [![Travis CI ](http://img.shields.io/travis/rack-webprofiler/rack-webprofiler/master.svg) ](https://travis-ci.org/rack-profiler/rack-webprofiler)
6
+ [![Travis CI ](http://img.shields.io/travis/rack-webprofiler/rack-webprofiler/master.svg) ](https://travis-ci.org/rack-webprofiler/rack-webprofiler)
7
7
  [![Gitter ](https://img.shields.io/gitter/room/rack-webprofiler/rack-webprofiler.svg) ](https://gitter.im/rack-webprofiler/rack-webprofiler)
8
8
 
9
9
  ## Installation
@@ -7,7 +7,7 @@
7
7
  </head>
8
8
  <body>
9
9
  <div id="rack-webprofiler">
10
- <%= partial 'panel/_sidebar.erb' %>
10
+ <%= partial "panel/_sidebar.erb" %>
11
11
 
12
12
  <main id="main">
13
13
  <header id="header">
@@ -41,6 +41,11 @@ module Rack
41
41
  @config
42
42
  end
43
43
 
44
+ # Reset collectors.
45
+ def reset_collectors!
46
+ config.collectors.reset!
47
+ end
48
+
44
49
  # Register one or many collectors.
45
50
  #
46
51
  # @param collector_class [Array, Class]
@@ -86,7 +86,8 @@ module Rack
86
86
  #
87
87
  # @return [Rack::WebProfiler::Collector::DSL::DataStorage]
88
88
  def collect!(request, response)
89
- @data_storage = Docile.dsl_eval(DataStorage.new, request, response, &collect)
89
+ args = [request, response]
90
+ @data_storage = Docile.dsl_eval(DataStorage.new, *args.take(collect.arity), &collect)
90
91
  end
91
92
 
92
93
  # Is the collector enabled.
@@ -11,8 +11,7 @@ module Rack
11
11
 
12
12
  # Initialize.
13
13
  def initialize
14
- @collectors = {}
15
- @sorted_collectors = {}
14
+ reset!
16
15
  end
17
16
 
18
17
  # Get a collector definition by his identifier.
@@ -77,6 +76,12 @@ module Rack
77
76
  sort_collectors!
78
77
  end
79
78
 
79
+ # Reset collecotrs.
80
+ def reset!
81
+ @collectors = {}
82
+ @sorted_collectors = {}
83
+ end
84
+
80
85
  private
81
86
 
82
87
  # Sort collectors by definition identifier.
@@ -10,7 +10,7 @@ ICON
10
10
  label "Rack"
11
11
  position 1
12
12
 
13
- collect do |request, _response|
13
+ collect do |request|
14
14
  store :rack_version, Rack.release
15
15
  store :rack_env, Rack::WebProfiler::Utils.hash_stringify_values(request.env)
16
16
  end
@@ -10,7 +10,7 @@ ICON
10
10
  label "Ruby"
11
11
  position 0
12
12
 
13
- collect do |_request, _response|
13
+ collect do
14
14
  store :ruby_version, RUBY_VERSION
15
15
  store :ruby_patchlevel, RUBY_PATCHLEVEL
16
16
  store :ruby_release_date, RUBY_RELEASE_DATE
@@ -10,7 +10,7 @@ ICON
10
10
  label "Time"
11
11
  position 3
12
12
 
13
- collect do |request, _response|
13
+ collect do |request|
14
14
  runtime = request.env[WebProfiler::ENV_RUNTIME] * 1000.0
15
15
 
16
16
  store :runtime, runtime
@@ -127,12 +127,10 @@ module Rack
127
127
  # @return [Rack::Response]
128
128
  #
129
129
  # @private
130
- def erb(path, layout: nil, variables: nil, status: 200)
130
+ def erb(path, layout: nil, variables: binding, status: 200)
131
131
  v = WebProfiler::View.new(path, layout: layout)
132
132
 
133
- variables ||= binding
134
-
135
- Rack::Response.new(v.result(variables), status, {
133
+ Rack::Response.new(v.result(variables) || "", status, {
136
134
  "Content-Type" => "text/html",
137
135
  })
138
136
  end
@@ -48,8 +48,10 @@ module Rack
48
48
  #
49
49
  # @param request [Rack::WebProfiler::Request]
50
50
  # @param response [Rack::Response]
51
+ #
52
+ # @return [WebProfiler::Model::CollectionRecord]
51
53
  def collect!(request, response)
52
- processor = Processor.new(request, response)
54
+ processor = Processor.new(request.clone.freeze, response.clone.freeze)
53
55
  processor.save!
54
56
 
55
57
  processor.record
@@ -73,7 +75,7 @@ module Rack
73
75
  attr_reader :record
74
76
 
75
77
  def initialize(request, response)
76
- @record = new_record(request.clone.freeze, response.clone.freeze)
78
+ @record = new_record(request, response)
77
79
  end
78
80
 
79
81
  def save!
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class WebProfiler
3
- VERSION = "0.1.2".freeze
3
+ VERSION = "0.1.3".freeze
4
4
  end
5
5
  end
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.2
4
+ version: 0.1.3
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-04-20 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack