rails_spotlight 0.1.4 → 0.1.6
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 +4 -4
- data/README.md +10 -2
- data/lib/rails_spotlight/middlewares/handlers/file_action_handler.rb +6 -1
- data/lib/rails_spotlight/middlewares/handlers/sql_action_handler.rb +28 -3
- data/lib/rails_spotlight/support/project.rb +19 -0
- data/lib/rails_spotlight/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 797f782446bb2946abfc23b500dd6bed6032df02be0795e0d44083ca78344d19
|
4
|
+
data.tar.gz: a95afda90830aaa9520b1f88012091a3481ca6ac71fd031fda5f4e8dddd8b126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a44dc240578e5a9a639a666d6adcb5bee447e46d26af4d6f2fd3e8e1c1c39bb9129f1df13ca209a525a16413584e2a06405c1392e652c882d671389533524a
|
7
|
+
data.tar.gz: 047e4a531ef327f471a494d0865be7b2d2327572bfda8c5575638b62ebf768ab66d34c497177c3cf9b04586df6f95cace25ac234525acba17cea8d56c7a2ef0f
|
data/README.md
CHANGED
@@ -4,8 +4,8 @@ Chrome extension [Rails Spotlight](https://chrome.google.com/webstore/detail/rai
|
|
4
4
|
|
5
5
|
## Support for
|
6
6
|
|
7
|
-
Rails 5+
|
8
|
-
Ruby 2.6+
|
7
|
+
* Rails 5+
|
8
|
+
* Ruby 2.6+
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -17,6 +17,14 @@ group :development do
|
|
17
17
|
end
|
18
18
|
```
|
19
19
|
|
20
|
+
## Configuration
|
21
|
+
|
22
|
+
environment variables
|
23
|
+
|
24
|
+
```
|
25
|
+
RAILS_SPOTLIGHT_PROJECT=MyProjectName
|
26
|
+
```
|
27
|
+
|
20
28
|
## Testing
|
21
29
|
|
22
30
|
To run tests for all versions of Rails and Ruby, run:
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../../support/project'
|
4
|
+
|
3
5
|
module RailsSpotlight
|
4
6
|
module Middlewares
|
5
7
|
module Handlers
|
@@ -19,7 +21,10 @@ module RailsSpotlight
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def json_response_body
|
22
|
-
{
|
24
|
+
{
|
25
|
+
source: text_response_body,
|
26
|
+
project: ::RailsSpotlight::Support::Project.instance.name
|
27
|
+
}
|
23
28
|
end
|
24
29
|
|
25
30
|
def write_mode?
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../../support/project'
|
4
|
+
|
3
5
|
module RailsSpotlight
|
4
6
|
module Middlewares
|
5
7
|
module Handlers
|
@@ -8,22 +10,41 @@ module RailsSpotlight
|
|
8
10
|
if ActiveSupport.const_defined?('ExecutionContext')
|
9
11
|
ActiveSupport::Notifications.subscribed(method(:logger), 'sql.active_record', monotonic: true) do
|
10
12
|
ActiveSupport::ExecutionContext.set(rails_spotlight: request_id) do
|
11
|
-
|
13
|
+
transaction
|
12
14
|
end
|
13
15
|
end
|
14
16
|
else
|
15
17
|
ActiveSupport::Notifications.subscribed(method(:logger), 'sql.active_record') do
|
16
|
-
|
18
|
+
transaction
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
23
|
private
|
22
24
|
|
25
|
+
def transaction
|
26
|
+
ActiveRecord::Base.transaction do
|
27
|
+
begin
|
28
|
+
self.result = ActiveRecord::Base.connection.exec_query(query)
|
29
|
+
rescue => e
|
30
|
+
self.error = e
|
31
|
+
ensure
|
32
|
+
raise ActiveRecord::Rollback unless force_execution?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
23
37
|
attr_accessor :result
|
38
|
+
attr_accessor :error
|
24
39
|
|
25
40
|
def json_response_body
|
26
|
-
{
|
41
|
+
{
|
42
|
+
result: result,
|
43
|
+
logs: logs,
|
44
|
+
error: error.inspect,
|
45
|
+
query_mode: force_execution? ? 'force' : 'default',
|
46
|
+
project: ::RailsSpotlight::Support::Project.instance.name
|
47
|
+
}
|
27
48
|
end
|
28
49
|
|
29
50
|
def logger(_, started, finished, unique_id, payload)
|
@@ -39,6 +60,10 @@ module RailsSpotlight
|
|
39
60
|
def query
|
40
61
|
@query ||= json_request_body.fetch('query')
|
41
62
|
end
|
63
|
+
|
64
|
+
def force_execution?
|
65
|
+
@force_execution ||= json_request_body['mode'] == 'force'
|
66
|
+
end
|
42
67
|
end
|
43
68
|
end
|
44
69
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RailsSpotlight
|
2
|
+
module Support
|
3
|
+
class Project
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
def name
|
7
|
+
@name ||= ENV['RAILS_SPOTLIGHT_PROJECT'] || if app_class.respond_to?(:module_parent_name)
|
8
|
+
app_class.module_parent_name
|
9
|
+
else
|
10
|
+
app_class.parent_name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def app_class
|
15
|
+
@app_class ||= Rails.application.class
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pawel Niemczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-contrib
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/rails_spotlight/middlewares/handlers/verify_action_handler.rb
|
188
188
|
- lib/rails_spotlight/middlewares/request_handler.rb
|
189
189
|
- lib/rails_spotlight/railtie.rb
|
190
|
+
- lib/rails_spotlight/support/project.rb
|
190
191
|
- lib/rails_spotlight/version.rb
|
191
192
|
- sig/rails_spotlight.rbs
|
192
193
|
homepage: https://github.com/pniemczyk/rails_spotlight
|