class Expd::Config
Public Class Methods
defaults()
click to toggle source
Return a configuration loaded from the default config file
# File lib/expd/config.rb, line 34 def self.defaults new File.expand_path("~/.expd_snippets") end
new(filename)
click to toggle source
# File lib/expd/config.rb, line 10 def initialize(filename) @filename = filename @conf = {} load_from_file! end
Public Instance Methods
load_from_file!()
click to toggle source
Load the configuration from its file if it exists. This already performed on instance creation.
# File lib/expd/config.rb, line 18 def load_from_file! @conf = YAML.load_file @filename if File.exist?(@filename) @conf[:snippets] ||= {} end
save!()
click to toggle source
Save the configuration on disk
# File lib/expd/config.rb, line 24 def save! File.open(@filename, "w") { |f| f.write YAML.dump(@conf) } end
snippets()
click to toggle source
Shortcut to get the snippets
# File lib/expd/config.rb, line 29 def snippets self[:snippets] end