Sha256: acde2fba94a3c5f18a68002b671aec321b37557c4ce3feb70b573d79c1461fbd

Contents?: true

Size: 731 Bytes

Versions: 4

Compression:

Stored size: 731 Bytes

Contents

module InfinityTest
  class Heuristics
    attr_reader :patterns, :script

    def initialize
      @patterns = {}
      @script = InfinityTest.watchr
      @application = InfinityTest.application
    end

    def add(pattern, &block)
      @patterns[pattern] = block
      @script.watch(pattern, &block) # Watchr
      @patterns
    end

    def remove(pattern)
      if pattern == :all
        @patterns.clear
        @script.rules.clear
      else
        @patterns.delete(pattern)
        @script.rules.delete_if { |rule| rule.pattern == pattern }
      end
    end

    def all
      @patterns.keys
    end

    def run(options)
      @application.run_commands_for_file(@application.files_to_run!(options))
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
infinity_test-1.0.3 lib/infinity_test/heuristics.rb
infinity_test-1.0.2 lib/infinity_test/heuristics.rb
infinity_test-1.0.1 lib/infinity_test/heuristics.rb
infinity_test-1.0.0 lib/infinity_test/heuristics.rb