class Detroit::Yardstick

Yardstick is a documentation coverage metric tool.

@assembly Standard

@todo Switch to analyze station if detroit moves it after document.

Constants

MANPAGE

Location of the manpage document for this tool.

Attributes

exact[RW]

return [Boolean]

output[RW]

The path to the file where the measurements will be written.

@param [String, Pathname] output

optional output path for measurements

@return [String]

path[RW]

List of paths to measure.

@param [Array<#to_s>, to_s] path

optional list of paths to measure

@return [String,Array<String>]

rules[RW]

@return [Hash]

threshold[RW]

return [Integer]

verbose[RW]

return [Boolean]

Public Instance Methods

assemble?(station, options={}) click to toggle source

This tool ties into the ‘post_document` station of the standard assembly.

@return [Boolean,Symbol]

# File lib/detroit-yardstick.rb, line 88
def assemble?(station, options={})
  return :save if station == :post_document
  return false
end
prerequisite() click to toggle source

Prerequisite setup.

@return [undefined]

# 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() click to toggle source

Measure the documentation and write to stdout.

@example

tool.print  # (print measurement report to stdout)

@return [undefined]

save() click to toggle source

Measure the documentation and write to output.

@example

tool.save  # (save measurement report to output)

@return [undefined]

# File lib/detroit-yardstick.rb, line 71
def save
  write_report { |io| ::Yardstick.measure(yard_config).puts(io) }
end

Private Instance Methods

write_report(&block) click to toggle source

Open up a report for writing

@yield [io]

yield to an object that responds to #puts

@yieldparam [#puts] io

the object that responds to #puts

@return [void]

# File lib/detroit-yardstick.rb, line 125
def write_report(&block)
  file = Pathname(output)
  file.dirname.mkpath
  file.open('w', &block)
end
yard_config() click to toggle source
# File lib/detroit-yardstick.rb, line 96
def yard_config
  Yardstick::Config.coerce(yard_options)
end
yardstick_options() click to toggle source
# File lib/detroit-yardstick.rb, line 101
def yardstick_options
  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