class XoltiConfig

Attributes

license[R]
offset[R]
project_info[R]
template[R]

Public Class Methods

find_config_file(path = Pathname.getwd) click to toggle source
# 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_config() click to toggle source
# File lib/config.rb, line 34
def self.load_config()
        raw_config = YAML.load(IO.binread(find_config_file()))
        XoltiConfig.new(raw_config)
end
new(raw_config) click to toggle source
# 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

Public Instance Methods

get_comment(ext) click to toggle source
# File lib/config.rb, line 49
def get_comment(ext)
        @comment[ext.delete('.')]
end

Private Instance Methods

extract_project_info(raw_project_info) click to toggle source
# File lib/config.rb, line 53
        def extract_project_info(raw_project_info)
        {
                author: raw_project_info["author"],
                project_name: raw_project_info["project_name"],
                year: raw_project_info["year"] || Date.today().year.to_s
        }
end
extract_template_if_present(raw_config) click to toggle source
# File lib/config.rb, line 61
        def extract_template_if_present(raw_config)
        return raw_config["template"] if raw_config.include?("template")
        default_template_path = Resources.get_template_path(@license)
        return IO.binread(default_template_path) if File.exists?(default_template_path)
        nil
end