Class: Autowatchr::Config
- Inherits:
-
Object
- Object
- Autowatchr::Config
- Defined in:
- lib/autowatchr.rb
Instance Attribute Summary collapse
- #command ⇒ Object
- #completed_re ⇒ Object
- #failed_results_re ⇒ Object
- #failing_only ⇒ Object
- #include ⇒ Object
- #lib_dir ⇒ Object
- #lib_re ⇒ Object
- #require ⇒ Object
- #ruby ⇒ Object
- #run_suite ⇒ Object
- #test_dir ⇒ Object
- #test_file ⇒ Object
- #test_re ⇒ Object
Instance Method Summary collapse
- #eval_command(predicate) ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #list_of_requires ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/autowatchr.rb', line 10 def initialize( = {}) @failing_only = @run_suite = true .each_pair do |key, value| method = "#{key}=" if self.respond_to?(method) self.send(method, value) end end end |
Instance Attribute Details
#command ⇒ Object
21 22 23 |
# File 'lib/autowatchr.rb', line 21 def command @command ||= "<%= ruby %> -I<%= include %> <% list_of_requires.each { |lib| %>-r<%= lib %> <% } %><%= predicate %>" end |
#completed_re ⇒ Object
71 72 73 |
# File 'lib/autowatchr.rb', line 71 def completed_re @completed_re ||= /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/ end |
#failed_results_re ⇒ Object
67 68 69 |
# File 'lib/autowatchr.rb', line 67 def failed_results_re @failed_results_re ||= /^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)\)/ end |
#failing_only ⇒ Object
75 76 77 |
# File 'lib/autowatchr.rb', line 75 def failing_only @failing_only end |
#include ⇒ Object
29 30 31 |
# File 'lib/autowatchr.rb', line 29 def include @include ||= ".:#{self.lib_dir}:#{self.test_dir}" end |
#lib_dir ⇒ Object
47 48 49 |
# File 'lib/autowatchr.rb', line 47 def lib_dir @lib_dir ||= "lib" end |
#lib_re ⇒ Object
55 56 57 |
# File 'lib/autowatchr.rb', line 55 def lib_re @lib_re ||= '^%s.*/.*\.rb$' % self.lib_dir end |
#require ⇒ Object
33 34 35 |
# File 'lib/autowatchr.rb', line 33 def require @require end |
#ruby ⇒ Object
25 26 27 |
# File 'lib/autowatchr.rb', line 25 def ruby @ruby ||= "ruby" end |
#run_suite ⇒ Object
79 80 81 |
# File 'lib/autowatchr.rb', line 79 def run_suite @run_suite end |
#test_dir ⇒ Object
51 52 53 |
# File 'lib/autowatchr.rb', line 51 def test_dir @test_dir ||= "test" end |
#test_file ⇒ Object
63 64 65 |
# File 'lib/autowatchr.rb', line 63 def test_file @test_file ||= 'test_%s.rb' end |
#test_re ⇒ Object
59 60 61 |
# File 'lib/autowatchr.rb', line 59 def test_re @test_re ||= '^%s.*/test_.*\.rb$' % self.test_dir end |
Instance Method Details
#eval_command(predicate) ⇒ Object
83 84 85 |
# File 'lib/autowatchr.rb', line 83 def eval_command(predicate) ERB.new(self.command).result(binding) end |
#list_of_requires ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/autowatchr.rb', line 37 def list_of_requires if @require.nil? || @require.empty? [] elsif @require.is_a?(Array) @require else [@require] end end |