Sha256: ac86b3f67ad5e5ee522f047afe00082dfaf76d7f6fd78d097563cb445f77556d

Contents?: true

Size: 865 Bytes

Versions: 9

Compression:

Stored size: 865 Bytes

Contents

require 'forgitter'

module Forgitter
  class Runner
    def initialize(options = Forgitter::DEFAULT_OPTIONS)
      @ignorefiles = Forgitter.filter(options)
    end

    def run
      failcnt = 0
      output = ''
      @ignorefiles.each do |ignorefile|
        ignore_file = get_ignore_file(ignorefile[:path])
        if ignore_file
          output += "# #{ignorefile[:path]}\n"
          output += ignore_file
        else
          failcnt += 1
        end
      end
      exit(1) if failcnt == @ignorefiles.length

      puts output
    end

    private

    # Given a filename on the gitignore repo, return a string with the contents of the file
    def get_ignore_file(filename)
      begin
        IO.read(File.join(DATA_PATH, filename))
      rescue Errno::ENOENT
        STDERR.puts "#{filename} does not exist!"
        false
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
forgitter-0.1.4 lib/forgitter/runner.rb
forgitter-0.1.3 lib/forgitter/runner.rb
forgitter-0.1.2 lib/forgitter/runner.rb
forgitter-0.1.1 lib/forgitter/runner.rb
forgitter-0.1.0 lib/forgitter/runner.rb
forgitter-0.0.12 lib/forgitter/runner.rb
forgitter-0.0.11 lib/forgitter/runner.rb
forgitter-0.0.10 lib/forgitter/runner.rb
forgitter-0.0.9 lib/forgitter/runner.rb