Class: Detroit::Syntax
- Inherits:
-
Tool
- Object
- Tool
- Detroit::Syntax
- Defined in:
- lib/detroit-syntax.rb
Overview
The Syntax tool simply checks all Ruby code for syntax errors. It is a rather trivial tool, and is here mainly for example sake.
NOTE: This method shells out to the command line using ‘ruby -c`.
Instance Attribute Summary collapse
-
#exclude ⇒ Object
Globs to exclude.
-
#extra ⇒ Object
Extra options to append to ‘ruby -c` command.
-
#files ⇒ Object
Files to check.
-
#ignore ⇒ Object
Files to ignore based on file name patterns.
-
#loadpath ⇒ Object
Add these folders to the $LOAD_PATH.
Class Method Summary collapse
Instance Method Summary collapse
-
#assemble(station, options = {}) ⇒ Object
Attach check method to test station.
-
#assemble?(station, options = {}) ⇒ Boolean
Attaches check method to test station.
-
#check ⇒ Object
Verify syntax of ruby scripts.
-
#log ⇒ Object
Log syntax errors?.
-
#log=(file_or_bool) ⇒ Object
File name of log file or
true
to use default ‘log/syntax.rdoc` file. -
#logfile ⇒ Object
If log is given save results to this log file.
Instance Attribute Details
#exclude ⇒ Object
Globs to exclude.
23 24 25 |
# File 'lib/detroit-syntax.rb', line 23 def exclude @exclude end |
#extra ⇒ Object
Extra options to append to ‘ruby -c` command.
29 30 31 |
# File 'lib/detroit-syntax.rb', line 29 def extra @extra end |
#files ⇒ Object
Files to check.
17 18 19 |
# File 'lib/detroit-syntax.rb', line 17 def files @files end |
#ignore ⇒ Object
Files to ignore based on file name patterns.
26 27 28 |
# File 'lib/detroit-syntax.rb', line 26 def ignore @ignore end |
#loadpath ⇒ Object
Add these folders to the $LOAD_PATH.
20 21 22 |
# File 'lib/detroit-syntax.rb', line 20 def loadpath @loadpath end |
Class Method Details
.man_page ⇒ Object
177 178 179 |
# File 'lib/detroit-syntax.rb', line 177 def self.man_page File.dirname(__FILE__)+'/../man/detroit-syntax.5' end |
Instance Method Details
#assemble(station, options = {}) ⇒ Object
Attach check method to test station.
53 54 55 56 57 58 |
# File 'lib/detroit-syntax.rb', line 53 def assemble(station, ={}) case station when :test check end end |
#assemble?(station, options = {}) ⇒ Boolean
Attaches check method to test station.
45 46 47 48 49 50 |
# File 'lib/detroit-syntax.rb', line 45 def assemble?(station, ={}) case station when :test true end end |
#check ⇒ Object
Verify syntax of ruby scripts.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/detroit-syntax.rb', line 74 def check list = run_syntax_check if log && (logfile.outofdate?(*files) or force?) log_syntax_errors(list) end abort "Syntax errors found." if list.size > 0 return true end |
#log ⇒ Object
Log syntax errors?
37 38 39 |
# File 'lib/detroit-syntax.rb', line 37 def log @log end |
#log=(file_or_bool) ⇒ Object
File name of log file or true
to use default ‘log/syntax.rdoc` file.
32 33 34 |
# File 'lib/detroit-syntax.rb', line 32 def log=(file_or_bool) @log = file_or_bool end |
#logfile ⇒ Object
If log is given save results to this log file.
64 65 66 67 68 69 70 71 |
# File 'lib/detroit-syntax.rb', line 64 def logfile case log when String Pathname.new(log) else project.log + 'syntax.rdoc' end end |