Sha256: 467f6732c803d6b9b51b2ab22bc0216014ff4d49b86be4b2f83f3abaa4ef400c
Contents?: true
Size: 518 Bytes
Versions: 5
Compression:
Stored size: 518 Bytes
Contents
module Nin class YamlStore DEFAULT_FILE = "#{ENV['HOME']}/.todos.yaml" attr_reader :file def initialize(file = DEFAULT_FILE) @file = file init_store end def read Psych.load_file(@file) || {} # Psych returns false if the file is empty end def write(hash) File.open(@file, 'w') do |file| file.write(Psych.dump(hash)) end end private def init_store return if File.exist?(@file) File.open(@file, "w") end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
nin-1.3.0 | lib/nin/yaml_store.rb |
nin-1.2.0 | lib/nin/yaml_store.rb |
nin-1.0.1 | lib/nin/yaml_store.rb |
nin-1.0.0 | lib/nin/yaml_store.rb |
nin-0.7.0 | lib/nin/yaml_store.rb |