Class: XoltiConfig

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_config) ⇒ XoltiConfig

Returns a new instance of XoltiConfig.



41
42
43
44
45
46
47
# File 'lib/config.rb', line 41

def initialize(raw_config)
	@project_info = extract_project_info(raw_config["project_info"])
	@comment = DefaultComment::HASH.merge!(raw_config["comment"] || {})
	@license = raw_config["license"]
	@template = extract_template_if_present(raw_config)
	@offset = raw_config["offset"] || 0
end

Instance Attribute Details

#licenseObject (readonly)

Returns the value of attribute license.



39
40
41
# File 'lib/config.rb', line 39

def license
  @license
end

#offsetObject (readonly)

Returns the value of attribute offset.



39
40
41
# File 'lib/config.rb', line 39

def offset
  @offset
end

#project_infoObject (readonly)

Returns the value of attribute project_info.



39
40
41
# File 'lib/config.rb', line 39

def project_info
  @project_info
end

#templateObject (readonly)

Returns the value of attribute template.



39
40
41
# File 'lib/config.rb', line 39

def template
  @template
end

Class Method Details

.find_config_file(path = Pathname.getwd) ⇒ Object



27
28
29
30
31
32
# File 'lib/config.rb', line 27

def self.find_config_file(path = Pathname.getwd)
	potential_config_file = (path + "xolti.yml")
	return potential_config_file.to_s if potential_config_file.file?
	raise "No xolti.yml found" if path.root?
	find_config_file(path.parent)
end

.load_configObject



34
35
36
37
# File 'lib/config.rb', line 34

def self.load_config()
	raw_config = YAML.load(IO.binread(find_config_file()))
	XoltiConfig.new(raw_config)
end

Instance Method Details

#get_comment(ext) ⇒ Object



49
50
51
# File 'lib/config.rb', line 49

def get_comment(ext)
	@comment[ext.delete('.')]
end