Sha256: 791032902e24c12c49c6d38a09fcd9e7213d822702ed67b24bea958cc3ff7bce
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
require_relative '../errors' require_relative '../../dir' module Warp module Dir module Serializer class Dotfile < Base def warprc_file_path Warp::Dir.absolute(config.warprc) end 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? 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(warprc_file_path, 'wt') 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
4 entries across 4 versions & 1 rubygems