Sha256: 2bcd117432768c4ecba790d1e7676486768e604ec6cd9cc096d733a83da67d4a
Contents?: true
Size: 976 Bytes
Versions: 21
Compression:
Stored size: 976 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 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
21 entries across 21 versions & 1 rubygems