view_component_devtools 0.1.5 → 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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d5ebb0adeb3fc06e01d4314298bf053e7374116ad151f93b4f26a0b45effef3
|
|
4
|
+
data.tar.gz: 716644f07896916f726dd42ef7908998896209e00045a459e9943c782a962ad0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28e32d5d480906e613e9aa6fd330e8d3a6a2d59f87d955cd047fa6b3d00880c7dfafc0efd25f25f14697cee25e23e5582fbbee5b91b4b7bad0b8ea3c0cd1cbaf
|
|
7
|
+
data.tar.gz: 9c2adc18f06c16d29961921f37a3c9ec3cce8afc9172b336697b65cc28562e8801578319f4649c2a9387f7237a1e63c241601cc8bad869aab6b1fd4dbd510e3c
|
|
@@ -13,8 +13,7 @@ module ViewComponentDevtools
|
|
|
13
13
|
/token/i
|
|
14
14
|
].freeze
|
|
15
15
|
|
|
16
|
-
attr_accessor :
|
|
17
|
-
:enabled,
|
|
16
|
+
attr_accessor :enabled,
|
|
18
17
|
:max_collection_size,
|
|
19
18
|
:max_depth,
|
|
20
19
|
:max_string_length,
|
|
@@ -22,7 +21,6 @@ module ViewComponentDevtools
|
|
|
22
21
|
|
|
23
22
|
def initialize
|
|
24
23
|
@enabled = false
|
|
25
|
-
@allow_non_development = false
|
|
26
24
|
@max_depth = 8
|
|
27
25
|
@max_collection_size = 50
|
|
28
26
|
@max_string_length = 2_000
|
|
@@ -30,7 +28,7 @@ module ViewComponentDevtools
|
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
def enabled_for?(environment)
|
|
33
|
-
enabled &&
|
|
31
|
+
enabled && environment.to_s == "development"
|
|
34
32
|
end
|
|
35
33
|
end
|
|
36
34
|
end
|
|
@@ -5,18 +5,25 @@ require "rails/engine"
|
|
|
5
5
|
module ViewComponentDevtools
|
|
6
6
|
class Engine < ::Rails::Engine
|
|
7
7
|
initializer "view_component_devtools.middleware" do |application|
|
|
8
|
+
next unless ViewComponentDevtools.development_environment?
|
|
9
|
+
|
|
8
10
|
application.middleware.use Middleware
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
initializer "view_component_devtools.helper" do
|
|
14
|
+
next unless ViewComponentDevtools.development_environment?
|
|
15
|
+
|
|
12
16
|
ActiveSupport.on_load(:action_view) { include Helper }
|
|
13
17
|
end
|
|
14
18
|
|
|
15
19
|
initializer "view_component_devtools.subscriber" do
|
|
20
|
+
next unless ViewComponentDevtools.development_environment?
|
|
21
|
+
|
|
16
22
|
Subscriber.install!
|
|
17
23
|
end
|
|
18
24
|
|
|
19
25
|
config.after_initialize do
|
|
26
|
+
ViewComponentDevtools.validate_environment!
|
|
20
27
|
next unless ViewComponentDevtools.capture_enabled?
|
|
21
28
|
|
|
22
29
|
Rails.application.config.view_component.instrumentation_enabled = true
|
|
@@ -10,6 +10,9 @@ module ViewComponentDevtools
|
|
|
10
10
|
|
|
11
11
|
class << self
|
|
12
12
|
def start!(request_id: nil)
|
|
13
|
+
unless ViewComponentDevtools.development_environment?
|
|
14
|
+
raise "ViewComponent DevTools state can only start in development"
|
|
15
|
+
end
|
|
13
16
|
raise "ViewComponent DevTools capture already active" if active?
|
|
14
17
|
|
|
15
18
|
ActiveSupport::IsolatedExecutionState[KEY] = Session.new(
|
|
@@ -19,6 +19,16 @@ module ViewComponentDevtools
|
|
|
19
19
|
configuration.enabled_for?(environment)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def development_environment?(environment = rails_environment)
|
|
23
|
+
environment.to_s == "development"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def validate_environment!(environment = rails_environment)
|
|
27
|
+
return unless configuration.enabled && !development_environment?(environment)
|
|
28
|
+
|
|
29
|
+
raise "ViewComponent DevTools can only be enabled in development"
|
|
30
|
+
end
|
|
31
|
+
|
|
22
32
|
private
|
|
23
33
|
|
|
24
34
|
def rails_environment
|
|
@@ -27,10 +37,12 @@ module ViewComponentDevtools
|
|
|
27
37
|
end
|
|
28
38
|
end
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
require_relative "view_component_devtools/
|
|
32
|
-
require_relative "view_component_devtools/
|
|
33
|
-
require_relative "view_component_devtools/
|
|
34
|
-
require_relative "view_component_devtools/
|
|
35
|
-
require_relative "view_component_devtools/
|
|
40
|
+
if ViewComponentDevtools.development_environment?
|
|
41
|
+
require_relative "view_component_devtools/normalizer"
|
|
42
|
+
require_relative "view_component_devtools/state"
|
|
43
|
+
require_relative "view_component_devtools/component"
|
|
44
|
+
require_relative "view_component_devtools/subscriber"
|
|
45
|
+
require_relative "view_component_devtools/middleware"
|
|
46
|
+
require_relative "view_component_devtools/helper"
|
|
47
|
+
end
|
|
36
48
|
require_relative "view_component_devtools/engine"
|