rails_spotlight 0.2.5 → 0.3.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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +60 -5
  3. data/lib/rails_spotlight/app_notifications.rb +3 -1
  4. data/lib/rails_spotlight/channels/handlers/live_console_handler.rb +64 -0
  5. data/lib/rails_spotlight/channels/handlers/logs_handler.rb +38 -0
  6. data/lib/rails_spotlight/channels/handlers.rb +29 -0
  7. data/lib/rails_spotlight/channels/silence_action_cable_broadcaster_logging.rb +26 -0
  8. data/lib/rails_spotlight/channels/spotlight_channel.rb +71 -0
  9. data/lib/rails_spotlight/channels.rb +2 -2
  10. data/lib/rails_spotlight/configuration.rb +21 -4
  11. data/lib/rails_spotlight/event.rb +2 -1
  12. data/lib/rails_spotlight/log_interceptor.rb +37 -29
  13. data/lib/rails_spotlight/middlewares/handlers/base_action_handler.rb +34 -2
  14. data/lib/rails_spotlight/middlewares/handlers/code_analysis_action_handler.rb +89 -0
  15. data/lib/rails_spotlight/middlewares/handlers/console_action_handler.rb +5 -23
  16. data/lib/rails_spotlight/middlewares/handlers/directory_index_action_handler.rb +112 -0
  17. data/lib/rails_spotlight/middlewares/handlers/file_action_handler.rb +18 -4
  18. data/lib/rails_spotlight/middlewares/handlers/meta_action_handler.rb +0 -1
  19. data/lib/rails_spotlight/middlewares/handlers/sql_action_handler.rb +6 -15
  20. data/lib/rails_spotlight/middlewares/handlers/verify_action_handler.rb +6 -2
  21. data/lib/rails_spotlight/middlewares/request_completed.rb +14 -10
  22. data/lib/rails_spotlight/middlewares/request_handler.rb +5 -1
  23. data/lib/rails_spotlight/railtie.rb +12 -4
  24. data/lib/rails_spotlight/render_view_reporter.rb +3 -1
  25. data/lib/rails_spotlight/utils.rb +2 -0
  26. data/lib/rails_spotlight/version.rb +1 -1
  27. data/lib/tasks/init.rake +75 -6
  28. metadata +9 -4
  29. data/lib/rails_spotlight/channels/live_console_channel.rb +0 -62
  30. data/lib/rails_spotlight/channels/request_completed_channel.rb +0 -15
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.2.5
4
+ version: 0.3.0
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-02-25 00:00:00.000000000 Z
11
+ date: 2024-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-contrib
@@ -240,15 +240,20 @@ files:
240
240
  - lib/rails_spotlight/app_notifications.rb
241
241
  - lib/rails_spotlight/app_request.rb
242
242
  - lib/rails_spotlight/channels.rb
243
- - lib/rails_spotlight/channels/live_console_channel.rb
244
- - lib/rails_spotlight/channels/request_completed_channel.rb
243
+ - lib/rails_spotlight/channels/handlers.rb
244
+ - lib/rails_spotlight/channels/handlers/live_console_handler.rb
245
+ - lib/rails_spotlight/channels/handlers/logs_handler.rb
246
+ - lib/rails_spotlight/channels/silence_action_cable_broadcaster_logging.rb
247
+ - lib/rails_spotlight/channels/spotlight_channel.rb
245
248
  - lib/rails_spotlight/configuration.rb
246
249
  - lib/rails_spotlight/event.rb
247
250
  - lib/rails_spotlight/log_interceptor.rb
248
251
  - lib/rails_spotlight/middlewares.rb
249
252
  - lib/rails_spotlight/middlewares/concerns/skip_request_paths.rb
250
253
  - lib/rails_spotlight/middlewares/handlers/base_action_handler.rb
254
+ - lib/rails_spotlight/middlewares/handlers/code_analysis_action_handler.rb
251
255
  - lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
256
+ - lib/rails_spotlight/middlewares/handlers/directory_index_action_handler.rb
252
257
  - lib/rails_spotlight/middlewares/handlers/file_action_handler.rb
253
258
  - lib/rails_spotlight/middlewares/handlers/meta_action_handler.rb
254
259
  - lib/rails_spotlight/middlewares/handlers/not_found_action_handler.rb
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../rails_command_executor'
4
- module RailsSpotlight
5
- module Channels
6
- class LiveConsoleChannel < ActionCable::Channel::Base
7
- def subscribed
8
- stream_from 'rails_spotlight_live_console_channel'
9
- publish({ message: "Welcome to the #{project} project Rails Spotlight Live Console" })
10
- end
11
-
12
- def unsubscribed
13
- # Any cleanup needed when channel is unsubscribed
14
- end
15
-
16
- def receive(data)
17
- command = data['command']
18
- inspect_types = data['inspect_types']
19
- for_project = data['project']
20
- return publish({ error: project_mismatch_message(for_project) }) if for_project.present? && for_project != project
21
-
22
- output = execute_command(command, inspect_types)
23
- publish(output)
24
- end
25
-
26
- private
27
-
28
- def project_mismatch_message(for_project)
29
- "Project mismatch, The command was intended for the #{for_project} project. This is #{project} project"
30
- end
31
-
32
- def publish(data)
33
- transmit(data.merge(project: project))
34
- end
35
-
36
- # TODO: add possibility to change project name via ENV variable or RailsSpotlight config
37
- def project
38
- ::RailsSpotlight.config.project_name
39
- end
40
-
41
- def executor
42
- @executor ||= ::RailsSpotlight::RailsCommandExecutor.new
43
- end
44
-
45
- def execute_command(command, inspect_types)
46
- RailsSpotlight.config.logger && RailsSpotlight.config.logger.info("Executing command: #{command}") # rubocop:disable Style/SafeNavigation
47
-
48
- executor.execute(command)
49
- if executor.execution_successful?
50
- {
51
- result: executor.result_as_json(inspect_types: inspect_types),
52
- project: ::RailsSpotlight.config.project_name
53
- }
54
- else
55
- executor.result_as_json.merge(project: ::RailsSpotlight.config.project_name)
56
- end
57
- rescue => e # rubocop:disable Style/RescueStandardError
58
- { error: e.message }
59
- end
60
- end
61
- end
62
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RailsSpotlight
4
- module Channels
5
- class RequestCompletedChannel < ActionCable::Channel::Base
6
- def subscribed
7
- stream_from 'rails_spotlight_request_completed_channel'
8
- end
9
-
10
- def unsubscribed
11
- # Any cleanup needed when channel is unsubscribed
12
- end
13
- end
14
- end
15
- end