rack-webprofiler 0.1.0.pre.beta2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +36 -12
  3. data/README.md +16 -12
  4. data/docs/DSL.md +152 -0
  5. data/docs/GettingStarted.md +51 -0
  6. data/docs/README.md +6 -0
  7. data/lib/rack/templates/assets/css/profiler.css +1 -1
  8. data/lib/rack/templates/assets/css/rwpt.css +1 -1
  9. data/lib/rack/templates/assets/sass/_variables.scss +21 -2
  10. data/lib/rack/templates/assets/sass/profiler.scss +73 -61
  11. data/lib/rack/templates/assets/sass/rwpt.scss +2 -2
  12. data/lib/rack/templates/panel/show.erb +4 -4
  13. data/lib/rack/templates/profiler.erb +4 -0
  14. data/lib/rack/web_profiler/collector.rb +197 -125
  15. data/lib/rack/web_profiler/collectors/rack_collector.rb +74 -0
  16. data/lib/rack/web_profiler/{collector/rack → collectors}/request_collector.rb +43 -60
  17. data/lib/rack/web_profiler/{collector → collectors}/ruby_collector.rb +4 -3
  18. data/lib/rack/web_profiler/{collector → collectors}/time_collector.rb +12 -6
  19. data/lib/rack/web_profiler/collectors.rb +21 -27
  20. data/lib/rack/web_profiler/config.rb +4 -9
  21. data/lib/rack/web_profiler/controller.rb +131 -126
  22. data/lib/rack/web_profiler/engine.rb +10 -14
  23. data/lib/rack/web_profiler/model.rb +74 -23
  24. data/lib/rack/web_profiler/request.rb +22 -7
  25. data/lib/rack/web_profiler/response.rb +27 -0
  26. data/lib/rack/web_profiler/rouge/html_formatter.rb +25 -0
  27. data/lib/rack/web_profiler/router.rb +11 -6
  28. data/lib/rack/web_profiler/version.rb +1 -1
  29. data/lib/rack/web_profiler/view.rb +255 -139
  30. data/lib/rack/web_profiler.rb +47 -4
  31. data/rack-webprofiler.gemspec +1 -3
  32. metadata +32 -32
  33. data/lib/rack/web_profiler/collector/debug_collector.rb +0 -31
  34. data/lib/rack/web_profiler/collector/erb_collector.rb +0 -0
  35. data/lib/rack/web_profiler/collector/performance_collector.rb +0 -1
  36. data/lib/rack/web_profiler/collector/rack/rack_collector.rb +0 -23
  37. data/lib/rack/web_profiler/collector/view.rb +0 -44
  38. data/lib/rack/web_profiler/model/collection_record.rb +0 -46
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["pro@nicolas-brousse.fr"]
11
11
 
12
12
  spec.summary = %q{A Rack profiler for web applications.}
13
- # spec.description = %q{}
13
+ spec.description = %q{A Rack profiler for web applications.}
14
14
  spec.homepage = "http://github.com/nicolas-brousse/rack-webprofiler"
15
15
  spec.license = "MIT"
16
16
 
@@ -28,8 +28,6 @@ Gem::Specification.new do |spec|
28
28
  || f.match(%r{^(\..*)$})
29
29
  end
30
30
 
31
- spec.bindir = "exe"
32
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
31
  spec.require_paths = ["lib"]
34
32
 
35
33
  spec.add_dependency "rack", ">= 1.6.4"
metadata CHANGED
@@ -1,128 +1,128 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-webprofiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.beta2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Brousse
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.6.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.6.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: docile
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.1'
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
40
  version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sequel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.3'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rouge
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.11'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.11'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '10.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '10.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '3.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.0'
125
- description:
125
+ description: A Rack profiler for web applications.
126
126
  email:
127
127
  - pro@nicolas-brousse.fr
128
128
  executables: []
@@ -133,6 +133,9 @@ files:
133
133
  - CODE_OF_CONDUCT.md
134
134
  - LICENSE
135
135
  - README.md
136
+ - docs/DSL.md
137
+ - docs/GettingStarted.md
138
+ - docs/README.md
136
139
  - lib/rack/templates/404.erb
137
140
  - lib/rack/templates/assets/css/profiler.css
138
141
  - lib/rack/templates/assets/css/rwpt.css
@@ -152,21 +155,18 @@ files:
152
155
  - lib/rack/templates/profiler.erb
153
156
  - lib/rack/web_profiler.rb
154
157
  - lib/rack/web_profiler/collector.rb
155
- - lib/rack/web_profiler/collector/debug_collector.rb
156
- - lib/rack/web_profiler/collector/erb_collector.rb
157
- - lib/rack/web_profiler/collector/performance_collector.rb
158
- - lib/rack/web_profiler/collector/rack/rack_collector.rb
159
- - lib/rack/web_profiler/collector/rack/request_collector.rb
160
- - lib/rack/web_profiler/collector/ruby_collector.rb
161
- - lib/rack/web_profiler/collector/time_collector.rb
162
- - lib/rack/web_profiler/collector/view.rb
163
158
  - lib/rack/web_profiler/collectors.rb
159
+ - lib/rack/web_profiler/collectors/rack_collector.rb
160
+ - lib/rack/web_profiler/collectors/request_collector.rb
161
+ - lib/rack/web_profiler/collectors/ruby_collector.rb
162
+ - lib/rack/web_profiler/collectors/time_collector.rb
164
163
  - lib/rack/web_profiler/config.rb
165
164
  - lib/rack/web_profiler/controller.rb
166
165
  - lib/rack/web_profiler/engine.rb
167
166
  - lib/rack/web_profiler/model.rb
168
- - lib/rack/web_profiler/model/collection_record.rb
169
167
  - lib/rack/web_profiler/request.rb
168
+ - lib/rack/web_profiler/response.rb
169
+ - lib/rack/web_profiler/rouge/html_formatter.rb
170
170
  - lib/rack/web_profiler/router.rb
171
171
  - lib/rack/web_profiler/version.rb
172
172
  - lib/rack/web_profiler/view.rb
@@ -182,14 +182,14 @@ require_paths:
182
182
  - lib
183
183
  required_ruby_version: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ! '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - ! '>'
190
+ - - ">="
191
191
  - !ruby/object:Gem::Version
192
- version: 1.3.1
192
+ version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
195
  rubygems_version: 2.4.5
@@ -1,31 +0,0 @@
1
- module Rack
2
- class WebProfiler::Collector::DebugCollector
3
- include Rack::WebProfiler::Collector::DSL
4
-
5
- icon nil
6
-
7
- collector_name "debug"
8
- position 1
9
-
10
- collect do |request, response|
11
- store :key, "value"
12
- store :backtrace, "value"
13
- end
14
-
15
- template __FILE__, type: :DATA
16
- end
17
- end
18
-
19
- # # @see also https://gist.github.com/ubermajestix/3644301
20
- # module Object
21
- # def inspect
22
- # res = super
23
- # # save the res on collector storage
24
- # res
25
- # end
26
- # end
27
-
28
- __END__
29
- <% content_for :tab do %>
30
- <%= data[:ruby_version] %>
31
- <% end %>
File without changes
@@ -1 +0,0 @@
1
- # See: https://github.com/noahd1/oink/blob/master/lib/oink/middleware.rb#L39
@@ -1,23 +0,0 @@
1
- module Rack
2
- class WebProfiler::Collector::Rack::RackCollector
3
- include Rack::WebProfiler::Collector::DSL
4
-
5
- icon nil
6
-
7
- collector_name "rack"
8
- position 1
9
-
10
- collect do |_request, _response|
11
- store :rack_version, Rack.release
12
- end
13
-
14
- template __FILE__, type: :DATA
15
-
16
- is_enabled? -> { !defined?(Rails) && !defined?(Sinatra) }
17
- end
18
- end
19
-
20
- __END__
21
- <%# content_for :tab do %>
22
- <%= data[:rack_version] %>
23
- <%# end %>
@@ -1,44 +0,0 @@
1
- module Rack
2
- class WebProfiler::Collector::View < WebProfiler::View
3
-
4
- def context
5
- @context ||= Context.new
6
- end
7
-
8
- # Helpers
9
- module Helpers
10
-
11
- def tab_content
12
- if block_given?
13
- @tab_content ||= capture(&Proc.new)
14
- elsif !@tab_content.nil?
15
- @tab_content
16
- end
17
- end
18
-
19
- def panel_content
20
- if block_given?
21
- @panel_content ||= capture(&Proc.new)
22
- elsif !@panel_content.nil?
23
- @panel_content
24
- end
25
- end
26
-
27
- def data(k)
28
- return nil if @collection.nil?
29
-
30
- datas = @collection.datas[@collector.name.to_sym][:datas]
31
- return datas[k] if datas.has_key?(k)
32
-
33
- nil
34
- end
35
- end
36
-
37
- protected
38
-
39
- class Context
40
- include WebProfiler::View::CommonHelpers
41
- include Helpers
42
- end
43
- end
44
- end
@@ -1,46 +0,0 @@
1
- module Rack
2
- #
3
- class WebProfiler::Model::CollectionRecord < Sequel::Model(Rack::WebProfiler::Model.database)
4
- # Plugins
5
- plugin :schema
6
- plugin :hook_class_methods
7
- plugin :serialization
8
- plugin :json_serializer
9
- plugin :timestamps
10
-
11
- # Attributes:
12
- # - id
13
- # - token
14
- # - ip
15
- # - url
16
- # - http_method
17
- # - http_status
18
- # - content_type
19
- # - datas
20
- # - created_at
21
- set_schema do
22
- primary_key :id
23
-
24
- varchar :token, unique: true, empty: false
25
- varchar :url, empty: false
26
- varchar :ip, empty: false
27
- varchar :http_method, empty: false
28
- integer :http_status
29
- varchar :content_type
30
- string :datas, text: true, empty: false
31
- datetime :created_at
32
- end
33
- create_table unless table_exists?
34
-
35
- # Serialization
36
- serialize_attributes :marshal, :datas
37
-
38
- # Hooks
39
- before_create :before_create
40
-
41
- def before_create
42
- token = Time.now.to_f.to_s.delete(".").to_i
43
- self.token = token.to_s(36)
44
- end
45
- end
46
- end