rack-webprofiler 0.1.0.pre.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +27 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +34 -0
  6. data/.rubocop_todo.yml +0 -0
  7. data/.travis.yml +23 -0
  8. data/CHANGELOG.md +39 -0
  9. data/CODE_OF_CONDUCT.md +74 -0
  10. data/Gemfile +15 -0
  11. data/LICENSE +21 -0
  12. data/README.md +94 -0
  13. data/Rakefile +17 -0
  14. data/bin/ci-prepare +16 -0
  15. data/bin/console +10 -0
  16. data/bin/setup +8 -0
  17. data/examples/README.md +56 -0
  18. data/examples/rack/config.ru +52 -0
  19. data/examples/sinatra/app.rb +37 -0
  20. data/examples/sinatra/config.ru +3 -0
  21. data/lib/rack/templates/404.erb +1 -0
  22. data/lib/rack/templates/assets/rwpt.css +9 -0
  23. data/lib/rack/templates/assets/rwpt.js +0 -0
  24. data/lib/rack/templates/async.erb +120 -0
  25. data/lib/rack/templates/panel/index.erb +29 -0
  26. data/lib/rack/templates/panel/layout.erb +17 -0
  27. data/lib/rack/templates/panel/show.erb +19 -0
  28. data/lib/rack/templates/profiler.erb +70 -0
  29. data/lib/rack/web_profiler/auto_configure/rails.rb +12 -0
  30. data/lib/rack/web_profiler/collector/debug_collector.rb +31 -0
  31. data/lib/rack/web_profiler/collector/erb_collector.rb +0 -0
  32. data/lib/rack/web_profiler/collector/performance_collector.rb +1 -0
  33. data/lib/rack/web_profiler/collector/rack/rack_collector.rb +23 -0
  34. data/lib/rack/web_profiler/collector/rack/request_collector.rb +33 -0
  35. data/lib/rack/web_profiler/collector/rails/active_record_collector.rb +25 -0
  36. data/lib/rack/web_profiler/collector/rails/logger_collector.rb +22 -0
  37. data/lib/rack/web_profiler/collector/rails/rails_collector.rb +25 -0
  38. data/lib/rack/web_profiler/collector/rails/request_collector.rb +50 -0
  39. data/lib/rack/web_profiler/collector/ruby_collector.rb +46 -0
  40. data/lib/rack/web_profiler/collector/sinatra/request_collector.rb +38 -0
  41. data/lib/rack/web_profiler/collector/sinatra/sinatra_collector.rb +25 -0
  42. data/lib/rack/web_profiler/collector/time_collector.rb +23 -0
  43. data/lib/rack/web_profiler/collector.rb +142 -0
  44. data/lib/rack/web_profiler/collectors.rb +88 -0
  45. data/lib/rack/web_profiler/config.rb +61 -0
  46. data/lib/rack/web_profiler/controller.rb +125 -0
  47. data/lib/rack/web_profiler/engine.rb +109 -0
  48. data/lib/rack/web_profiler/erb.rb +9 -0
  49. data/lib/rack/web_profiler/model/collection_record.rb +45 -0
  50. data/lib/rack/web_profiler/model.rb +35 -0
  51. data/lib/rack/web_profiler/request.rb +14 -0
  52. data/lib/rack/web_profiler/router.rb +71 -0
  53. data/lib/rack/web_profiler/version.rb +5 -0
  54. data/lib/rack/web_profiler.rb +70 -0
  55. data/lib/rack/webprofiler.rb +1 -0
  56. data/rack-webprofiler.gemspec +38 -0
  57. metadata +198 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4e53fe35fbf1ec6a915d0374a19f1906099038b1
4
+ data.tar.gz: 5d4e24c3922f21f2ab2729c76ab2773d23c5139d
5
+ SHA512:
6
+ metadata.gz: 6fe6001ef5e408dd90112981ef35a71767df331c4050493cbe9cd0e047e3f263f398e75d1f4461215eee7a701602e7ee534ef886bdf88bdb1cb896516f696d32
7
+ data.tar.gz: 20a4c13c4861a4a025b3b09b3a8889d18b7cf98665e3caa530575658cdc2d8e279416ebb185d14194c4ae1fdee55a7de1fd605cc7335aa0e6993f58485623f63
data/.editorconfig ADDED
@@ -0,0 +1,27 @@
1
+ ; top-most EditorConfig file
2
+ root = true
3
+
4
+ ; Unix-style newlines
5
+ [*]
6
+ end_of_line = LF
7
+ indent_style = space
8
+ indent_size = 2
9
+ charset = utf-8
10
+ trim_trailing_whitespace = true
11
+ insert_final_newline = true
12
+
13
+ [*.rb]
14
+ indent_style = space
15
+ indent_size = 2
16
+
17
+ [{*.css,*.scss}]
18
+ indent_style = space
19
+ ident_size = 4
20
+
21
+ [*.js]
22
+ indent_style = space
23
+ ident_size = 2
24
+
25
+ [*.yml]
26
+ indent_style = space
27
+ indent_size = 2
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /examples/*/tmp/
11
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,34 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+
3
+ inherit_from: .rubocop_todo.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 1.9
7
+ Exclude:
8
+ - 'examples/**/*'
9
+ # - 'tmp/**/*'
10
+
11
+ Style/StringLiterals:
12
+ EnforcedStyle: double_quotes
13
+
14
+ Style/StringLiteralsInInterpolation:
15
+ EnforcedStyle: double_quotes
16
+
17
+ Style/IfUnlessModifier:
18
+ MaxLineLength: 120
19
+
20
+ Style/WhileUntilModifier:
21
+ MaxLineLength: 120
22
+
23
+ Metrics/LineLength:
24
+ Max: 120
25
+
26
+ Style/TrailingCommaInLiteral:
27
+ EnforcedStyleForMultiline: comma
28
+
29
+ Style/AlignHash:
30
+ EnforcedHashRocketStyle: table
31
+ EnforcedColonStyle: table
32
+
33
+ # Style/IndentArray:
34
+ # EnforcedStyle: align_brackets
data/.rubocop_todo.yml ADDED
File without changes
data/.travis.yml ADDED
@@ -0,0 +1,23 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+
6
+ install:
7
+ - bin/ci-prepare
8
+
9
+ script:
10
+ - time bundle exec rake spec
11
+ - bundle exec bundle-audit update
12
+ - bundle exec bundle-audit check
13
+
14
+ notifications:
15
+ email:
16
+ on_success: change
17
+ on_failure: always
18
+ webhooks:
19
+ urls:
20
+ - secure: X0uF0lUgFuKAPxNWL26+RsP8SYcuxLdRwopuMpkxc0qdP972IrgVLpKnbi02zsnt7IK0LCSiknj3uV6X1aqiRPAeZwOLEScEttuA50qnth3spVFc0UmYRvs9H6OdE2ylc3iBlavptP4TJytJQiPAyfzl8DeLvkTZesPEf5Jkiw+WmGWk+al4zt8Ejq9+vHsYbBk4ty/GzVP5FgruEpmtQG3TibVo5aKRmgvJc6c+HZHkefXBGZwhmhoQpvH3rRUXp/c7c/3K1QJTI0LzO+AAjl5Jh3qP5U5JhblmCaVqFKp0eD7jhym/lTyWSodPDdZ+JoDV8S7EJhoWjMtlW5c1Q9hooax/mjCwmApGXhrMaPPqmlU6l0Io1TYV8f4MLus0WXDf2O62AFe4uD4NvrFAS1tEPx6fEJd8X9chE96h03S+SxM3Ol3d++n6latb3H9dWTN0QM0miOmwdUUKSK6iOMuiFOp1cZoM+AbvyQvMhqAHvZ3SVeL3FCRpqFt7UpFTmVaBmtxSWlByU4raD1yK6LLfJxcPoOWZg2XoqZ5OAu1GWtdE5Xgr9jnnDojMMOlpcCpIydBbhdTe6e/qsg+iVA4HBwxuiKIYbL4mXBXoTcdgwpD/mufaM9NLmJsc9WqO3n+rIkxB+msYgR6lw5Brw0ofCBm7Yw2AL+cZqXs8DzY=
21
+ on_success: always
22
+ on_failure: always
23
+ on_start: never
data/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ ## Unplanned
4
+
5
+ ### Features
6
+
7
+ * Create a collector to show informations about CPU usage.
8
+ * Create a collector to list all `.inspect` method calls.
9
+ * Create a collector to list the HTTP calls.
10
+ * Create a collector for Devise gem.
11
+ * Create a collector for ActiveRecord.
12
+ * Create a collector for Sequel.
13
+ * Create a collector for SQL requests without ActiveRecord.
14
+ * Create a collector to show the Rails logger informations.
15
+ * Create a collector to list jobs created with ActiveJob.
16
+ * Create a collector to list the ajax requests.
17
+ * Have a friendly UI.
18
+ * Catch 500 or exceptions.
19
+
20
+
21
+ ## v0.2.0
22
+
23
+ ### Features
24
+
25
+ * Create a Rails request collector.
26
+ * Create a collector to show which Rails version it is used and the current environment.
27
+
28
+
29
+ ## v0.1.0 (WIP)
30
+
31
+ ### Features
32
+
33
+ * Web toolbar injected into text/html responses.
34
+ * Have a panel who list all the request stored into the profiler and show more informations than the toolbar.
35
+ * Provide a nice DSL for collector to allow adding a new collector easily.
36
+ * Create a execution time collector.
37
+ * Create a collector to show which version of ruby it is used.
38
+ * Create a collector to show the Rack request informations.
39
+ * Create a collector to show the Sinatra request informations.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at pro@nicolas-brousse.fr. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rack-webprofiler.gemspec
4
+ gemspec
5
+
6
+ gem "sinatra"
7
+ gem "simplecov", require: false
8
+ gem "rubocop", "~> 0.38.0", require: false
9
+ gem "bundler-audit"
10
+ gem "flog"
11
+ gem "flay"
12
+ gem "ruby2ruby"
13
+ gem "yard"
14
+ gem "shotgun"
15
+ gem "pry"
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nicolas Brousse
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # Rack WebProfiler
2
+
3
+ A Rack profiler for web application.
4
+
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/nicolas-brousse/rack-webprofiler/master.svg) ](https://travis-ci.org/nicolas-brousse/rack-webprofiler)
7
+ [![Gitter ](https://img.shields.io/gitter/room/nicolas-brousse/rack-webprofiler.svg) ](https://gitter.im/nicolas-brousse/rack-webprofiler)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'rack-webprofiler'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install rack-webprofiler
24
+
25
+ ### Rack
26
+
27
+ ```ruby
28
+ home = lambda { |_env|
29
+ [200, { "Content-Type" => "text/html" }, ["<html><body>Hello world!</body></html>"]]
30
+ }
31
+
32
+ builder = Rack::Builder.new do
33
+ use Rack::WebProfiler
34
+
35
+ map('/') { run home }
36
+ end
37
+
38
+ run builder
39
+ ```
40
+
41
+ ### Sinatra
42
+
43
+ ```ruby
44
+ require "rack-webprofiler"
45
+
46
+ class App < Sinatra::Base
47
+ use Rack::WebProfiler
48
+ end
49
+ ```
50
+
51
+ ### Rails
52
+
53
+ The WebProfiler is automatically enabled.
54
+
55
+
56
+ ## Configuration
57
+
58
+ You can specify the temporary directory. It is used to save the SQlite database.
59
+
60
+ ```ruby
61
+ use Rack::WebProfiler, tmp_dir: File.expand_path("/tmp", __FILE__)
62
+ ```
63
+
64
+ ## Usage
65
+
66
+ TODO
67
+
68
+ HTTP headers `X-RackWebProfiler-Token` `X-RackWebProfiler-Url`.
69
+
70
+
71
+ ## Examples
72
+
73
+ See [the examples](./examples).
74
+
75
+ ## Development
76
+
77
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
78
+
79
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
80
+
81
+ ## Contributing
82
+
83
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nicolas-brousse/rack-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.
84
+
85
+ ## License
86
+
87
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
88
+
89
+ ## Alternatives & comments
90
+
91
+ * https://github.com/MiniProfiler/rack-mini-profiler
92
+ * https://github.com/dawanda/rack-profiler
93
+
94
+ This project is in part inspired by the [Symfony WebProfiler Bundle](https://github.com/symfony/web-profiler-bundle).
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require "bundler/gem_tasks"
2
+ require "rubocop/rake_task"
3
+ require "rspec/core/rake_task"
4
+ require "yard"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ YARD::Rake::YardocTask.new do |t|
9
+ t.files = ["lib/**/*.rb"]
10
+ t.stats_options = ["--list-undoc"]
11
+ end
12
+
13
+ RuboCop::RakeTask.new do
14
+ # task.requires << "rubocop-rspec"
15
+ end
16
+
17
+ task default: :spec
data/bin/ci-prepare ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler --no-ri --no-rdoc
4
+
5
+ echo ''
6
+ echo '------------------------------------------------------------------------------------------'
7
+ echo "Shell: $SHELL"
8
+ echo "PATH: $PATH"
9
+ echo "Ruby path: $(which ruby)"
10
+ echo "Ruby version: $(ruby -v)"
11
+ echo "Bundler path: $(which bundle)"
12
+ echo "Bundler version: $(bundle -v)"
13
+ echo '------------------------------------------------------------------------------------------'
14
+ echo ''
15
+
16
+ bundle install --retry=3 --jobs $(($(nproc) + 1)) "${FLAGS[@]}"
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rack/webprofiler"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,56 @@
1
+ # Examples
2
+
3
+ ```shell
4
+ $ rackup rack/config.ru
5
+ $ rackup sinatra/config.ru
6
+ ```
7
+
8
+
9
+ # How to create a custom collector
10
+
11
+ ## What is a collector
12
+
13
+ A collector is a class who permit retrieve profiler data. And also create a tab and show content into the toolbar.
14
+
15
+ ## The class
16
+
17
+ ```ruby
18
+ class MyCustomCollector
19
+ include Rack::WebProfiler::Collector::DSL
20
+
21
+ collector_name "my_collector" # Technical name of the collector.
22
+ icon "" # Base64 encoded image for the icon collector.
23
+ position 0 # Position of the collector in the toolbar.
24
+
25
+ # Retrieve the env, the request and the response
26
+ # to collect the needed information. Then save datas
27
+ # and show them in the profiler toolbar and panel.
28
+ collect do |env, request, response|
29
+ store :version, MyApp::VERSION
30
+ store :list, ["value1", "value2"]
31
+ end
32
+
33
+ # The path of the collector template.
34
+ # May be with some options to know if we show the collector
35
+ # on tab and/or panel.
36
+ template "../path/to/template.erb"
37
+ # Or
38
+ # template __FILE__, type: :DATA
39
+
40
+ # To know if the collector must be enabled.
41
+ # Usefull to load collector only if a gem is installed.
42
+ is_enabled? -> { defined? MyApp }
43
+ end
44
+ ```
45
+
46
+ And you have to register it
47
+
48
+ ```ruby
49
+ Rack::WebProfiler.register_collector MyCustomCollector
50
+ ```
51
+
52
+ You could also unregister a collector
53
+
54
+ ```ruby
55
+ Rack::WebProfiler.unregister_collector MyCustomCollector
56
+ ```
@@ -0,0 +1,52 @@
1
+ require "bundler/setup"
2
+ require "rack/webprofiler"
3
+ require "rack"
4
+
5
+ # An example of a custom collector.
6
+ #
7
+ # module MyCollector
8
+ # class Profiler::Collector::TimeCollector
9
+ # include Rack::WebProfiler::Collector::DSL
10
+ #
11
+ # icon ""
12
+ #
13
+ # collector_name "my_collector"
14
+ # position 2
15
+ #
16
+ # collect do |request, response|
17
+ # store :runtime, request.runtime
18
+ # end
19
+ #
20
+ # template "
21
+ # <% content_for :tab do %>
22
+ # <%= data[:runtime] %>
23
+ # <% end %>
24
+ # "
25
+ # end
26
+ # end
27
+
28
+ home = lambda { |_env|
29
+ [200, { "Content-Type" => "text/html" }, [<<-'HTML'
30
+ <!DOCTYPE html>
31
+ <html>
32
+ <head>
33
+ <meta charset="UTF-8">
34
+ <title>Rack WebProfiler test</title>
35
+ </head>
36
+
37
+ <body>
38
+ <p>Hello world!</p>
39
+ </body>
40
+ </html>
41
+ HTML
42
+ ]]
43
+ }
44
+
45
+ builder = Rack::Builder.new do
46
+ use Rack::WebProfiler, tmp_dir: File.expand_path("../tmp", __FILE__)
47
+ use Rack::ShowExceptions
48
+
49
+ map('/') { run home }
50
+ end
51
+
52
+ run builder
@@ -0,0 +1,37 @@
1
+ require "bundler/setup"
2
+ require "rack/webprofiler"
3
+ require "rack"
4
+ require "sinatra"
5
+
6
+ class App < Sinatra::Base
7
+ use Rack::WebProfiler, tmp_dir: File.expand_path("../tmp", __FILE__)
8
+
9
+ get "/" do
10
+ erb "Hello World!", layout: TEMPLATE
11
+ end
12
+
13
+ get "/without_profiler" do
14
+ erb "Hello World!"
15
+ end
16
+
17
+ get "/500" do
18
+ "Hello World!" if hello == world
19
+ erb ""
20
+ end
21
+
22
+ TEMPLATE = <<-HTML
23
+ <html>
24
+ <head>
25
+ <title>Rack WebProfiler test — Sinatra</title>
26
+ </head>
27
+ <body>
28
+ <p>
29
+ <a href="./">text/html page</a>
30
+ - <a href="./without_profiler">text/plain page</a>
31
+ - <a href="./500">500 page</a>
32
+ </p>
33
+ <%= yield %>
34
+ </body>
35
+ </html>
36
+ HTML
37
+ end
@@ -0,0 +1,3 @@
1
+ require File.expand_path("../app.rb", __FILE__)
2
+
3
+ run App
@@ -0,0 +1 @@
1
+ 404
@@ -0,0 +1,9 @@
1
+ /*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */img,legend{border:0}legend,td,th{padding:0}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,optgroup,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre,textarea{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}table{border-collapse:collapse;border-spacing:0}
2
+
3
+ #rack-webprofiler {
4
+ top: 0;
5
+ }
6
+
7
+ body {
8
+ margin-top: 50px;
9
+ }
File without changes