Class: Plumbo::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/plumbo/configuration.rb

Overview

Runtime configuration for the panel. Defaults are dev-only and safe; override in an initializer via Plumbo.configure { |c| ... }.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



34
35
36
37
38
39
40
41
42
# File 'lib/plumbo/configuration.rb', line 34

def initialize
  @enabled = rails_development?
  @max_files = 500
  @path_prefix = "@"
  @include_stimulus = true
  @highlight = true
  @javascript_root = "app/javascript"
  @root = nil
end

Instance Attribute Details

#enabledObject

Whether the panel is injected. Defaults to true only in Rails development.



8
9
10
# File 'lib/plumbo/configuration.rb', line 8

def enabled
  @enabled
end

#highlightObject

Whether hovering a view/partial/layout row highlights its rendered region on the page. Defaults to true. When on, Plumbo enables Rails' built-in annotate_rendered_view_with_filenames so the rendered HTML carries the BEGIN/END comment markers the highlight reads. Turn off to leave the host app's HTML untouched (highlighting then does nothing).



26
27
28
# File 'lib/plumbo/configuration.rb', line 26

def highlight
  @highlight
end

#include_stimulusObject

Whether to list Stimulus controllers found via data-controller attributes in the rendered HTML. Defaults to true.



19
20
21
# File 'lib/plumbo/configuration.rb', line 19

def include_stimulus
  @include_stimulus
end

#javascript_rootObject

Source directory Stimulus controllers are mapped into. Combined with the "controllers/" subdirectory and the Stimulus identifier to form the path.



30
31
32
# File 'lib/plumbo/configuration.rb', line 30

def javascript_root
  @javascript_root
end

#max_filesObject

Hard cap on the number of files listed (guards against runaway pages).



11
12
13
# File 'lib/plumbo/configuration.rb', line 11

def max_files
  @max_files
end

#path_prefixObject

Prefix added to each listed path. "@" makes the list paste-ready as file mentions for an AI assistant; set to "" for bare paths.



15
16
17
# File 'lib/plumbo/configuration.rb', line 15

def path_prefix
  @path_prefix
end

#rootObject

Project root, used to (a) filter render events down to app files and (b) make listed paths relative. Defaults to Rails.root, then the cwd.



46
47
48
# File 'lib/plumbo/configuration.rb', line 46

def root
  @root ||= rails_root || Dir.pwd
end