Sha256: 7da1a760d28158e70ac4834c1e2a981eb59cbcebf4b1fcf3ceef01933a5fb67c

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

module Approvals

  class Dotfile
    class << self

      def reset
        File.delete(path) if File.exists?(path)
        touch
      end

      def path
        File.join(Approvals.project_dir, '.approvals')
      end

      def touch
        FileUtils.touch(path)
      end

      def append(text)
        unless includes?(text)
          write text
        end
      end

      def includes?(text)
        system("cat #{path} | grep -q \"^#{text}$\"")
      end

      def write(text)
        File.open(path, 'a+') do |f|
          f.write "#{text}\n"
        end
      end

    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
approvals-0.0.9 lib/approvals/utilities/dotfile.rb
approvals-0.0.8 lib/approvals/utilities/dotfile.rb