Sha256: d18cd52b9c338089fccf99dbba9739e91d403663c6964596b484570e204d058d
Contents?: true
Size: 1.3 KB
Versions: 16
Compression:
Stored size: 1.3 KB
Contents
require 'fileutils' require 'yaml' require 'delicious-cli/log' ################################################################# HOMEDIR = File.expand_path("~") CONFIGDIR = File.join(HOMEDIR, ".delicious") ################################################################# ################################################################# class FileNotFound < IOError; end ################################################################# ################################################################# def configfile(filename, check=false) path = File.join(CONFIGDIR, filename) if check and not File.exists? path raise FileNotFound, path end path end ################################################################# ################################################################# unless File.exists? CONFIGDIR puts puts "* Creating new configuration directory: #{CONFIGDIR}" FileUtils.mkdir_p CONFIGDIR end class Settings def self.settings @settings ||= {} end def self.[](key) settings[key] end def self.[]=(key, val) settings[key] = val end def self.load! @settings = YAML::load_file( configfile('settings.yml') ) end def self.save! open( configfile('settings.yml'), "w" ) do |f| f.write YAML::dump(settings) end end end
Version data entries
16 entries across 16 versions & 2 rubygems