Class: RubyBindgen::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-bindgen/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_path) ⇒ Config

Returns a new instance of Config.



6
7
8
9
10
11
12
13
14
15
# File 'lib/ruby-bindgen/config.rb', line 6

def initialize(config_path)
  @config_dir = File.dirname(File.expand_path(config_path))
  raw = YAML.safe_load(File.read(config_path), permitted_classes: [], permitted_symbols: [], aliases: true)
  # YAML.safe_load returns nil for an empty file. Treat that as an empty
  # config so the CLI's validate_config can produce its useful "Config
  # must specify 'output'" message instead of a NoMethodError.
  @data = raw.is_a?(Hash) ? symbolize_keys(raw) : {}
  resolve_toolchain
  resolve_paths
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/ruby-bindgen/config.rb', line 17

def [](key)
  @data[key]
end

#[]=(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Used by tests for ad-hoc overrides and by the CLI to default :input to :output. Not intended for downstream code; the public contract is read-only.



24
25
26
# File 'lib/ruby-bindgen/config.rb', line 24

def []=(key, value)
  @data[key] = value
end