Class: Autowatchr::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



8
9
10
11
12
13
14
15
16
17
# File 'lib/autowatchr.rb', line 8

def initialize(options = {})
  @failing_only = @run_suite = true

  options.each_pair do |key, value|
    method = "#{key}="
    if self.respond_to?(method)
      self.send(method, value)
    end
  end
end

Instance Attribute Details

#commandObject



19
20
21
# File 'lib/autowatchr.rb', line 19

def command
  @command ||= "<%= ruby %> -I<%= include %> <%= predicate %>"
end

#completed_reObject



51
52
53
# File 'lib/autowatchr.rb', line 51

def completed_re
  @completed_re ||= /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/
end

#failed_results_reObject



47
48
49
# File 'lib/autowatchr.rb', line 47

def failed_results_re
  @failed_results_re ||= /^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)\)/
end

#failing_onlyObject



55
56
57
# File 'lib/autowatchr.rb', line 55

def failing_only
  @failing_only
end

#includeObject



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

def include
  @include ||= ".:#{self.lib_dir}:#{self.test_dir}"
end

#lib_dirObject



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

def lib_dir
  @lib_dir ||= "lib"
end

#lib_reObject



39
40
41
# File 'lib/autowatchr.rb', line 39

def lib_re
  @lib_re ||= '^%s.*/.*\.rb$' % self.lib_dir
end

#rubyObject



23
24
25
# File 'lib/autowatchr.rb', line 23

def ruby
  @ruby ||= "ruby"
end

#run_suiteObject



59
60
61
# File 'lib/autowatchr.rb', line 59

def run_suite
  @run_suite
end

#test_dirObject



35
36
37
# File 'lib/autowatchr.rb', line 35

def test_dir
  @test_dir ||= "test"
end

#test_reObject



43
44
45
# File 'lib/autowatchr.rb', line 43

def test_re
  @test_re ||= '^%s.*/test_.*\.rb$' % self.test_dir
end

Instance Method Details

#eval_command(predicate) ⇒ Object



63
64
65
# File 'lib/autowatchr.rb', line 63

def eval_command(predicate)
  ERB.new(self.command).result(binding)
end