Class: Rdm::SourceParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rdm/source_parser.rb

Defined Under Namespace

Classes: SourceValidationError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_path, stdout) ⇒ SourceParser

Returns a new instance of SourceParser.



13
14
15
16
# File 'lib/rdm/source_parser.rb', line 13

def initialize(source_path, stdout)
  @source_path = source_path
  @stdout      = stdout || STDOUT
end

Instance Attribute Details

#source_pathObject

Returns the value of attribute source_path.



11
12
13
# File 'lib/rdm/source_parser.rb', line 11

def source_path
  @source_path
end

Class Method Details

.read_and_init_source(source_path, stdout: nil) ⇒ Object



6
7
8
# File 'lib/rdm/source_parser.rb', line 6

def read_and_init_source(source_path, stdout: nil)
  Rdm::SourceParser.new(source_path, stdout).read_and_init_source
end

Instance Method Details

#parse_source_contentRdm::Source

Parse source file and return Source object

Returns:



39
40
41
42
43
# File 'lib/rdm/source_parser.rb', line 39

def parse_source_content
  source = Rdm::Source.new(root_path: root_path)
  source.instance_eval(source_content)
  source
end

#read_and_init_sourceRdm::Source

Read source file, parse and init it’s packages and configs

Parameters:

  • source_path (String)

    Source file path

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rdm/source_parser.rb', line 21

def read_and_init_source
  source = parse_source_content

  # Setup Rdm
  if block = source.setup_block
    Rdm.setup(&block)
  end
  validate_rdm_settings!

  init_and_set_packages(source)
  init_and_set_configs(source)
  init_and_set_env_variables(source)
  source.init_with(packages: packages, configs: configs)
  source
end