dev_toolbar 0.1.0 → 1.0.0

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
  SHA256:
3
- metadata.gz: 1aef5cd3c0aa26e81bb29134d3700bbafe9addc215bc03a8baaf844ca0de43c6
4
- data.tar.gz: 471568a19e42b41835ccb82016d618f699dba0f9aa86be361ddc93b360b4e621
3
+ metadata.gz: ae8544fc0deb66a6da156b87729c736b2ea98651f3eb16ba1f236b0fdb10e3f9
4
+ data.tar.gz: 34880d9149ff1891f3945535568540a3a197b2a5053c4bbff950bc2648c332fd
5
5
  SHA512:
6
- metadata.gz: 7db6621b788076edaa4772437fe4e9820716fed9693aac4b93db45683435a8c7c9b8bbcc138396a3ea6803eb45d4790d0259ff815a4f37f913fdf1eb50b9f576
7
- data.tar.gz: f138d77ff57066f90a5a1095b2e36d32b9e9d68ab7526a1ccb6396c95e3b3998782d133f549ce4fa7727e79ca227816ac8fce202312863cb4f9682b33fcfe03f
6
+ metadata.gz: 3caf66b8f84258900547d13aa0381375241c13b1de0b0ba8a8a733df8ae4c98f98a49fe66bfff1bb6a482d03a0ce067f744e955879b0cbaa1c4877ae1d11b145
7
+ data.tar.gz: ee2fc25df5ac895cc2b6a56f5e43eaa6beeb77c3a2df92624a955bfdbaf8cf8b3d9aea019647beabce6a9af428849102d56200528b31abb1117acddb9db433cd
@@ -0,0 +1,9 @@
1
+ module DevToolbar
2
+ class Configuration
3
+ attr_accessor :links
4
+
5
+ def initialize
6
+ @links = []
7
+ end
8
+ end
9
+ end
@@ -5,37 +5,47 @@ module DevToolbar
5
5
  end
6
6
 
7
7
  def call(env)
8
- request = Rack::Request.new(env)
9
- @ip = request.ip
10
- @app.call(env)
11
- rescue Exception => ex
12
- if pass_through?
13
- @app.call(env)
14
- else
15
- [200, {"Content-Type" => "text/html"}, [error_message]]
16
- end
17
- end
8
+ status, headers, response = @app.call(env)
18
9
 
19
- def pass_through?
20
- path = Rails.root.join('whitelist.yml')
21
- if File.exist?(path)
22
- whitelisted_ips = YAML.load_file(path)
23
- whitelisted_ips.include?(@ip)
24
- else
25
- true
26
- end
27
- end
10
+ if Rails.env.development? && headers["Content-Type"]&.include?("text/html")
11
+ response_body = response.body
12
+ toolbar_html = <<-HTML
13
+ <div id="dev-toolbar">
14
+ #{toolbar_links}
15
+ </div>
16
+ <style>
17
+ #dev-toolbar {
18
+ position: fixed;
19
+ right: 0;
20
+ top: 0;
21
+ background: #333;
22
+ color: #fff;
23
+ padding: 0.5rem;
24
+ z-index: 1000;
25
+ }
28
26
 
29
- def error_message
30
- <<-HTML
31
- <h1>Uh oh! You've got an error in your code.</h1>
27
+ #dev-toolbar a {
28
+ color: #fff;
29
+ margin-right: 0.5rem;
30
+ }
31
+ </style>
32
+ HTML
32
33
 
33
- <h2>To get a more helpful error page, please run this command at a terminal prompt:</h2>
34
+ response_body.sub!('</body>', "#{toolbar_html}</body>")
35
+ headers["Content-Length"] = response_body.bytesize.to_s
36
+
37
+ response = [response_body]
38
+ end
39
+
40
+ [status, headers, response]
41
+ end
34
42
 
35
- <pre style="font-size: 4em;"><code>bin/whitelist #{@ip}</code></pre>
43
+ private
36
44
 
37
- <h2>and then restart your server.</h2>
38
- HTML
45
+ def toolbar_links
46
+ DevToolbar.configuration.links.map do |link|
47
+ "<a href='#{link[:path]}' target='_blank'>#{link[:name]}</a>"
48
+ end.join(' ')
39
49
  end
40
50
  end
41
51
  end
@@ -0,0 +1,7 @@
1
+ module DevToolbar
2
+ class Railtie < Rails::Railtie
3
+ initializer "dev_toolbar.middleware" do |app|
4
+ app.middleware.use DevToolbar::Middleware if Rails.env.development?
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DevToolbar
2
- VERSION = '0.1.0'
4
+ VERSION = "1.0.0"
3
5
  end
data/lib/dev_toolbar.rb CHANGED
@@ -1,6 +1,19 @@
1
- require "dev_toolbar/engine"
2
- require "dev_toolbar/middleware"
3
- require "dev_toolbar/debug_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "dev_toolbar/version"
4
+ require_relative "dev_toolbar/railtie"
5
+ require_relative "dev_toolbar/middleware"
6
+ require_relative "dev_toolbar/configuration"
7
+
4
8
  module DevToolbar
5
- # Your code goes here...
9
+ class Error < StandardError; end
10
+
11
+ class << self
12
+ attr_accessor :configuration
13
+
14
+ def configure
15
+ self.configuration ||= Configuration.new
16
+ yield(configuration)
17
+ end
18
+ end
6
19
  end
metadata CHANGED
@@ -1,65 +1,76 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_toolbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Murugan
8
- autorequire:
9
- bindir: bin
7
+ - Ben Purinton
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '7.0'
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
- version: '0'
26
+ version: '7.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: better_errors
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ">="
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
41
- description: Firstdraft Dev Toolbar
54
+ version: '13.0'
55
+ description: A sticky toolbar for Rails applications in development mode
42
56
  email:
43
- - murugan@firstdraft.com
57
+ - ben@firstdraft.com
44
58
  executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
- - MIT-LICENSE
49
- - README.md
50
- - Rakefile
51
- - app/assets/stylesheets/dev_toolbar/dev_toolbar.scss
52
- - app/views/shared/_dev_tools.html.erb
53
62
  - lib/dev_toolbar.rb
54
- - lib/dev_toolbar/debug_helper.rb
55
- - lib/dev_toolbar/engine.rb
63
+ - lib/dev_toolbar/configuration.rb
56
64
  - lib/dev_toolbar/middleware.rb
65
+ - lib/dev_toolbar/railtie.rb
57
66
  - lib/dev_toolbar/version.rb
58
67
  homepage: https://github.com/firstdraft
59
68
  licenses:
60
69
  - MIT
61
- metadata: {}
62
- post_install_message:
70
+ metadata:
71
+ homepage_uri: https://github.com/firstdraft
72
+ source_code_uri: https://github.com/firstdraft/dev_toolbar
73
+ post_install_message:
63
74
  rdoc_options: []
64
75
  require_paths:
65
76
  - lib
@@ -67,16 +78,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
78
  requirements:
68
79
  - - ">="
69
80
  - !ruby/object:Gem::Version
70
- version: '0'
81
+ version: 2.6.0
71
82
  required_rubygems_version: !ruby/object:Gem::Requirement
72
83
  requirements:
73
84
  - - ">="
74
85
  - !ruby/object:Gem::Version
75
86
  version: '0'
76
87
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.7.8
79
- signing_key:
88
+ rubygems_version: 3.4.6
89
+ signing_key:
80
90
  specification_version: 4
81
- summary: Debug helper
91
+ summary: A development toolbar for Rails applications.
82
92
  test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2017 Firstdraft
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,16 +0,0 @@
1
- # DevToolbar
2
- Firstdraft Dev Toolbar for cloud9 integration with better errors and web-console..etc..,
3
-
4
- ## Installation
5
- Add this line to your application's Gemfile:
6
-
7
- ```ruby
8
- group :development do
9
- gem 'dev_toolbar', git: 'https://github.com/firstdraft/dev_toolbar.git'
10
- end
11
- ```
12
-
13
- And then execute:
14
- ```bash
15
- $ bundle
16
- ```
data/Rakefile DELETED
@@ -1,36 +0,0 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
6
-
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'DevToolbar'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
- load 'rails/tasks/engine.rake'
19
-
20
-
21
- load 'rails/tasks/statistics.rake'
22
-
23
-
24
-
25
- require 'bundler/gem_tasks'
26
-
27
- require 'rake/testtask'
28
-
29
- Rake::TestTask.new(:test) do |t|
30
- t.libs << 'test'
31
- t.pattern = 'test/**/*_test.rb'
32
- t.verbose = false
33
- end
34
-
35
-
36
- task default: :test
@@ -1,76 +0,0 @@
1
- .dev_toolbar {
2
- box-sizing: border-box;
3
- position:fixed;
4
- height: 40px;
5
- right:-40px;
6
- top:45%;
7
- transform:rotate(-90deg);
8
- -webkit-transform:rotate(-90deg);
9
- -ms-transform:rotate(-90deg);
10
- -moz-transform:rotate(-90deg);
11
- z-index:999;
12
-
13
- .btn {
14
- font-family: Georgia;
15
- text-decoration: none;
16
- display: inline-block;
17
- font-weight: normal;
18
- text-align: center;
19
- white-space: nowrap;
20
- vertical-align: middle;
21
- -webkit-user-select: none;
22
- -moz-user-select: none;
23
- -ms-user-select: none;
24
- user-select: none;
25
- border: 1px solid transparent;
26
- padding: 0.5rem 0.75rem;
27
- font-size: 1rem;
28
- line-height: 1.25;
29
- border-radius: 0.25rem;
30
- transition: all 0.15s ease-in-out;
31
- }
32
-
33
- .btn:focus, .btn.focus {
34
- outline: 0;
35
- box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
36
- }
37
-
38
- .btn-outline-secondary {
39
- color: #868e96;
40
- background-color: transparent;
41
- background-image: none;
42
- border-color: #868e96;
43
- }
44
-
45
- .btn-outline-secondary:hover {
46
- color: #fff;
47
- background-color: #868e96;
48
- border-color: #868e96;
49
- }
50
-
51
- .btn-outline-secondary:focus, .btn-outline-secondary.focus {
52
- box-shadow: 0 0 0 3px rgba(134, 142, 150, 0.5);
53
- }
54
-
55
- .btn-outline-secondary:active {
56
- color: #fff;
57
- background-color: #868e96;
58
- border-color: #868e96;
59
- }
60
- }
61
-
62
- .footer {
63
- position: absolute;
64
- right: 0;
65
- bottom: 0;
66
- left: 0;
67
- padding: 1rem;
68
- text-align: center;
69
- }
70
-
71
- .alert-info {
72
- color: #31708f;
73
- background-color: #d9edf7;
74
- border-color: #bce8f1;
75
- }
76
-
@@ -1,11 +0,0 @@
1
- <%= stylesheet_link_tag "dev_toolbar" %>
2
- <div class="dev_toolbar">
3
- <% if defined?(WebGit) %>
4
- <%= link_to "Git", "/git", class: "dev_tools_button btn btn-outline-secondary" %>
5
- <% end %>
6
-
7
- <% if defined?(ActiveAdmin) %>
8
- <%= link_to "Admin", "/admin", class: "dev_tools_button btn btn-outline-secondary" %>
9
- <% end %>
10
- <%= link_to "Routes", "/rails/info", class: "dev_tools_button btn btn-outline-secondary" %>
11
- </div>
@@ -1,10 +0,0 @@
1
- module DevToolbar
2
- module DebugHelper
3
-
4
- def dev_tools
5
- if Rails.env.development?
6
- render "shared/dev_tools"
7
- end
8
- end
9
- end
10
- end
@@ -1,49 +0,0 @@
1
- module DevToolbar
2
- class Engine < ::Rails::Engine
3
- isolate_namespace DevToolbar
4
-
5
- initializer "dev_toolbar.configure_rails_initialization" do |app|
6
- if enable?
7
- insert_middleware
8
- end
9
- end
10
-
11
- initializer "dev_toolbar.assets" do |app|
12
- Rails.application.config.assets.precompile += %w{ dev_toolbar }
13
- Rails.application.config.assets.paths << root.join("app", "assets", "stylesheets", "dev_toolbar")
14
- end
15
-
16
- initializer 'dev_toolbar.action_controller' do |app|
17
- ActiveSupport.on_load :action_controller do
18
- helper DevToolbar::DebugHelper
19
- end
20
- end
21
-
22
- config.after_initialize do
23
- path = Rails.root.join('whitelist.yml')
24
- if File.exist?(path)
25
- whitelisted_ips = YAML.load_file(path)
26
- whitelisted_ips.each do |ip|
27
- BetterErrors::Middleware.allow_ip!(ip)
28
- end
29
- end
30
- end
31
-
32
- def insert_middleware
33
- if defined? BetterErrors::Middleware
34
- app.middleware.insert_after BetterErrors::Middleware, DevToolbar::Middleware
35
- else
36
- app.middleware.use DevToolbar::Middleware
37
- end
38
- end
39
-
40
-
41
- def enable?
42
- !Rails.env.production? and app.config.consider_all_requests_local
43
- end
44
-
45
- def app
46
- Rails.application
47
- end
48
- end
49
- end