Class: YamlMaster::Context

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master_path, properties) ⇒ Context

Returns a new instance of Context.



110
111
112
113
# File 'lib/yaml_master.rb', line 110

def initialize(master_path, properties)
  @master_path = master_path
  @properties = properties
end

Instance Attribute Details

#master_pathObject (readonly)

Returns the value of attribute master_path.



108
109
110
# File 'lib/yaml_master.rb', line 108

def master_path
  @master_path
end

#propertiesObject (readonly)

Returns the value of attribute properties.



108
109
110
# File 'lib/yaml_master.rb', line 108

def properties
  @properties
end

Instance Method Details

#read_file_if_exist(path) ⇒ Object



119
120
121
122
# File 'lib/yaml_master.rb', line 119

def read_file_if_exist(path)
  return nil unless File.exist?(path)
  File.read(path)
end

#render_masterObject



124
125
126
# File 'lib/yaml_master.rb', line 124

def render_master
  ERB.new(File.read(@master_path)).result(binding)
end

#user_homeObject



115
116
117
# File 'lib/yaml_master.rb', line 115

def user_home
  Pathname(ENV["HOME"])
end