rails_spotlight 0.3.1 → 0.3.4

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
2
  SHA256:
3
- metadata.gz: b9eca5a5464ed6e44b8c65f206f96ead18ff5cc73a0f9395b2b5cc863a28b270
4
- data.tar.gz: 4bc0b0e190af921c926a1f08bb43954dee8b3aa488d867c885b4af84c3816ab7
3
+ metadata.gz: 251b10d3b271c26da91b3d6c6b41f84eb49f4b6f732d89c4e0f377ead50ae797
4
+ data.tar.gz: bf48a45b74e5fd78f81e7f3b4250f339c7cd39c2ce230efefa4bf2d847898b83
5
5
  SHA512:
6
- metadata.gz: 552d1619a7c990dbce5c52fa883a45bcb5d5d58fa3a81a947fd244badbffcab5516607bb739dc73803d90ababd44755d78b9efe159d6d7d785181cef9e390b59
7
- data.tar.gz: 8173b1bfc3514712a350d08c8441552c8091c4b3559357192cde5de84470aee320dc26be1663ca07aa1fcbe7fb48573001d7d9bffce578886b3c5c75302633d3
6
+ metadata.gz: 3ec1fe5f5e842f5eb8975e6d19d5eb923b8dfe6425a86c85b650b1781d2f060a61fc866c159d0e940cb488c2d38cb9e72b9c26034d79638b1a7c2319f9c2fe9f
7
+ data.tar.gz: 9ab3ecb3de8b864c850b5b398e82c121cde1a4ecf9184170bb4e2c6f7229cb2306e4df21516f5d8fa60873fbb1bde1901f66358b6a098969ae6f86e0a48cca2f
data/README.md CHANGED
@@ -11,6 +11,14 @@ Chrome extension [Rails Spotlight](https://chrome.google.com/webstore/detail/rai
11
11
 
12
12
  Add this line to your application's Gemfile:
13
13
 
14
+ use bash
15
+
16
+ ```bash
17
+ bundle add rails_spotlight --group development
18
+ ```
19
+
20
+ or add it manually:
21
+
14
22
  ```ruby
15
23
  group :development do
16
24
  gem 'rails_spotlight'
@@ -62,6 +62,9 @@ module RailsSpotlight
62
62
  # Subscribe to all events relevant to RailsPanel
63
63
  #
64
64
  def self.subscribe
65
+ # Skip RailsSpotlight subscriptions during migrations
66
+ return if migrating?
67
+
65
68
  new
66
69
  .subscribe('rsl.notification.log')
67
70
  .subscribe('sql.active_record', &SQL_BLOCK)
@@ -92,6 +95,12 @@ module RailsSpotlight
92
95
  # such as the collection name and the partial being used to render each item.
93
96
  end
94
97
 
98
+ def self.migrating?
99
+ defined?(Rake) && Rake.application.top_level_tasks.any? do |task|
100
+ task.start_with?('db:migrate', 'db:schema:load')
101
+ end
102
+ end
103
+
95
104
  def subscribe(event_name)
96
105
  ActiveSupport::Notifications.subscribe(event_name) do |*args|
97
106
  event = block_given? ? yield(*args) : Event.new(*args)
@@ -44,7 +44,7 @@ module RailsSpotlight
44
44
  executor.execute(command)
45
45
  if executor.execution_successful?
46
46
  {
47
- payload: { result: executor.result_as_json(inspect_types: inspect_types) },
47
+ payload: { result: executor.result_as_json(inspect_types: inspect_types) }
48
48
  }
49
49
  else
50
50
  {
@@ -19,9 +19,7 @@ module RailsSpotlight
19
19
  def self.handle(data)
20
20
  case data['type']
21
21
  when LiveConsoleHandler::TYPE then LiveConsoleHandler.new(data).call
22
- # when LogsHandler::TYPE then LogsHandler.new(data).call
23
- else
24
- nil
22
+ when LogsHandler::TYPE then LogsHandler.new(data).call
25
23
  end
26
24
  end
27
25
  end
@@ -23,4 +23,3 @@ module RailsSpotlight
23
23
  end
24
24
  end
25
25
  end
26
-
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RailsSpotlight
4
4
  module Channels
5
- SPOTLIGHT_CHANNEL = 'RailsSpotlight::Channels::SpotlightChannel'.freeze
5
+ SPOTLIGHT_CHANNEL = 'RailsSpotlight::Channels::SpotlightChannel'.freeze # rubocop:disable Style/RedundantFreeze
6
6
  autoload(:SpotlightChannel, 'rails_spotlight/channels/spotlight_channel') if defined?(ActionCable)
7
7
  end
8
8
  end
@@ -4,7 +4,7 @@ require 'yaml'
4
4
  require 'erb'
5
5
 
6
6
  module RailsSpotlight
7
- class Configuration
7
+ class Configuration # rubocop:disable Metrics/ClassLength
8
8
  DEFAULT_NOT_ENCODABLE_EVENT_VALUES = {
9
9
  'ActiveRecord' => ['ActiveRecord::ConnectionAdapters::AbstractAdapter'],
10
10
  'ActionDispatch' => ['ActionDispatch::Request', 'ActionDispatch::Response']
@@ -57,8 +57,9 @@ module RailsSpotlight
57
57
  def not_encodable?(value)
58
58
  ::RailsSpotlight.config.not_encodable_event_values.any? do |module_name, class_names|
59
59
  next unless defined?(module_name.constantize)
60
+
60
61
  class_names.any? { |class_name| value.is_a?(class_name.constantize) }
61
- rescue => e
62
+ rescue => e # rubocop:disable Lint/RescueException, Lint/RedundantCopDisableDirective, Style/RescueStandardError
62
63
  puts "Error in not_encodable? method: #{e.message}"
63
64
  end
64
65
  end
@@ -7,7 +7,7 @@ module RailsSpotlight
7
7
  SEVERITY = %w[debug info warn error fatal unknown].freeze
8
8
  SEVERITY_MAP = { 0 => 'debug', 1 => 'info', 2 => 'warn', 3 => 'error', 4 => 'fatal', 5 => 'unknown' }.freeze
9
9
 
10
- def add(severity, message = nil, progname = nil)
10
+ def add(severity, message = nil, progname = nil) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
11
11
  severity ||= 5
12
12
  return true if @logdev.nil? || severity < level
13
13
 
@@ -37,7 +37,7 @@ module RailsSpotlight
37
37
  message.include?(::RailsSpotlight::Channels::SPOTLIGHT_CHANNEL)
38
38
  end
39
39
 
40
- def _push_event(level, message, progname = nil)
40
+ def _push_event(level, message, progname = nil) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
41
41
  callsite = Utils.dev_callsite(caller.drop(1))
42
42
  name = progname.is_a?(String) || progname.is_a?(Symbol) ? progname : nil
43
43
  AppRequest.current.events << Event.new('rsl.notification.log', 0, 0, 0, callsite.merge(message: message, level: level, progname: name)) if AppRequest.current && callsite
@@ -45,8 +45,8 @@ module RailsSpotlight
45
45
  return unless ::RailsSpotlight.config.live_console_enabled?
46
46
  return if message.blank?
47
47
 
48
- id = AppRequest.current ? AppRequest.current.id : nil
49
- payload = (callsite || {}).merge(msg: message, src: ENV['RS_SRC'] || ::RailsSpotlight.config.default_rs_src, l: level, dt: Time.now.to_f, id: id, pg: name)
48
+ id = AppRequest.current ? AppRequest.current.id : nil # rubocop:disable Style/SafeNavigation
49
+ payload = (callsite || {}).merge(msg: message, src: ENV['RS_SRC'] || ::RailsSpotlight.config.default_rs_src, l: level, dt: Time.now.to_f, id: id, pg: name)
50
50
  ::RailsSpotlight::Channels::SpotlightChannel.broadcast(type: 'logs', payload: payload)
51
51
  rescue StandardError => e
52
52
  RailsSpotlight.config.logger.fatal("#{e.message}\n #{e.backtrace.join("\n ")}")
@@ -32,7 +32,7 @@ module RailsSpotlight
32
32
 
33
33
  require 'rails_spotlight/channels/spotlight_channel' if ::RailsSpotlight.config.request_completed_broadcast_enabled?
34
34
 
35
- app.routes.draw { mount ActionCable.server => '/cable' } if ::RailsSpotlight.config.auto_mount_action_cable?
35
+ app.routes.draw { mount ActionCable.server => ::RailsSpotlight.config.action_cable_mount_path || '/cable' } if ::RailsSpotlight.config.auto_mount_action_cable?
36
36
  end
37
37
  end
38
38
 
@@ -15,8 +15,7 @@ module RailsSpotlight
15
15
  line: line.to_i,
16
16
  method: method
17
17
  }
18
- rescue
19
- nil
18
+ rescue # rubocop:disable Style/RescueStandardError, Lint/SuppressedException
20
19
  end
21
20
 
22
21
  def sub_source_path(path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsSpotlight
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.4'
5
5
  end
data/lib/tasks/init.rake CHANGED
@@ -45,10 +45,10 @@ namespace :rails_spotlight do # rubocop:disable Metrics/BlockLength
45
45
  end
46
46
  end
47
47
 
48
- desc "Generate rails_spotlight JavaScript ERB partial for application layout to allow injecting JS code from the extension"
49
- task inject_js_partial: :environment do
48
+ desc 'Generate rails_spotlight JavaScript ERB partial for application layout to allow injecting JS code from the extension'
49
+ task inject_js_partial: :environment do # rubocop:disable Metrics/BlockLength
50
50
  # Define the partial name and path
51
- partial_name = "_rails_spotlight_extension_js.html.erb"
51
+ partial_name = '_rails_spotlight_extension_js.html.erb'
52
52
  partial_path = "app/views/layouts/#{partial_name}"
53
53
 
54
54
  # Define the JavaScript code
@@ -99,12 +99,10 @@ namespace :rails_spotlight do # rubocop:disable Metrics/BlockLength
99
99
  end
100
100
 
101
101
  case layout_format
102
- when 'slim'
103
- puts "- if Rails.env.development?\n = render 'layouts/#{partial_name.split('.').first}'"
104
- when 'haml'
105
- puts "- if Rails.env.development?\n = render 'layouts/#{partial_name.split('.').first}'"
102
+ when 'slim', 'haml'
103
+ puts "- if Rails.env.development?\n = render 'layouts/#{partial_name.split('.').first}'" # rubocop:disable Style/StringLiteralsInInterpolation
106
104
  else
107
- puts "<% if Rails.env.development? %>\n <%= render 'layouts/#{partial_name.split('.').first}' %>\n<% end %>"
105
+ puts "<% if Rails.env.development? %>\n <%= render 'layouts/#{partial_name.split('.').first}' %>\n<% end %>" # rubocop:disable Style/StringLiteralsInInterpolation
108
106
  end
109
107
  end
110
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_spotlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pawel Niemczyk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-19 00:00:00.000000000 Z
11
+ date: 2024-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-contrib
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 3.0.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '7.2'
42
+ version: '7.3'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 3.0.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '7.2'
52
+ version: '7.3'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: action-cable-testing
55
55
  requirement: !ruby/object:Gem::Requirement