Sha256: 5c0659e718e2d94c90ac71d25d03b35a1d2e20cf6c3c9c9a0f20747413b8099e

Contents?: true

Size: 646 Bytes

Versions: 3

Compression:

Stored size: 646 Bytes

Contents

module Retest
  class ListenOptions
    IGNORE_REGEX = /node_modules|tmp|\.sqlite|\.byebug_history/

    class << self
      def to_h(tool = GitTool.new)
        return {ignore: IGNORE_REGEX, relative: true} unless tool.installed?

        {only: regex_for(tool.files), relative: true}
      end

      private

      def regex_for(files)
        Regexp.new files.split("\n").join('|')
      end
    end
  end

  class GitTool
    attr_reader :name
    alias :to_s :name

    def initialize
      @name = 'git'
    end

    def installed?
      system "git -C . rev-parse 2>/dev/null"
    end

    def files
      `git ls-files`
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
retest-0.7.0 lib/retest/listen_options.rb
retest-0.6.0 lib/retest/listen_options.rb
retest-0.6.0.pre3 lib/retest/listen_options.rb