class Warp::Dir::Serializer::Dotfile

Serializer only assumes that Points can serialize themselves or deserialize themselves to/from a one-line text format.

Public Instance Methods

persist!() click to toggle source
# File lib/warp/dir/serializer/dotfile.rb, line 30
def persist!
  File.open(warprc_file_path, 'wt') do |file|
    buffer = ''
    store.points.each do |point|
      buffer << "#{point.serialize}\n"
    end
    file.write(buffer)
  end
end
restore!() click to toggle source
# File lib/warp/dir/serializer/dotfile.rb, line 15
def restore!
  unless File.exist?(warprc_file_path)
    $stderr.puts "No warprc file found in the path #{warprc_file_path}" if config.debug
    return
  end
  File.open(warprc_file_path, 'r') do |f|
    f.each_line do |line|
      line = line.chomp
      next if line.blank?
      line.gsub!(/["']/,'') # remove any quotes that may have been inserted
      store.add(point: Warp::Dir::Point.deserialize(line))
    end
  end
end
warprc_file_path() click to toggle source
# File lib/warp/dir/serializer/dotfile.rb, line 11
def warprc_file_path
  Warp::Dir.absolute(config.warprc)
end