Class: Canopus::Debug::Configuration
- Inherits:
-
Object
- Object
- Canopus::Debug::Configuration
- Defined in:
- lib/canopus/debug/configuration.rb
Constant Summary collapse
- RELATIVE_PATH =
File.join(".canopus", "launch.jsonc")
- MAX_BYTES =
1_048_576- MAX_CONFIGURATIONS =
128- MAX_DEPTH =
20- MAX_COLLECTION_SIZE =
1_024- MAX_STRING_BYTES =
65_536- MAX_EXPANDED_STRING_BYTES =
1_048_576- MAX_TOTAL_EXPANDED_BYTES =
1_048_576- MAX_ENVIRONMENT_ENTRY_BYTES =
1_048_576- MAX_ENVIRONMENT_BYTES =
1_048_576- VARIABLE =
/\$\{([^{}]+)\}/
Instance Attribute Summary collapse
-
#configurations ⇒ Object
readonly
Returns the value of attribute configurations.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #adapter(type, file: nil, line_number: nil, selected_text: nil) ⇒ Object
-
#initialize(root:, settings: Settings.new, environment: ENV) ⇒ Configuration
constructor
A new instance of Configuration.
- #resolve(configuration, file: nil, line_number: nil, selected_text: nil) ⇒ Object
Constructor Details
#initialize(root:, settings: Settings.new, environment: ENV) ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 28 29 |
# File 'lib/canopus/debug/configuration.rb', line 24 def initialize(root:, settings: Settings.new, environment: ENV) @root = canonical_root(root) @settings = settings @environment = snapshot_environment(environment) @configurations = load_configurations end |
Instance Attribute Details
#configurations ⇒ Object (readonly)
Returns the value of attribute configurations.
22 23 24 |
# File 'lib/canopus/debug/configuration.rb', line 22 def configurations @configurations end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
22 23 24 |
# File 'lib/canopus/debug/configuration.rb', line 22 def root @root end |
Instance Method Details
#adapter(type, file: nil, line_number: nil, selected_text: nil) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/canopus/debug/configuration.rb', line 42 def adapter(type, file: nil, line_number: nil, selected_text: nil) raise Error, "debug adapter type must be a string" unless type.is_a?(String) = @settings["debug_adapters"] = [type] if .is_a?(Hash) raise Error, "no debug adapter configured for #{type}" unless freeze_value((, context(file, line_number, selected_text), [MAX_TOTAL_EXPANDED_BYTES])) end |
#resolve(configuration, file: nil, line_number: nil, selected_text: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/canopus/debug/configuration.rb', line 31 def resolve(configuration, file: nil, line_number: nil, selected_text: nil) source = configuration.is_a?(String) ? @configurations.find { |item| item["name"] == configuration } : @configurations.find { |item| item.equal?(configuration) } raise Error, "unknown debug configuration" unless source resolved = (source, context(file, line_number, selected_text), [MAX_TOTAL_EXPANDED_BYTES]) %w[program cwd].each do |key| resolved[key] = project_path(resolved[key], key) if resolved.key?(key) end freeze_value(resolved) end |