Class: InfinityTest::Heuristics

Inherits:
Object
  • Object
show all
Defined in:
lib/infinity_test/heuristics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHeuristics

Returns a new instance of Heuristics.



5
6
7
8
9
# File 'lib/infinity_test/heuristics.rb', line 5

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

Instance Attribute Details

#patternsObject (readonly)

Returns the value of attribute patterns.



3
4
5
# File 'lib/infinity_test/heuristics.rb', line 3

def patterns
  @patterns
end

#scriptObject (readonly)

Returns the value of attribute script.



3
4
5
# File 'lib/infinity_test/heuristics.rb', line 3

def script
  @script
end

Instance Method Details

#add(pattern, &block) ⇒ Object



11
12
13
14
15
# File 'lib/infinity_test/heuristics.rb', line 11

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

#allObject



27
28
29
# File 'lib/infinity_test/heuristics.rb', line 27

def all
  @patterns.keys
end

#remove(pattern) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/infinity_test/heuristics.rb', line 17

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

#run(options) ⇒ Object



31
32
33
# File 'lib/infinity_test/heuristics.rb', line 31

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