Sha256: 28522f0e2d4596c710647dc6516c89cf525f7f21af700b8bd6c10ab034577ca3

Contents?: true

Size: 691 Bytes

Versions: 3

Compression:

Stored size: 691 Bytes

Contents

require 'git'

module Orly
  class NoRepo < StandardError ; end

  class Tester

    def initialize
      @need_bundle = false
      @need_migrate = false
      run_tests
    rescue ArgumentError
      raise NoRepo.new
    end

    def run_tests
      get_diff.each do |file|
        if file.path =~ /^Gemfile/
          @need_bundle = true
        elsif file.path =~ /^db\/migrate/
          @need_migrate = true
        end
      end
    rescue Git::GitExecuteError
      false
    end

    def get_diff
      git = Git.open('.')
      git.diff('HEAD@{1}','HEAD')
    end

    def need_migrate?
      @need_migrate
    end

    def need_bundle_install?
      @need_bundle
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
orly-0.0.6 lib/orly/tester.rb
orly-0.0.5 lib/orly/tester.rb
orly-0.0.4 lib/orly/tester.rb