web-console 3.5.1 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8a1cf82ab4c1380c5d85d7cdbda8b48d8ef0d7e4
4
- data.tar.gz: 15b623e433d5101d376444ad1122b00282fc3fa6
2
+ SHA256:
3
+ metadata.gz: bb1461a9213387e0c8158f62623d63b0ecff23c0cc6ccd91433ab203eec3eb8b
4
+ data.tar.gz: 45336b5c06bff19cd02d1b651d5917934434367d0efcb546ec55afd9b0b66804
5
5
  SHA512:
6
- metadata.gz: 7e02abfa3203653103218c7a187c5cc4337b252f5a383ad5c3cfd06eee7d0a93f42f08230131bab0bc9481d7ba78cc8296230a78af7e393fa08bc1a08f8c4b76
7
- data.tar.gz: fae466a396dfdff3c5c2397c002ca6c5ca9d1e9b82d59a71d71f4c39b3752f2a3b41101675b9f8c1c9ec40edb71ab0784e007839cc53c2622660131a05883351
6
+ metadata.gz: 638a0796f7049de3544b8d342d72545d72c06a56e0ecc82dbc2974fd16b2e81ab91a56ff9615e61ef34bfded1dda8f29187b4792db3d2bd757fed7e27dcf5d27
7
+ data.tar.gz: b52c4650487ec31ef5ba20ec4fdf180016f730ddffe2a8bf9909a32db39c362a4ae2ae60a59441fe1c0fc1a177933d4e09e634a5af3b4f51b23b4b51dfe13321
@@ -2,15 +2,24 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 3.6.0
6
+
7
+ * [#254](https://github.com/rails/web-console/pull/254) Rescue ActionDispatch::RemoteIp::IpSpoofAttackError ([@wjordan])
8
+ * [#250](https://github.com/rails/web-console/pull/250) Close original body to comply with Rack SPEC ([@wagenet])
9
+ * [#249](https://github.com/rails/web-console/pull/249) Update for frozen-string-literal friendliness ([@pat])
10
+ * [#248](https://github.com/rails/web-console/pull/248) Fix copy on Safari ([@ybart])
11
+ * [#246](https://github.com/rails/web-console/pull/246) International keyboard special character input fixes ([@fl0l0u])
12
+ * [#244](https://github.com/rails/web-console/pull/244) Let WebConsole.logger respect Rails.logger ([@gsamokovarov])
13
+
5
14
  ## 3.5.1
6
15
 
7
- * [239](https://github.com/rails/web-console/pull/239) Fix the ActionDispatch::DebugExceptions integration ([@gsamokovarov])
16
+ * [#239](https://github.com/rails/web-console/pull/239) Fix the ActionDispatch::DebugExceptions integration ([@gsamokovarov])
8
17
 
9
18
  ## 3.5.0
10
19
 
11
- * [237](https://github.com/rails/web-console/pull/237) Bindex integration for JRuby 9k support ([@gsamokovarov])
12
- * [236](https://github.com/rails/web-console/pull/236) Remove unused Active Support lazy load hook ([@betesh])
13
- * [230](https://github.com/rails/web-console/pull/230) Handle invalid remote addresses ([@akirakoyasu])
20
+ * [#237](https://github.com/rails/web-console/pull/237) Bindex integration for JRuby 9k support ([@gsamokovarov])
21
+ * [#236](https://github.com/rails/web-console/pull/236) Remove unused Active Support lazy load hook ([@betesh])
22
+ * [#230](https://github.com/rails/web-console/pull/230) Handle invalid remote addresses ([@akirakoyasu])
14
23
 
15
24
  ## 3.4.0
16
25
 
@@ -22,7 +31,7 @@ Drop support for Rails `4.2.0`.
22
31
 
23
32
  ## 3.3.0
24
33
 
25
- * [203](https://github.com/rails/web-console/pull/203) Map bindings to traces based on the trace __FILE__ and __LINE__ ([@gsamokovarov])
34
+ * [#203](https://github.com/rails/web-console/pull/203) Map bindings to traces based on the trace __FILE__ and __LINE__ ([@gsamokovarov])
26
35
 
27
36
  ## 3.2.1
28
37
 
@@ -55,8 +64,8 @@ Drop support for Rails `4.2.0`.
55
64
  This is mainly a Rails 5 compatibility release. If you have the chance, please
56
65
  go to 3.1.0 instead.
57
66
 
58
- * [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors (@schneems)
59
- * [#150](https://github.com/rails/web-console/pull/150) Revert #150. (@gsamokovarov)
67
+ * [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors ([@schneems])
68
+ * [#150](https://github.com/rails/web-console/pull/150) Revert #150. ([@gsamokovarov])
60
69
 
61
70
  ## 2.2.1
62
71
 
@@ -108,3 +117,8 @@ go to 3.1.0 instead.
108
117
  [@schneems]: https://github.com/schneems
109
118
  [@betesh]: https://github.com/betesh
110
119
  [@akirakoyasu]: https://github.com/akirakoyasu
120
+ [@wagenet]: https://github.com/wagenet
121
+ [@wjordan]: https://github.com/wjordan
122
+ [@pat]: https://github.com/pat
123
+ [@ybart]: https://github.com/ybart
124
+ [@fl0l0u]: https://github.com/fl0l0u
@@ -2,7 +2,6 @@
2
2
  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
- <a href=https://github.com/rails/web-console/tree/v3.0.0>v3.0.0</a>
6
5
  </p>
7
6
 
8
7
  # Web Console [![Build Status](https://travis-ci.org/rails/web-console.svg?branch=master)](https://travis-ci.org/rails/web-console)
@@ -17,8 +16,7 @@ _Web Console_ is a debugging tool for your Ruby on Rails applications.
17
16
 
18
17
  ## Installation
19
18
 
20
- _Web Console_ is meant to work as a Rails plugin. To install it in your current
21
- application, add the following to your `Gemfile`.
19
+ Add the following to your `Gemfile`.
22
20
 
23
21
  ```ruby
24
22
  group :development do
@@ -26,13 +24,10 @@ group :development do
26
24
  end
27
25
  ```
28
26
 
29
- After you save the `Gemfile` changes, make sure to run `bundle install` and
30
- restart your server for the _Web Console_ to kick in.
31
-
32
27
  ## Usage
33
28
 
34
29
  The web console allows you to create an interactive Ruby session in your
35
- browser. Those sessions are launched automatically in case on an error, but
30
+ browser. Those sessions are launched automatically in case of an error, but
36
31
  they can also be launched manually in any page.
37
32
 
38
33
  For example, calling `console` in a view will display a console in the current
@@ -56,8 +51,8 @@ end
56
51
 
57
52
  The method is defined in `Kernel` and you can invoke it any application code.
58
53
 
59
- Only one `console` invocation is allowed once per request. If you happen to
60
- have multiple ones, a `WebConsole::DoubleRenderError` will be raised.
54
+ Only one `console` invocation per request is allowed. If you happen to
55
+ have multiple ones, `WebConsole::DoubleRenderError` will be raised.
61
56
 
62
57
  ## Configuration
63
58
 
data/Rakefile CHANGED
@@ -1,26 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
- require 'bundler/setup'
4
+ require "bundler/setup"
3
5
  rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
7
  end
6
8
 
7
- require 'socket'
8
- require 'rake/testtask'
9
- require 'tmpdir'
10
- require 'securerandom'
11
- require 'json'
12
- require 'web_console/testing/erb_precompiler'
9
+ require "socket"
10
+ require "rake/testtask"
11
+ require "tmpdir"
12
+ require "securerandom"
13
+ require "json"
14
+ require "web_console/testing/erb_precompiler"
13
15
 
14
16
  EXPANDED_CWD = File.expand_path(File.dirname(__FILE__))
15
17
 
16
18
  Rake::TestTask.new(:test) do |t|
17
- t.libs << 'lib'
18
- t.libs << 'test'
19
- t.pattern = 'test/**/*_test.rb'
19
+ t.libs << "lib"
20
+ t.libs << "test"
21
+ t.pattern = "test/**/*_test.rb"
20
22
  t.verbose = false
21
23
  end
22
24
 
23
- Dir['lib/web_console/tasks/**/*.rake'].each { |task| load task }
25
+ Dir["lib/web_console/tasks/**/*.rake"].each { |task| load task }
24
26
 
25
27
  Bundler::GemHelper.install_tasks
26
28
 
@@ -1 +1,3 @@
1
- require 'web_console'
1
+ # frozen_string_literal: true
2
+
3
+ require "web_console"
@@ -1,5 +1,7 @@
1
- require 'active_support/dependencies/autoload'
2
- require 'active_support/logger'
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/dependencies/autoload"
4
+ require "active_support/logger"
3
5
 
4
6
  module WebConsole
5
7
  extend ActiveSupport::Autoload
@@ -16,13 +18,14 @@ module WebConsole
16
18
  autoload :Middleware
17
19
  autoload :Context
18
20
 
19
- autoload_at 'web_console/errors' do
21
+ autoload_at "web_console/errors" do
20
22
  autoload :Error
21
23
  autoload :DoubleRenderError
22
24
  end
23
25
 
24
- mattr_accessor :logger
25
- @@logger = ActiveSupport::Logger.new($stderr)
26
+ def self.logger
27
+ Rails.logger || (@logger ||= ActiveSupport::Logger.new($stderr))
28
+ end
26
29
  end
27
30
 
28
- require 'web_console/railtie'
31
+ require "web_console/railtie"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  # A context lets you get object names related to the current session binding.
3
5
  class Context
@@ -17,12 +19,12 @@ module WebConsole
17
19
  private
18
20
 
19
21
  GLOBAL_OBJECTS = [
20
- 'instance_variables',
21
- 'local_variables',
22
- 'methods',
23
- 'class_variables',
24
- 'Object.constants',
25
- 'global_variables'
22
+ "instance_variables",
23
+ "local_variables",
24
+ "methods",
25
+ "class_variables",
26
+ "Object.constants",
27
+ "global_variables"
26
28
  ]
27
29
 
28
30
  def global
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  # The base class for every Web Console related error.
3
5
  Error = Class.new(StandardError)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  # Simple Ruby code evaluator.
3
5
  #
@@ -8,7 +10,7 @@ module WebConsole
8
10
  # Cleanses exceptions raised inside #eval.
9
11
  cattr_reader :cleaner
10
12
  @@cleaner = ActiveSupport::BacktraceCleaner.new
11
- @@cleaner.add_silencer { |line| line.start_with?(File.expand_path('..', __FILE__)) }
13
+ @@cleaner.add_silencer { |line| line.start_with?(File.expand_path("..", __FILE__)) }
12
14
 
13
15
  def initialize(binding = TOPLEVEL_BINDING)
14
16
  @binding = binding
@@ -25,7 +27,7 @@ module WebConsole
25
27
  def format_exception(exc)
26
28
  backtrace = cleaner.clean(Array(exc.backtrace) - caller)
27
29
 
28
- format = "#{exc.class.name}: #{exc}\n"
30
+ format = "#{exc.class.name}: #{exc}\n".dup
29
31
  format << backtrace.map { |trace| "\tfrom #{trace}\n" }.join
30
32
  format
31
33
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  class ExceptionMapper
3
5
  def initialize(exception)
@@ -15,19 +17,19 @@ module WebConsole
15
17
 
16
18
  private
17
19
 
18
- def guess_binding_for_index(index)
19
- file, line = @backtrace[index].to_s.split(':')
20
- line = line.to_i
20
+ def guess_binding_for_index(index)
21
+ file, line = @backtrace[index].to_s.split(":")
22
+ line = line.to_i
21
23
 
22
- @bindings.find do |binding|
23
- binding.eval('__FILE__') == file && binding.eval('__LINE__') == line
24
+ @bindings.find do |binding|
25
+ binding.eval("__FILE__") == file && binding.eval("__LINE__") == line
26
+ end
24
27
  end
25
- end
26
28
 
27
- def guess_the_first_application_binding
28
- @bindings.find do |binding|
29
- binding.eval('__FILE__').to_s.start_with?(Rails.root.to_s)
29
+ def guess_the_first_application_binding
30
+ @bindings.find do |binding|
31
+ binding.eval("__FILE__").to_s.start_with?(Rails.root.to_s)
32
+ end
30
33
  end
31
- end
32
34
  end
33
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kernel
2
4
  module_function
3
5
 
@@ -24,7 +26,7 @@ module ActionDispatch
24
26
  class DebugExceptions
25
27
  def render_exception_with_web_console(request, exception)
26
28
  render_exception_without_web_console(request, exception).tap do
27
- backtrace_cleaner = request.get_header('action_dispatch.backtrace_cleaner')
29
+ backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner")
28
30
  error = ExceptionWrapper.new(backtrace_cleaner, exception).exception
29
31
 
30
32
  # Get the original exception if ExceptionWrapper decides to follow it.
@@ -1,11 +1,13 @@
1
- require 'active_support/core_ext/string/strip'
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/string/strip"
2
4
 
3
5
  module WebConsole
4
6
  class Middleware
5
- TEMPLATES_PATH = File.expand_path('../templates', __FILE__)
7
+ TEMPLATES_PATH = File.expand_path("../templates", __FILE__)
6
8
 
7
9
  cattr_accessor :mount_point
8
- @@mount_point = '/__web_console'
10
+ @@mount_point = "/__web_console"
9
11
 
10
12
  cattr_accessor :whiny_requests
11
13
  @@whiny_requests = true
@@ -27,13 +29,13 @@ module WebConsole
27
29
 
28
30
  status, headers, body = call_app(env)
29
31
 
30
- if session = Session.from(Thread.current) and acceptable_content_type?(headers)
32
+ if (session = Session.from(Thread.current)) && acceptable_content_type?(headers)
31
33
  response = Response.new(body, status, headers)
32
34
  template = Template.new(env, session)
33
35
 
34
36
  response.headers["X-Web-Console-Session-Id"] = session.id
35
37
  response.headers["X-Web-Console-Mount-Point"] = mount_point
36
- response.write(template.render('index'))
38
+ response.write(template.render("index"))
37
39
  response.finish
38
40
  else
39
41
  [ status, headers, body ]
@@ -54,12 +56,12 @@ module WebConsole
54
56
  private
55
57
 
56
58
  def acceptable_content_type?(headers)
57
- Mime::Type.parse(headers['Content-Type'].to_s).first == Mime[:html]
59
+ Mime::Type.parse(headers["Content-Type"].to_s).first == Mime[:html]
58
60
  end
59
61
 
60
62
  def json_response(opts = {})
61
63
  status = opts.fetch(:status, 200)
62
- headers = { 'Content-Type' => 'application/json; charset = utf-8' }
64
+ headers = { "Content-Type" => "application/json; charset = utf-8" }
63
65
  body = yield.to_json
64
66
 
65
67
  Rack::Response.new(body, status, headers).finish
@@ -121,13 +123,13 @@ module WebConsole
121
123
 
122
124
  def respond_with_unavailable_session(id)
123
125
  json_response(status: 404) do
124
- { output: format(I18n.t('errors.unavailable_session'), id: id)}
126
+ { output: format(I18n.t("errors.unavailable_session"), id: id) }
125
127
  end
126
128
  end
127
129
 
128
130
  def respond_with_unacceptable_request
129
131
  json_response(status: 406) do
130
- { output: I18n.t('errors.unacceptable_request') }
132
+ { output: I18n.t("errors.unacceptable_request") }
131
133
  end
132
134
  end
133
135
 
@@ -1,20 +1,18 @@
1
- require 'rails/railtie'
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/railtie"
2
4
 
3
5
  module WebConsole
4
6
  class Railtie < ::Rails::Railtie
5
7
  config.web_console = ActiveSupport::OrderedOptions.new
6
8
  config.web_console.whitelisted_ips = %w( 127.0.0.1 ::1 )
7
9
 
8
- initializer 'web_console.initialize' do
9
- require 'bindex'
10
- require 'web_console/extensions'
11
-
12
- if logger = ::Rails.logger
13
- WebConsole.logger = logger
14
- end
10
+ initializer "web_console.initialize" do
11
+ require "bindex"
12
+ require "web_console/extensions"
15
13
  end
16
14
 
17
- initializer 'web_console.development_only' do
15
+ initializer "web_console.development_only" do
18
16
  unless (config.web_console.development_only == false) || Rails.env.development?
19
17
  abort <<-END.strip_heredoc
20
18
  Web Console is activated in the #{Rails.env} environment. This is
@@ -32,13 +30,13 @@ module WebConsole
32
30
  end
33
31
  end
34
32
 
35
- initializer 'web_console.insert_middleware' do |app|
33
+ initializer "web_console.insert_middleware" do |app|
36
34
  app.middleware.insert_before ActionDispatch::DebugExceptions, Middleware
37
35
  end
38
36
 
39
- initializer 'web_console.mount_point' do
37
+ initializer "web_console.mount_point" do
40
38
  if mount_point = config.web_console.mount_point
41
- Middleware.mount_point = mount_point.chomp('/')
39
+ Middleware.mount_point = mount_point.chomp("/")
42
40
  end
43
41
 
44
42
  if root = Rails.application.config.relative_url_root
@@ -46,26 +44,26 @@ module WebConsole
46
44
  end
47
45
  end
48
46
 
49
- initializer 'web_console.template_paths' do
47
+ initializer "web_console.template_paths" do
50
48
  if template_paths = config.web_console.template_paths
51
49
  Template.template_paths.unshift(*Array(template_paths))
52
50
  end
53
51
  end
54
52
 
55
- initializer 'web_console.whitelisted_ips' do
53
+ initializer "web_console.whitelisted_ips" do
56
54
  if whitelisted_ips = config.web_console.whitelisted_ips
57
55
  Request.whitelisted_ips = Whitelist.new(whitelisted_ips)
58
56
  end
59
57
  end
60
58
 
61
- initializer 'web_console.whiny_requests' do
59
+ initializer "web_console.whiny_requests" do
62
60
  if config.web_console.key?(:whiny_requests)
63
61
  Middleware.whiny_requests = config.web_console.whiny_requests
64
62
  end
65
63
  end
66
64
 
67
- initializer 'i18n.load_path' do
68
- config.i18n.load_path.concat(Dir[File.expand_path('../locales/*.yml', __FILE__)])
65
+ initializer "i18n.load_path" do
66
+ config.i18n.load_path.concat(Dir[File.expand_path("../locales/*.yml", __FILE__)])
69
67
  end
70
68
  end
71
69
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  # Web Console tailored request object.
3
5
  class Request < ActionDispatch::Request
@@ -6,7 +8,7 @@ module WebConsole
6
8
  @@whitelisted_ips = Whitelist.new
7
9
 
8
10
  # Define a vendor MIME type. We can call it using Mime[:web_console_v2].
9
- Mime::Type.register 'application/vnd.web-console.v2', :web_console_v2
11
+ Mime::Type.register "application/vnd.web-console.v2", :web_console_v2
10
12
 
11
13
  # Returns whether a request came from a whitelisted IP.
12
14
  #
@@ -19,6 +21,8 @@ module WebConsole
19
21
  # Determines the remote IP using our much stricter whitelist.
20
22
  def strict_remote_ip
21
23
  GetSecureIp.new(self, whitelisted_ips).to_s
24
+ rescue ActionDispatch::RemoteIp::IpSpoofAttackError
25
+ "[Spoofed]"
22
26
  end
23
27
 
24
28
  # Returns whether the request is acceptable.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  # A response object that writes content before the closing </body> tag, if
3
5
  # possible.
@@ -7,13 +9,15 @@ module WebConsole
7
9
  def write(content)
8
10
  raw_body = Array(body).first.to_s
9
11
 
10
- if position = raw_body.rindex('</body>')
11
- raw_body.insert(position, content)
12
- else
13
- raw_body << content
14
- end
12
+ # We're done with the original body object, so make sure to close it to comply with the Rack SPEC
13
+ body.close if body.respond_to?(:close)
15
14
 
16
- self.body = raw_body
15
+ self.body =
16
+ if position = raw_body.rindex("</body>")
17
+ raw_body.dup.insert(position, content)
18
+ else
19
+ raw_body.dup << content
20
+ end
17
21
  end
18
22
 
19
23
  def finish
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  # A session lets you persist an +Evaluator+ instance in memory associated
3
5
  # with multiple bindings.
@@ -1,23 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :ext do
2
- rootdir = Pathname('extensions')
4
+ rootdir = Pathname("extensions")
3
5
 
4
- desc 'Build Chrome Extension'
5
- task chrome: 'chrome:build'
6
+ desc "Build Chrome Extension"
7
+ task chrome: "chrome:build"
6
8
 
7
9
  namespace :chrome do
8
- dist = Pathname('dist/crx')
10
+ dist = Pathname("dist/crx")
9
11
  extdir = rootdir.join(dist)
10
- manifest_json = rootdir.join('chrome/manifest.json')
12
+ manifest_json = rootdir.join("chrome/manifest.json")
11
13
 
12
14
  directory extdir
13
15
 
14
- task build: [ extdir, 'lib:templates' ] do
16
+ task build: [ extdir, "lib:templates" ] do
15
17
  cd rootdir do
16
- cp_r [ 'img/', 'tmp/lib/' ], dist
18
+ cp_r [ "img/", "tmp/lib/" ], dist
17
19
  `cd chrome && git ls-files`.split("\n").each do |src|
18
20
  dest = dist.join(src)
19
21
  mkdir_p dest.dirname
20
- cp Pathname('chrome').join(src), dest
22
+ cp Pathname("chrome").join(src), dest
21
23
  end
22
24
  end
23
25
  end
@@ -34,7 +36,7 @@ namespace :ext do
34
36
  cd(extdir) { sh "zip -r ../crx-web-console-#{version}.zip ./" }
35
37
  end
36
38
 
37
- desc 'Launch a browser with the chrome extension.'
39
+ desc "Launch a browser with the chrome extension."
38
40
  task run: [ :build ] do
39
41
  cd(rootdir) { sh "sh ./script/run_chrome.sh --load-extension=#{dist}" }
40
42
  end
@@ -45,15 +47,15 @@ namespace :ext do
45
47
  end
46
48
 
47
49
  namespace :lib do
48
- templates = Pathname('lib/web_console/templates')
49
- tmplib = rootdir.join('tmp/lib/')
50
- js_erb = FileList.new(templates.join('**/*.js.erb'))
50
+ templates = Pathname("lib/web_console/templates")
51
+ tmplib = rootdir.join("tmp/lib/")
52
+ js_erb = FileList.new(templates.join("**/*.js.erb"))
51
53
  dirs = js_erb.pathmap("%{^#{templates},#{tmplib}}d")
52
54
 
53
55
  task templates: dirs + js_erb.pathmap("%{^#{templates},#{tmplib}}X")
54
56
 
55
57
  dirs.each { |d| directory d }
56
- rule '.js' => [ "%{^#{tmplib},#{templates}}X.js.erb" ] do |t|
58
+ rule ".js" => [ "%{^#{tmplib},#{templates}}X.js.erb" ] do |t|
57
59
  File.write(t.name, WebConsole::Testing::ERBPrecompiler.new(t.source).build)
58
60
  end
59
61
  end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :templates do
2
- desc 'Run tests for templates'
4
+ desc "Run tests for templates"
3
5
  task test: [ :daemonize, :npm, :rackup, :wait, :mocha, :kill, :exit ]
4
6
  task serve: [ :npm, :rackup ]
5
7
 
6
- workdir = Pathname(EXPANDED_CWD).join('test/templates')
8
+ workdir = Pathname(EXPANDED_CWD).join("test/templates")
7
9
  pid = Pathname(Dir.tmpdir).join("web_console_test.pid")
8
10
  runner = URI.parse("http://#{ENV['IP'] || '127.0.0.1'}:#{ENV['PORT'] || 29292}/html/test_runner.html")
9
11
  rackup = "rackup --host #{runner.host} --port #{runner.port}"
10
12
  result = nil
11
- browser = 'phantomjs'
13
+ browser = "phantomjs"
12
14
 
13
15
  def need_to_wait?(uri)
14
16
  Net::HTTP.start(uri.host, uri.port) { |http| http.get(uri.path) }
@@ -20,13 +22,13 @@ namespace :templates do
20
22
  rackup += " -D --pid #{pid}"
21
23
  end
22
24
 
23
- task :npm => [ :phantomjs ] do
24
- Dir.chdir(workdir) { system 'npm install --silent' }
25
+ task npm: [ :phantomjs ] do
26
+ Dir.chdir(workdir) { system "npm install --silent" }
25
27
  end
26
28
 
27
29
  task :phantomjs do
28
30
  unless system("which #{browser} >/dev/null")
29
- browser = './node_modules/.bin/phantomjs'
31
+ browser = "./node_modules/.bin/phantomjs"
30
32
  Dir.chdir(workdir) { system("test -f #{browser} || npm install --silent phantomjs-prebuilt") }
31
33
  end
32
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  # A facade that handles template rendering and composition.
3
5
  #
@@ -6,7 +8,7 @@ module WebConsole
6
8
  class Template
7
9
  # Lets you customize the default templates folder location.
8
10
  cattr_accessor :template_paths
9
- @@template_paths = [ File.expand_path('../templates', __FILE__) ]
11
+ @@template_paths = [ File.expand_path("../templates", __FILE__) ]
10
12
 
11
13
  def initialize(env, session)
12
14
  @env = env
@@ -494,7 +494,7 @@ REPLConsole.prototype.getSuggestion = function(keyword) {
494
494
  hint.className = 'console-hint';
495
495
  hint.dataset.keyword = found;
496
496
  hint.innerText = found.substr(self.suggestKeyword.length);
497
- // clear hinting information after timeout in a few time
497
+ // clear hinting information after timeout in a few time
498
498
  if (self.suggestTimeout) clearTimeout(self.suggestTimeout);
499
499
  self.suggestTimeout = setTimeout(function() { self.renderInput() }, self.suggestWait);
500
500
  }
@@ -710,9 +710,10 @@ REPLConsole.prototype.onKeyDown = function(ev) {
710
710
  }
711
711
 
712
712
  if (ev.ctrlKey || ev.metaKey) {
713
- // Set focus to our clipboard in case they hit the "v" key
714
- this.clipboard.focus();
715
713
  if (ev.keyCode == 86) {
714
+ // Set focus to our clipboard when they hit the "v" key
715
+ this.clipboard.focus();
716
+
716
717
  // Pasting to clipboard doesn't happen immediately,
717
718
  // so we have to wait for a while to get the pasted text.
718
719
  var _this = this;
@@ -732,7 +733,7 @@ REPLConsole.prototype.onKeyDown = function(ev) {
732
733
  */
733
734
  REPLConsole.prototype.onKeyPress = function(ev) {
734
735
  // Only write to the console if it's a single key press.
735
- if (ev.ctrlKey || ev.metaKey) { return; }
736
+ if (ev.ctrlKey && !ev.altKey || ev.metaKey) { return; }
736
737
  var keyCode = ev.keyCode || ev.which;
737
738
  this.insertAtCurrent(String.fromCharCode(keyCode));
738
739
  ev.stopPropagation();
@@ -1,5 +1,7 @@
1
- require 'web_console/testing/helper'
2
- require 'web_console/testing/fake_middleware'
1
+ # frozen_string_literal: true
2
+
3
+ require "web_console/testing/helper"
4
+ require "web_console/testing/fake_middleware"
3
5
 
4
6
  module WebConsole
5
7
  module Testing
@@ -8,7 +10,7 @@ module WebConsole
8
10
  def initialize(path)
9
11
  @erb = ERB.new(File.read(path))
10
12
  @view = FakeMiddleware.new(
11
- view_path: Helper.gem_root.join('lib/web_console/templates'),
13
+ view_path: Helper.gem_root.join("lib/web_console/templates"),
12
14
  ).view
13
15
  end
14
16
 
@@ -1,12 +1,14 @@
1
- require 'action_view'
2
- require 'web_console'
3
- require 'web_console/testing/helper'
4
- Mime = { web_console_v2: 'fake' }
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view"
4
+ require "web_console"
5
+ require "web_console/testing/helper"
6
+ Mime = { web_console_v2: "fake" }
5
7
 
6
8
  module WebConsole
7
9
  module Testing
8
10
  class FakeMiddleware
9
- I18n.load_path.concat(Dir[Helper.gem_root.join('lib/web_console/locales/*.yml')])
11
+ I18n.load_path.concat(Dir[Helper.gem_root.join("lib/web_console/locales/*.yml")])
10
12
 
11
13
  DEFAULT_HEADERS = { "Content-Type" => "application/javascript" }
12
14
 
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  module Testing
3
5
  module Helper
4
6
  def self.gem_root
5
- Pathname(File.expand_path('../../../../', __FILE__))
7
+ Pathname(File.expand_path("../../../../", __FILE__))
6
8
  end
7
9
  end
8
10
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
- VERSION = '3.5.1'
4
+ VERSION = "3.6.0"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  class View < ActionView::Base
3
5
  # Execute a block only on error pages.
@@ -15,7 +17,7 @@ module WebConsole
15
17
  # leaking globals, unless you explicitly want to.
16
18
  def render_javascript(template)
17
19
  assign(template: template)
18
- render(template: template, layout: 'layouts/javascript')
20
+ render(template: template, layout: "layouts/javascript")
19
21
  end
20
22
 
21
23
  # Render inlined string to be used inside of JavaScript code.
@@ -23,7 +25,7 @@ module WebConsole
23
25
  # The inlined string is returned as an actual JavaScript string. You
24
26
  # don't need to wrap the result yourself.
25
27
  def render_inlined_string(template)
26
- render(template: template, layout: 'layouts/inlined_string')
28
+ render(template: template, layout: "layouts/inlined_string")
27
29
  end
28
30
 
29
31
  # Custom ActionView::Base#render wrapper which silences all the log
@@ -31,7 +33,7 @@ module WebConsole
31
33
  #
32
34
  # Helps to keep the Rails logs clean during errors.
33
35
  def render(*)
34
- if logger = WebConsole.logger and logger.respond_to?(:silence)
36
+ if (logger = WebConsole.logger) && logger.respond_to?(:silence)
35
37
  WebConsole.logger.silence { super }
36
38
  else
37
39
  super
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebConsole
2
4
  # Noisy wrapper around +Request+.
3
5
  #
@@ -21,7 +23,7 @@ module WebConsole
21
23
  end
22
24
 
23
25
  def logger
24
- env['action_dispatch.logger'] || WebConsole.logger
26
+ env["action_dispatch.logger"] || WebConsole.logger
25
27
  end
26
28
 
27
29
  def request
@@ -1,4 +1,6 @@
1
- require 'ipaddr'
1
+ # frozen_string_literal: true
2
+
3
+ require "ipaddr"
2
4
 
3
5
  module WebConsole
4
6
  # Whitelist of allowed networks that can access Web Console.
@@ -20,7 +22,7 @@ module WebConsole
20
22
  end
21
23
 
22
24
  def to_s
23
- @networks.map(&method(:human_readable_ipaddr)).join(', ')
25
+ @networks.map(&method(:human_readable_ipaddr)).join(", ")
24
26
  end
25
27
 
26
28
  private
@@ -38,7 +40,7 @@ module WebConsole
38
40
  end
39
41
 
40
42
  def human_readable_ipaddr(ipaddr)
41
- ipaddr.to_range.to_s.split('..').uniq.join('/')
43
+ ipaddr.to_range.to_s.split("..").uniq.join("/")
42
44
  end
43
45
  end
44
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web-console
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Somerville
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-05-12 00:00:00.000000000 Z
14
+ date: 2018-04-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: railties
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.6.11
139
+ rubygems_version: 2.7.3
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: A debugging tool for your Ruby on Rails applications.