Sha256: 5e502ad607230517c0a91a514fb87f48d7474159120baf342a9659b0f27a2dca
Contents?: true
Size: 966 Bytes
Versions: 1
Compression:
Stored size: 966 Bytes
Contents
require_relative '../errors' require_relative '../../dir' module Warp module Dir module Serializer class Dotfile < Base def restore! File.open(Warp::Dir.absolute(config.warprc), "r") do |f| f.each_line do |line| line = line.chomp next if line.blank? name, path = line.split(/:/) if name.nil? || path.nil? raise Warp::Dir::Errors::StoreFormatError.new("File may be corrupt - #{config.warprc}:#{line}", line) end store.add point_name: name, point_path: path end end end def persist! File.open(Warp::Dir.absolute(config.warprc), 'w') do |file| buffer = '' store.points.each do |point| buffer << "#{point.name}:#{point.relative_path}\n" end file.write(buffer) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
warp-dir-1.1.0 | lib/warp/dir/serializer/dotfile.rb |