2003-05-10 01:25:50 +04:00
|
|
|
#
|
|
|
|
# YAML::Store
|
|
|
|
#
|
|
|
|
require 'yaml'
|
|
|
|
require 'pstore'
|
|
|
|
|
2004-05-27 11:43:38 +04:00
|
|
|
class YAML::Store < PStore
|
|
|
|
def initialize( *o )
|
|
|
|
@opt = YAML::DEFAULTS.dup
|
|
|
|
if String === o.first
|
|
|
|
super(o.shift)
|
|
|
|
end
|
|
|
|
if o.last.is_a? Hash
|
|
|
|
@opt.update(o.pop)
|
|
|
|
end
|
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2004-05-27 11:43:38 +04:00
|
|
|
def dump(table)
|
|
|
|
@table.to_yaml(@opt)
|
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2004-05-27 11:43:38 +04:00
|
|
|
def load(content)
|
|
|
|
YAML::load(content)
|
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
|
2004-05-27 11:43:38 +04:00
|
|
|
def load_file(file)
|
|
|
|
YAML::load(file)
|
|
|
|
end
|
2003-05-10 01:25:50 +04:00
|
|
|
end
|