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_method ⇒ Object
- #run_suite ⇒ Object
- #test_dir ⇒ 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
25 26 27 |
# File 'lib/autowatchr.rb', line 25 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
33 34 35 |
# File 'lib/autowatchr.rb', line 33 def include @include ||= ".:#{self.lib_dir}:#{self.test_dir}" end |
#lib_dir ⇒ Object
51 52 53 |
# File 'lib/autowatchr.rb', line 51 def lib_dir @lib_dir ||= "lib" end |
#lib_re ⇒ Object
59 60 61 |
# File 'lib/autowatchr.rb', line 59 def lib_re @lib_re ||= '^%s.*/.*\.rb$' % self.lib_dir end |
#require ⇒ Object
37 38 39 |
# File 'lib/autowatchr.rb', line 37 def require @require end |
#ruby ⇒ Object
29 30 31 |
# File 'lib/autowatchr.rb', line 29 def ruby @ruby ||= "ruby" end |
#run_method ⇒ Object
21 22 23 |
# File 'lib/autowatchr.rb', line 21 def run_method @run_method ||= :require end |
#run_suite ⇒ Object
79 80 81 |
# File 'lib/autowatchr.rb', line 79 def run_suite @run_suite end |
#test_dir ⇒ Object
55 56 57 |
# File 'lib/autowatchr.rb', line 55 def test_dir @test_dir ||= "test" end |
#test_re ⇒ Object
63 64 65 |
# File 'lib/autowatchr.rb', line 63 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
41 42 43 44 45 46 47 48 49 |
# File 'lib/autowatchr.rb', line 41 def list_of_requires if @require.nil? || @require.empty? [] elsif @require.is_a?(Array) @require else [@require] end end |