rails-webprofiler 0.1.0 → 0.1.1

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: 0d5d3d3fec249c55feee97e07f90502654799248
4
- data.tar.gz: 9add6f25af392583b805641dab95d3b5d040f761
3
+ metadata.gz: 9a63d72241be08bb543bd3f463571bd7c560acf3
4
+ data.tar.gz: 2baccab9e96c4377e5be9d61e23e68bc4500218d
5
5
  SHA512:
6
- metadata.gz: c0d62734e506066c976b4cf9aa4cab9998f294b1a2a3e164c89042a5afb7ba7ec11eaee105556212b71e5bc7deab2b8aadaea9ac8f306a6ca5f2a4eb2523e3da
7
- data.tar.gz: 29d2f4fbb9512d3fae65f52b9cfeedaa73e39c46559aa25983374468449c92037359897069777573db087c09c20392de3fc347a0dac5ea49b728190d3d662fcf
6
+ metadata.gz: 07ddd1fb120f61f05023d3aa1146a64a7292261e0089a186ffa36d9d3d719155f2da6110584f6d8abf2cb190d0d15eb9038e66b7036edc7dc6d7785ee3fa994a
7
+ data.tar.gz: b1836c45195e1dfae91d31723beb449f2c6fc8027d70e6e32e64ea67eeb4da4dbdb00a43e0f02697dbc551edc2b351baf09663e607273eb775bead4e0406bb30
@@ -9,6 +9,22 @@
9
9
  * Create a collector to show the Rails logger informations.
10
10
 
11
11
 
12
+ ## v0.1.1
13
+
14
+ Use `rack-webprofiler` >= `0.1.3`.
15
+
16
+ ### Features
17
+
18
+ * Show connection informations on ActiveRecordCollector.
19
+
20
+ ### Fixes
21
+
22
+ * Optimize the Railtie implementation.
23
+ * Optimize ActionViewCollector (#10).
24
+ * Load profiler only for Rails 4.2+.
25
+ * Small code cleanup.
26
+
27
+
12
28
  ## v0.1.0
13
29
 
14
30
  ### Features
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rails WebProfiler
2
2
 
3
- A web profiler for Rails applications based on
3
+ A web profiler for Rails +4.2 applications based on
4
4
  [`rack-webprofiler`](https://github.com/rack-webprofiler/rack-webprofiler/).
5
5
 
6
6
  [![Version ](http://img.shields.io/gem/v/rails-webprofiler.svg) ](https://rubygems.org/gems/rails-webprofiler)
@@ -27,7 +27,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
27
27
 
28
28
  ## Contributing
29
29
 
30
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails-webprofiler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rack-webprofiler/rails-webprofiler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
31
31
 
32
32
 
33
33
  ## License
@@ -1,16 +1,21 @@
1
1
  require "rack/webprofiler"
2
+ require "rails/version"
3
+ require "rails/railtie"
2
4
 
3
- class Rails::WebProfiler
5
+ module Rails
6
+ class WebProfiler
7
+ autoload :VERSION, "rails/web_profiler/version"
8
+ autoload :NotificationHandler, "rails/web_profiler/notification_handler"
4
9
 
5
- autoload :VERSION, "rails/web_profiler/version"
6
- autoload :NotificationHandler, "rails/web_profiler/notification_handler"
7
-
8
- module Collectors
9
- autoload :ActionViewCollector, "rails/web_profiler/collectors/action_view_collector"
10
- autoload :ActiveRecordCollector, "rails/web_profiler/collectors/active_record_collector"
11
- autoload :RailsCollector, "rails/web_profiler/collectors/rails_collector"
12
- autoload :RequestCollector, "rails/web_profiler/collectors/request_collector"
10
+ module Collectors
11
+ autoload :ActionViewCollector, "rails/web_profiler/collectors/action_view_collector"
12
+ autoload :ActiveRecordCollector, "rails/web_profiler/collectors/active_record_collector"
13
+ autoload :RailsCollector, "rails/web_profiler/collectors/rails_collector"
14
+ autoload :RequestCollector, "rails/web_profiler/collectors/request_collector"
15
+ end
13
16
  end
14
17
  end
15
18
 
16
- require "rails/web_profiler/railtie" if defined? Rails
19
+ if defined?(::Rails) && ::Rails.version >= "4.2.0"
20
+ require "rails/web_profiler/railtie"
21
+ end
@@ -10,11 +10,16 @@ ICON
10
10
  label "ActionView"
11
11
  position 9
12
12
 
13
- collect do |_request, _response|
13
+ collect do
14
14
  data = ::Rack::WebProfiler.data("rails.events")
15
15
 
16
16
  events = []
17
- events = data.by_event_names(%w(render_template.action_view render_partial.action_view)) unless data.nil?
17
+ if !data.nil?
18
+ events = data.by_event_names(%w(render_template.action_view render_partial.action_view))
19
+ events.each do |e|
20
+ e.payload.delete_if { |k, _v| !%w( identifier layout ).include?(k.to_s) }
21
+ end
22
+ end
18
23
 
19
24
  total_duration = events.inject(0) { |sum, e| sum + e.duration }
20
25
 
@@ -25,7 +30,7 @@ ICON
25
30
 
26
31
  template __FILE__, type: :DATA
27
32
 
28
- is_enabled? -> { defined? ::ActiveRecord }
33
+ is_enabled? -> { defined? ::ActionView }
29
34
  end
30
35
  end
31
36
 
@@ -10,12 +10,18 @@ ICON
10
10
  label "ActiveRecord"
11
11
  position 10
12
12
 
13
- collect do |_request, _response|
13
+ collect do
14
14
  data = ::Rack::WebProfiler.data("rails.events")
15
15
 
16
16
  events = []
17
17
  events = data.by_event_name("sql.active_record") unless data.nil?
18
18
 
19
+ ar_conn = ActiveRecord::Base.connection
20
+ store :connection, {
21
+ adapter_class: ar_conn.class.name,
22
+ adapter_name: ar_conn.adapter_name,
23
+ }
24
+
19
25
  total_duration = events.inject(0) { |sum, e| sum + e.duration }
20
26
 
21
27
  store :events, events
@@ -85,4 +91,22 @@ __END__
85
91
  <p><span class="text__no-value">No queries executed.</span></p>
86
92
  <% end %>
87
93
  </div>
94
+
95
+ <div class="block">
96
+ <h3>Connection</h3>
97
+
98
+ <% conn = data(:connection) %>
99
+ <table>
100
+ <tbody>
101
+ <tr>
102
+ <th>Adapter class</th>
103
+ <td><code><%=h conn[:adapter_class] %></code></td>
104
+ </tr>
105
+ <tr>
106
+ <th>Adapter name</th>
107
+ <td><%=h conn[:adapter_name] %></td>
108
+ </tr>
109
+ </tbody>
110
+ </table>
111
+ </div>
88
112
  <% end %>
@@ -11,7 +11,7 @@ ICON
11
11
  label "Rails"
12
12
  position 1
13
13
 
14
- collect do |request, _response|
14
+ collect do |request|
15
15
  store :rack_version, ::Rack.release
16
16
 
17
17
  store :rails_version, Rails.version
@@ -20,7 +20,6 @@ class Rails::WebProfiler::NotificationHandler
20
20
  end
21
21
  end
22
22
  end
23
-
24
23
  alias by_event_names by_event_name
25
24
  end
26
25
  end
@@ -1,20 +1,15 @@
1
- require "rails"
2
-
3
1
  module Rails
4
- # WebProfiler::Railtie
5
- class WebProfiler::Railtie < ::Rails::Railtie # :nodoc:
6
- initializer "rails-webprofiler.configure_rails_initialization" do |app|
7
- app.middleware.use ::Rack::WebProfiler do |c|
8
- c.tmp_dir = ::File.expand_path(::File.join(Rails.root, "tmp"), __FILE__)
9
- end
2
+ class WebProfiler
3
+ def self.initialize!(app)
4
+ raise "Rails::WebProfiler initialized twice. Set `require: false' for rails-webprofiler in your Gemfile" if @already_initialized
10
5
 
11
- ::Rack::WebProfiler.unregister_collector [
12
- # ::Rack::WebProfiler::Collectors::ExceptionCollector,
13
- ::Rack::WebProfiler::Collectors::RackCollector,
14
- ::Rack::WebProfiler::Collectors::RequestCollector,
15
- ]
6
+ app.middleware.insert(0, ::Rack::WebProfiler)
16
7
 
17
- ::Rack::WebProfiler.register_collector [
8
+ ::Rack::WebProfiler.reset_collectors!
9
+
10
+ ::Rack::WebProfiler.register_collectors [
11
+ ::Rack::WebProfiler::Collectors::RubyCollector,
12
+ ::Rack::WebProfiler::Collectors::TimeCollector,
18
13
  Rails::WebProfiler::Collectors::ActionViewCollector,
19
14
  Rails::WebProfiler::Collectors::ActiveRecordCollector,
20
15
  Rails::WebProfiler::Collectors::RailsCollector,
@@ -24,6 +19,18 @@ module Rails
24
19
  # Subscrine all Rails notifications.
25
20
  handler = Rails::WebProfiler::NotificationHandler.new
26
21
  ActiveSupport::Notifications.subscribe(/.+/, handler)
22
+
23
+ c = ::Rack::WebProfiler.config
24
+
25
+ c.tmp_dir = ::File.expand_path(::File.join(Rails.root, "tmp"), __FILE__)
26
+
27
+ @already_initialized = true
28
+ end
29
+
30
+ class Railtie < ::Rails::Railtie # :nodoc:
31
+ initializer "rails-webprofiler.configure_rails_initialization" do |app|
32
+ Rails::WebProfiler.initialize!(app)
33
+ end
27
34
  end
28
35
  end
29
36
  end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  class WebProfiler
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  spec.add_dependency "rails", ">= 5.0.0"
34
- spec.add_dependency "rack-webprofiler", "~> 0.1.0"
34
+ spec.add_dependency "rack-webprofiler", "~> 0.1.3"
35
35
 
36
36
  spec.add_development_dependency "bundler", "~> 1.12"
37
37
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-webprofiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Brousse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-17 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: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.0
33
+ version: 0.1.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.0
40
+ version: 0.1.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.5.2
124
+ rubygems_version: 2.6.8
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: A web profiler for Rails applications.