Sha256: 7030497b20476204c345b5e06467ac378c531c5379e131749ee4411e9b5e0b36

Contents?: true

Size: 560 Bytes

Versions: 3

Compression:

Stored size: 560 Bytes

Contents

module Approvals

  class Dotfile
    class << self

      def reset
        File.truncate(path, 0) if File.exists?(path)
      end

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

      private

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

      def includes?(text)
        system("cat #{path} 2> /dev/null | 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

3 entries across 3 versions & 1 rubygems

Version Path
approvals-0.0.20 lib/approvals/dotfile.rb
approvals-0.0.19 lib/approvals/dotfile.rb
approvals-0.0.18 lib/approvals/dotfile.rb