Class: Muwu::ProjectOptionsReader

Inherits:
Object
  • Object
show all
Includes:
Muwu
Defined in:
lib/muwu/project_options_builder/project_options_reader.rb

Constant Summary

Constants included from Muwu

GEM_HOME_LIB, GEM_HOME_LIB_MUWU, VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Muwu

debug, read

Constructor Details

#initializeProjectOptionsReader

Returns a new instance of ProjectOptionsReader.



25
26
27
28
29
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 25

def initialize
  @options_from_file = {}
  @options_validated = {}
  @project_options = ProjectOptions.new
end

Instance Attribute Details

#options_from_fileObject

Returns the value of attribute options_from_file.



11
12
13
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 11

def options_from_file
  @options_from_file
end

#options_validatedObject

Returns the value of attribute options_validated.



11
12
13
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 11

def options_validated
  @options_validated
end

#project_optionsObject

Returns the value of attribute project_options.



11
12
13
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 11

def project_options
  @project_options
end

Class Method Details

.build {|builder| ... } ⇒ Object

Yields:

  • (builder)


18
19
20
21
22
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 18

def self.build
  builder = new
  yield(builder)
  builder.project_options
end

Instance Method Details

#build_from_ymlfile(project) ⇒ Object



36
37
38
39
40
41
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 36

def build_from_ymlfile(project)
  @project = project
  phase_1_read_options_file
  phase_2_validate_options_file
  phase_3_set_project_options
end

#phase_1_read_options_fileObject



44
45
46
47
48
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 44

def phase_1_read_options_file
  if ProjectValidator.new(@project).validate_file_options
    @options_from_file = YAML.load_file(@project.options_filename)
  end
end

#phase_2_validate_options_fileObject



51
52
53
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 51

def phase_2_validate_options_file
  @options_validated = validate_options(@options_from_file)
end

#phase_3_set_project_optionsObject



56
57
58
59
60
# File 'lib/muwu/project_options_builder/project_options_reader.rb', line 56

def phase_3_set_project_options
  @options_validated.each_pair do |key, value|
    @project_options.set_option(key, value)
  end
end