web-console 4.2.0 → 4.2.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
  SHA256:
3
- metadata.gz: a491428cda19f89cf20ad5ef83558e948feecb7acb7f46b453c5644ad419131b
4
- data.tar.gz: 3e3d2902466fc03684b00591b294df2c19af06db31e43f58f1f9e8de14cb731f
3
+ metadata.gz: ed1dcd754f3147bcefa20043ba34ea374d9acac479d68e3eae7b89b3ee68994d
4
+ data.tar.gz: 7556b35cf5abd8d6438931b7d4cce3dd082483617cfeca28545d7a1bb5c83d06
5
5
  SHA512:
6
- metadata.gz: d949e602f1056bda92b2e7e13e030a78bd856befeb52ccd89c57c27a5341bab30830e27969f3fd9bf8e3d5e4467de381cb788cd9d5809ad6f5d662b2a00b3993
7
- data.tar.gz: a17229c83c77f2fdc2b06ca4d25674391e9318490da932de015d0d8ebc59bf652ccb010577eea9d95c357fcd703ba6b5fb8f2afc8343ad79306e80834f52d77d
6
+ metadata.gz: 757a0810bb51d57678f588d7f70ac3734c0a32740aa357acab67edc880701588bf703ca6e90e0e228b3ea8a6d009bd32b8b5e0d3cfb7f0569d784c69028d2c08
7
+ data.tar.gz: 7ffb4ff41a124ca94852bc043dc4e745ee43e112c4e986e83ad9296f2d97cad17f83ce05b3f9917c5b68f74741aa674ec0bd052e97b588cd822cfbdd2a315e7b
data/CHANGELOG.markdown CHANGED
@@ -1,11 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
- ## master (unreleased)
3
+ ## main (unreleased)
4
+
5
+ # 4.2.1
6
+
7
+ * Support to Rails 7.1
8
+ * Support to Rack 3.0
4
9
 
5
10
  ## 4.2.0
6
11
 
7
12
  * [#308](https://github.com/rails/web-console/pull/308) Fix web-console inline templates rendering ([@voxik])
8
- * [#306](https://github.com/rails/web-console/pull/306) Support Ruby 3.0 and above ([@ruanwood])
13
+ * [#306](https://github.com/rails/web-console/pull/306) Support Ruby 3.0 and above ([@ryanwood])
9
14
 
10
15
  ## 4.1.0
11
16
 
data/README.markdown CHANGED
@@ -1,11 +1,11 @@
1
1
  <p align=right>
2
- <strong>Current version: 4.1.0</strong> | Documentation for:
2
+ <strong>Current version: 4.2.1</strong> | Documentation for:
3
3
  <a href=https://github.com/rails/web-console/tree/v1.0.4>v1.0.4</a>
4
4
  <a href=https://github.com/rails/web-console/tree/v2.2.1>v2.2.1</a>
5
5
  <a href=https://github.com/rails/web-console/tree/v3.7.0>v3.7.0</a>
6
6
  </p>
7
7
 
8
- # Web Console [![Build Status](https://travis-ci.org/rails/web-console.svg?branch=master)](https://travis-ci.org/rails/web-console)
8
+ # Web Console [![CI](https://github.com/rails/web-console/actions/workflows/ci.yml/badge.svg)](https://github.com/rails/web-console/actions/workflows/ci.yml)
9
9
 
10
10
  _Web Console_ is a debugging tool for your Ruby on Rails applications.
11
11
 
@@ -186,7 +186,7 @@ Make sure your configuration lives in `config/environments/development.rb`.
186
186
  [Hailey Somerville]: https://github.com/haileys
187
187
  [John Mair]: https://github.com/banister
188
188
  [Charles Oliver Nutter]: https://github.com/headius
189
- [templates]: https://github.com/rails/web-console/tree/master/lib/web_console/templates
189
+ [templates]: https://github.com/rails/web-console/tree/main/lib/web_console/templates
190
190
  [rvt]: https://github.com/gsamokovarov/rvt
191
191
  [contributors]: https://github.com/rails/web-console/graphs/contributors
192
192
  [Passenger on Nginx]: https://www.phusionpassenger.com/library/config/nginx/reference/#passengerstickysessions
@@ -13,10 +13,10 @@ module WebConsole
13
13
  end
14
14
 
15
15
  def inject(content)
16
- # Set Content-Length header to the size of the current body
16
+ # Set content-length header to the size of the current body
17
17
  # + the extra content. Otherwise the response will be truncated.
18
- if @headers["Content-Length"]
19
- @headers["Content-Length"] = (@body.bytesize + content.bytesize).to_s
18
+ if @headers[Rack::CONTENT_LENGTH]
19
+ @headers[Rack::CONTENT_LENGTH] = (@body.bytesize + content.bytesize).to_s
20
20
  end
21
21
 
22
22
  [
@@ -1,8 +1,7 @@
1
1
  module WebConsole
2
2
  module Interceptor
3
- def self.call(request, exception)
3
+ def self.call(request, error)
4
4
  backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner")
5
- error = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).exception
6
5
 
7
6
  # Get the original exception if ExceptionWrapper decides to follow it.
8
7
  Thread.current[:__web_console_exception] = error
@@ -28,8 +28,8 @@ module WebConsole
28
28
  status, headers, body = call_app(env)
29
29
 
30
30
  if (session = Session.from(Thread.current)) && acceptable_content_type?(headers)
31
- headers["X-Web-Console-Session-Id"] = session.id
32
- headers["X-Web-Console-Mount-Point"] = mount_point
31
+ headers["x-web-console-session-id"] = session.id
32
+ headers["x-web-console-mount-point"] = mount_point
33
33
 
34
34
  template = Template.new(env, session)
35
35
  body, headers = Injector.new(body, headers).inject(template.render("index"))
@@ -52,12 +52,12 @@ module WebConsole
52
52
  private
53
53
 
54
54
  def acceptable_content_type?(headers)
55
- headers["Content-Type"].to_s.include?("html")
55
+ headers[Rack::CONTENT_TYPE].to_s.include?("html")
56
56
  end
57
57
 
58
58
  def json_response(opts = {})
59
59
  status = opts.fetch(:status, 200)
60
- headers = { "Content-Type" => "application/json; charset = utf-8" }
60
+ headers = { Rack::CONTENT_TYPE => "application/json; charset = utf-8" }
61
61
  body = yield.to_json
62
62
 
63
63
  [ status, headers, [ body ] ]
@@ -51,6 +51,10 @@ module WebConsole
51
51
  end
52
52
  end
53
53
 
54
+ initializer "web_console.deprecator" do |app|
55
+ app.deprecators[:web_console] = WebConsole.deprecator if app.respond_to?(:deprecators)
56
+ end
57
+
54
58
  initializer "web_console.permissions" do
55
59
  permissions = web_console_permissions
56
60
  Request.permissions = Permissions.new(permissions)
@@ -63,7 +67,7 @@ module WebConsole
63
67
  when config.web_console.allowed_ips
64
68
  config.web_console.allowed_ips
65
69
  when config.web_console.whitelisted_ips
66
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
70
+ WebConsole.deprecator.warn(<<-MSG.squish)
67
71
  The config.web_console.whitelisted_ips is deprecated and will be ignored in future release of web_console.
68
72
  Please use config.web_console.allowed_ips instead.
69
73
  MSG
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class SourceLocation
4
- def initialize(binding)
5
- @binding = binding
6
- end
3
+ module WebConsole
4
+ class SourceLocation
5
+ def initialize(binding)
6
+ @binding = binding
7
+ end
7
8
 
8
- if RUBY_VERSION >= "2.6"
9
- def path() @binding.source_location.first end
10
- def lineno() @binding.source_location.last end
11
- else
12
- def path() @binding.eval("__FILE__") end
13
- def lineno() @binding.eval("__LINE__") end
9
+ if RUBY_VERSION >= "2.6"
10
+ def path() @binding.source_location.first end
11
+ def lineno() @binding.source_location.last end
12
+ else
13
+ def path() @binding.eval("__FILE__") end
14
+ def lineno() @binding.eval("__LINE__") end
15
+ end
14
16
  end
15
17
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "net/http"
4
+
3
5
  namespace :templates do
4
6
  desc "Run tests for templates"
5
7
  task test: [ :daemonize, :npm, :rackup, :wait, :mocha, :kill, :exit ]
@@ -10,7 +12,6 @@ namespace :templates do
10
12
  runner = URI.parse("http://#{ENV['IP'] || '127.0.0.1'}:#{ENV['PORT'] || 29292}/html/test_runner.html")
11
13
  rackup = "rackup --host #{runner.host} --port #{runner.port}"
12
14
  result = nil
13
- browser = "phantomjs"
14
15
 
15
16
  def need_to_wait?(uri)
16
17
  Net::HTTP.start(uri.host, uri.port) { |http| http.get(uri.path) }
@@ -22,17 +23,10 @@ namespace :templates do
22
23
  rackup += " -D --pid #{pid}"
23
24
  end
24
25
 
25
- task npm: [ :phantomjs ] do
26
+ task :npm do
26
27
  Dir.chdir(workdir) { system "npm install --silent" }
27
28
  end
28
29
 
29
- task :phantomjs do
30
- unless system("which #{browser} >/dev/null")
31
- browser = "./node_modules/.bin/phantomjs"
32
- Dir.chdir(workdir) { system("test -f #{browser} || npm install --silent phantomjs-prebuilt") }
33
- end
34
- end
35
-
36
30
  task :rackup do
37
31
  Dir.chdir(workdir) { system rackup }
38
32
  end
@@ -43,7 +37,7 @@ namespace :templates do
43
37
  end
44
38
 
45
39
  task :mocha do
46
- Dir.chdir(workdir) { result = system("#{browser} ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js #{runner} dot") }
40
+ Dir.chdir(workdir) { result = system("npx mocha-headless-chrome -f #{runner} -r dot") }
47
41
  end
48
42
 
49
43
  task :kill do
@@ -935,8 +935,8 @@ REPLConsole.request = function request(method, url, params, callback) {
935
935
  var xhr = new REPLConsole.XMLHttpRequest();
936
936
 
937
937
  xhr.open(method, url, true);
938
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
939
- xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
938
+ xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
939
+ xhr.setRequestHeader("x-requested-with", "XMLHttpRequest");
940
940
  xhr.send(params);
941
941
 
942
942
  xhr.onreadystatechange = function() {
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "action_view"
4
+ require "action_dispatch" # This is needed to use Mime::Type
4
5
  require "web_console"
5
6
  require "web_console/testing/helper"
6
7
 
@@ -9,7 +10,7 @@ module WebConsole
9
10
  class FakeMiddleware
10
11
  I18n.load_path.concat(Dir[Helper.gem_root.join("lib/web_console/locales/*.yml")])
11
12
 
12
- DEFAULT_HEADERS = { "Content-Type" => "application/javascript" }
13
+ DEFAULT_HEADERS = { Rack::CONTENT_TYPE => "application/javascript" }
13
14
 
14
15
  def initialize(opts)
15
16
  @headers = opts.fetch(:headers, DEFAULT_HEADERS)
@@ -18,18 +19,21 @@ module WebConsole
18
19
  end
19
20
 
20
21
  def call(env)
21
- [ 200, @headers, [ render(req_path(env)) ] ]
22
+ body = render(req_path(env))
23
+ @headers[Rack::CONTENT_LENGTH] = body.bytesize.to_s
24
+
25
+ [ 200, @headers, [ body ] ]
22
26
  end
23
27
 
24
28
  def view
25
- @view = View.new(@view_path)
29
+ @view = View.with_empty_template_cache.with_view_paths(@view_path)
26
30
  end
27
31
 
28
32
  private
29
33
 
30
34
  # extract target path from REQUEST_PATH
31
35
  def req_path(env)
32
- env["REQUEST_PATH"].match(@req_path_regex)[1]
36
+ File.basename(env["REQUEST_PATH"].match(@req_path_regex)[1], ".*")
33
37
  end
34
38
 
35
39
  def render(template)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebConsole
4
- VERSION = "4.2.0"
4
+ VERSION = "4.2.1"
5
5
  end
data/lib/web_console.rb CHANGED
@@ -26,7 +26,11 @@ module WebConsole
26
26
  end
27
27
 
28
28
  def self.logger
29
- Rails.logger || (@logger ||= ActiveSupport::Logger.new($stderr))
29
+ (defined?(Rails.logger) && Rails.logger) || (@logger ||= ActiveSupport::Logger.new($stderr))
30
+ end
31
+
32
+ def self.deprecator
33
+ @deprecator ||= ActiveSupport::Deprecation.new("5.0", "WebConsole")
30
34
  end
31
35
  end
32
36
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web-console
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hailey Somerville
8
8
  - Genadi Samokovarov
9
9
  - Guillermo Iguaran
10
10
  - Ryan Dao
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-11-17 00:00:00.000000000 Z
14
+ date: 2023-09-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: railties
@@ -69,7 +69,7 @@ dependencies:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: 0.4.0
72
- description:
72
+ description:
73
73
  email:
74
74
  - hailey@hailey.lol
75
75
  - gsamokovarov@gmail.com
@@ -123,7 +123,7 @@ homepage: https://github.com/rails/web-console
123
123
  licenses:
124
124
  - MIT
125
125
  metadata: {}
126
- post_install_message:
126
+ post_install_message:
127
127
  rdoc_options: []
128
128
  require_paths:
129
129
  - lib
@@ -138,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
- rubygems_version: 3.1.6
142
- signing_key:
141
+ rubygems_version: 3.4.10
142
+ signing_key:
143
143
  specification_version: 4
144
144
  summary: A debugging tool for your Ruby on Rails applications.
145
145
  test_files: []