Sha256: e5033c42bf9d755a5b393589897a9467604e48bd12b0953f5cde41e10c4eb619

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

module Retest
  class Setup
    def self.type
      new.type
    end

    def type
      @type ||= begin
        return :ruby unless has_lock_file?

        if rspec?
          :rspec
        elsif rails?
          :rails
        elsif rake?
          :rake
        else
          :ruby
        end
      end
    end

    private

    def has_lock_file?
      File.exist? 'Gemfile.lock'
    end

    def rspec?
      has_gem? 'rspec'
    end

    def rails?
      File.exist? 'bin/rails'
    end

    def rake?
      has_gem? 'rake'
    end

    def has_gem?(gem_name)
      !`cat Gemfile.lock | grep #{gem_name}`.empty?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
retest-1.0.0 lib/retest/setup.rb
retest-1.0.0.pre2 lib/retest/setup.rb