lib/nutella_lib/persist.rb in nutella_lib-0.2.0 vs lib/nutella_lib/persist.rb in nutella_lib-0.2.1
- old
+ new
@@ -1,15 +1,20 @@
require 'json'
require 'pstore'
+require 'fileutils'
module Nutella
module Persist
# This module exposes a single method to retrieve a JSONStore
def Persist.getJsonStore(file_name)
- JSONStore.new(file_name)
+ dir = file_name[0..file_name.rindex('/')]
+ file = file_name[file_name.rindex('/')..file_name.length-1]
+ new_dir = dir + Nutella.run_id
+ FileUtils.mkdir_p new_dir
+ JSONStore.new(new_dir + file)
end
end
# JSONStore provides the same functionality as PStore, except it uses JSON
@@ -40,9 +45,14 @@
# store = JSONStore.new("my_file.json")
# hash = store.transaction { store.to_h }
def to_h
@table
end
+
+ def merge!( hash )
+ @table.merge!(hash)
+ end
+
def marshal_dump_supports_canonical_option?
false
end