Class: Clian::Config::Toplevel
Overview
Syntax table manipulation
Constant Summary collapse
- DEFAULT_DIR =
ENV["XDG_CONFIG_HOME"] || "~/.config"
- DEFAULT_FILE =
"config.yml"
Instance Attribute Summary
Attributes inherited from Element
Class Method Summary collapse
- .create_from_file(file_name = self.default_path) ⇒ Object
- .default_home(package_name) ⇒ Object
- .default_path(package_name) ⇒ Object
Methods inherited from Element
create_from_yaml_file, create_from_yaml_string, define_syntax, #get_value, #initialize, syntax, #to_hash, #to_yaml
Constructor Details
This class inherits a constructor from Clian::Config::Element
Class Method Details
.create_from_file(file_name = self.default_path) ⇒ Object
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/clian/config.rb', line 193 def self.create_from_file(file_name = self.default_path) unless File.exists?(File.(file_name)) raise ConfigurationError, "config file '#{file_name}' not found" end begin return create_from_yaml_file(file_name) rescue Psych::SyntaxError, Clian::ConfigurationError => e raise ConfigurationError, e. end end |
.default_home(package_name) ⇒ Object
185 186 187 |
# File 'lib/clian/config.rb', line 185 def self.default_home(package_name) File.join(DEFAULT_DIR, package_name) end |
.default_path(package_name) ⇒ Object
189 190 191 |
# File 'lib/clian/config.rb', line 189 def self.default_path(package_name) File.join(default_home(package_name), DEFAULT_FILE) end |