Class: Detroit::Yardstick
- Inherits:
-
Tool
- Object
- Tool
- Detroit::Yardstick
- Includes:
- Standard
- Defined in:
- lib/detroit-yardstick.rb
Overview
Switch to analyze station if detroit moves it after document.
Yardstick is a documentation coverage metric tool.
Constant Summary collapse
- MANPAGE =
Location of the manpage document for this tool.
File.dirname(__FILE__) + '/../man/detroit-yardstick.5'
Instance Attribute Summary collapse
-
#exact ⇒ Object
return [Boolean].
-
#output ⇒ String
The path to the file where the measurements will be written.
-
#path ⇒ String+
List of paths to measure.
- #rules ⇒ Hash
-
#threshold ⇒ Object
return [Integer].
-
#verbose ⇒ Object
return [Boolean].
Instance Method Summary collapse
-
#assemble?(station, options = {}) ⇒ Boolean, Symbol
This tool ties into the ‘post_document` station of the standard assembly.
-
#prerequisite ⇒ undefined
Prerequisite setup.
-
#print ⇒ undefined
Measure the documentation and write to stdout.
-
#save ⇒ undefined
Measure the documentation and write to output.
-
#write_report {|io| ... } ⇒ void
private
Open up a report for writing.
- #yard_config ⇒ Object private
- #yardstick_options ⇒ Object private
Instance Attribute Details
#exact ⇒ Object
return [Boolean]
60 61 62 |
# File 'lib/detroit-yardstick.rb', line 60 def exact @exact end |
#output ⇒ String
The path to the file where the measurements will be written.
51 52 53 |
# File 'lib/detroit-yardstick.rb', line 51 def output @output end |
#path ⇒ String+
List of paths to measure.
43 44 45 |
# File 'lib/detroit-yardstick.rb', line 43 def path @path end |
#rules ⇒ Hash
63 64 65 |
# File 'lib/detroit-yardstick.rb', line 63 def rules @rules end |
#threshold ⇒ Object
return [Integer]
54 55 56 |
# File 'lib/detroit-yardstick.rb', line 54 def threshold @threshold end |
#verbose ⇒ Object
return [Boolean]
57 58 59 |
# File 'lib/detroit-yardstick.rb', line 57 def verbose @verbose end |
Instance Method Details
#assemble?(station, options = {}) ⇒ Boolean, Symbol
This tool ties into the ‘post_document` station of the standard assembly.
88 89 90 91 |
# File 'lib/detroit-yardstick.rb', line 88 def assemble?(station, ={}) return :save if station == :post_document return false end |
#prerequisite ⇒ undefined
Prerequisite setup.
28 29 30 31 32 33 34 35 |
# File 'lib/detroit-yardstick.rb', line 28 def prerequisite require 'yardstick' @path = 'lib/**/*.rb' @output = project.log + 'yardstick.txt' @verbose = true @exact = true end |
#print ⇒ undefined
Measure the documentation and write to stdout.
81 82 83 |
# File 'lib/detroit-yardstick.rb', line 81 def print ::Yardstick.measure(yard_config).puts($stdout) end |
#save ⇒ undefined
Measure the documentation and write to output.
71 72 73 |
# File 'lib/detroit-yardstick.rb', line 71 def save write_report { |io| ::Yardstick.measure(yard_config).puts(io) } end |
#write_report {|io| ... } ⇒ void (private)
This method returns an undefined value.
Open up a report for writing
125 126 127 128 129 |
# File 'lib/detroit-yardstick.rb', line 125 def write_report(&block) file = Pathname(output) file.dirname.mkpath file.open('w', &block) end |
#yard_config ⇒ Object (private)
96 97 98 |
# File 'lib/detroit-yardstick.rb', line 96 def yard_config Yardstick::Config.coerce() end |
#yardstick_options ⇒ Object (private)
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/detroit-yardstick.rb', line 101 def opts = {} opts[:path] = path opts[:output] = output opts[:verbose] = verbose opts[:require_exact_threshold] = exact opts[:threshold] = threshold if threashold opts[:rules] = rules if rules return opts end |