Sha256: b453ec318a78274b691ae6ee58f849681505b8f2bfbfd16995cd321ea47eb036

Contents?: true

Size: 875 Bytes

Versions: 3

Compression:

Stored size: 875 Bytes

Contents

module Timber
  class CLI
    module FileHelper
      def self.append(path, contents)
        File.open(path, "a") do |f|
          f.write(contents)
        end
      end

      def self.read_or_create(path, contents)
        if !File.exists?(path)
          write(path, contents)
        end

        File.read(path)
      end

      def self.read(path)
        File.read(path)
      end

      def self.write(path, contents)
        File.open(path, "w") do |f|
          f.write(contents)
        end
      end

      def self.verify(path, io)
        if !File.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

3 entries across 3 versions & 1 rubygems

Version Path
timber-2.1.0.rc3 lib/timber/cli/file_helper.rb
timber-2.1.0.rc2 lib/timber/cli/file_helper.rb
timber-2.1.0.rc1 lib/timber/cli/file_helper.rb