class CHBuild::Config
Build configuration object
Attributes
before[R]
env[R]
path[R]
raw[R]
use[R]
version[R]
Public Class Methods
new(path_to_config)
click to toggle source
# File lib/chbuild/config.rb, line 15 def initialize(path_to_config) begin @path = path_to_config build_config = YAML.load_file(path_to_config) rescue Errno::ENOENT raise CHBuild::Config::NotFoundError, "'#{path_to_config}': file not found" end @errors = [] unless build_config @errors << 'Build file is empty' return end @raw = build_config @version = Version.new(build_config['version']) @use = Use.new(build_config['use']) @env = Env.new(build_config['env']) @before = Before.new(build_config['before']) end
Public Instance Methods
errors()
click to toggle source
# File lib/chbuild/config.rb, line 46 def errors all_errors = Array.new(@errors) instance_variables.each do |var| section = instance_variable_get(var) next unless section.respond_to?(:name) && section.respond_to?(:errors) section_name = section.send(:name) section_errors = section.send(:errors) section_errors.each do |err| all_errors << "#{section_name}: #{err}" end end all_errors end
init_script()
click to toggle source
# File lib/chbuild/config.rb, line 36 def init_script unless @init_script generation_time = "echo \"Generated at: [#{Time.now}]\"\n\n" env_script = @env.to_bash_script before_script = @before.to_bash_script @init_script = generation_time + env_script + before_script end @init_script end
inspect()
click to toggle source
# File lib/chbuild/config.rb, line 62 def inspect data = [] instance_variables.each do |var| section = instance_variable_get(var) if section.respond_to?(:name) section_name = section.send(:name) data << "#{section_name}: #{section.inspect}" end end data.join("\n") end