Sha256: 2ff11d0dda730bc7d4dd00385c447ce50bc204703b337e14cb98bb28ee88da75
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
Contents
require 'yaml' class Stencil class Config class <<self @@cache = nil @@path = File.expand_path('~/.stencil.yml') def create write(:projects => {}, :templates => {}) end def read if @@cache @@cache elsif File.exists?(@@path) File.open(@@path, 'r') do |f| @@cache = YAML::load f end else create @@cache = read end end def update(hash) write read.deep_merge(hash) end def delete @@cache = nil File.unlink @@path end def exists?(type, name) read[type] && ( read[type][name.intern] || ( read[type][File.basename(name).intern] && read[type][File.basename(name).intern][:path] == name ) ) end private def write(hash) @@cache = nil File.open(@@path, 'w') do |f| f.write YAML::dump(hash) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems