Class: InfinityTest::Heuristics
- Inherits:
-
Object
- Object
- InfinityTest::Heuristics
- Defined in:
- lib/infinity_test/heuristics.rb
Instance Attribute Summary collapse
-
#patterns ⇒ Object
readonly
Returns the value of attribute patterns.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
Instance Method Summary collapse
- #add(pattern, &block) ⇒ Object
- #all ⇒ Object
-
#initialize ⇒ Heuristics
constructor
A new instance of Heuristics.
- #remove(pattern) ⇒ Object
- #run(options) ⇒ Object
Constructor Details
#initialize ⇒ Heuristics
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
#patterns ⇒ Object (readonly)
Returns the value of attribute patterns.
3 4 5 |
# File 'lib/infinity_test/heuristics.rb', line 3 def patterns @patterns end |
#script ⇒ Object (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 |
#all ⇒ Object
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() @application.run_commands_for_file(@application.files_to_run!()) end |