Class: Inch::Codebase::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/inch/codebase/serializer.rb

Constant Summary collapse

INCH_DB_DIR =
File.join(".inch", "db")

Class Method Summary collapse

Class Method Details

.filename(revision) ⇒ Object



6
7
8
# File 'lib/inch/codebase/serializer.rb', line 6

def self.filename(revision)
  File.join(INCH_DB_DIR, revision)
end

.load(filename) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/inch/codebase/serializer.rb', line 16

def self.load(filename)
  codebase = Marshal.load( File.binread(filename) )
  codebase.objects.each do |object|
    object.object_lookup = codebase.objects
  end
  codebase
end

.save(codebase, filename) ⇒ Object



10
11
12
13
14
# File 'lib/inch/codebase/serializer.rb', line 10

def self.save(codebase, filename)
  content = Marshal.dump(codebase)
  FileUtils.mkdir_p( File.dirname(filename) )
  File.open(filename, 'wb') { |file| file.write(content) }
end