Sha256: 1f86d6f2fb35bdce88b62f96b8b593ae74e455466357d92312e303006e6dadfa
Contents?: true
Size: 1022 Bytes
Versions: 10
Compression:
Stored size: 1022 Bytes
Contents
module Timber class CLI class FileHelper attr_reader :api def initialize(api) @api = api end def append(path, contents) File.open(path, "a") do |f| f.write(contents) end end def exists?(path) File.exists?(path) end def read_or_create(path, contents) if !exists?(path) write(path, contents) end read(path) end def read(path) File.read(path) end def write(path, contents) File.open(path, "w") do |f| f.write(contents) end api.event(:file_written, path: path) end def verify(path, io) if !exists?(path) io.puts "" io.puts "Uh oh! It looks like we couldn't locate the #{path} file. " io.puts "Please enter the correct path:" io.puts new_path = io.gets verify(new_path, io) else path end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems