Module: FileMarshal

Defined in:
lib/file_marshal/dumper.rb,
lib/file_marshal/facade.rb,
lib/file_marshal/loader.rb,
lib/file_marshal/writer.rb,
lib/file_marshal/version.rb,
lib/file_marshal/writer/file.rb,
lib/file_marshal/writer/temp.rb,
lib/file_marshal/file_attributes.rb

Defined Under Namespace

Classes: Dumper, FileAttributes, Loader, Writer

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.dump(file) ⇒ Object



2
3
4
5
# File 'lib/file_marshal/facade.rb', line 2

def self.dump(file)
  hash = FileMarshal::Dumper.new(file).to_hash
  hash.to_json
end

.load(string, path = nil) ⇒ Object



7
8
9
10
11
# File 'lib/file_marshal/facade.rb', line 7

def self.load(string, path=nil)
  hash = JSON.parse(string)
  loader = FileMarshal::Loader.new(hash)
  path ? loader.to_file(path) : loader.tempfile
end