Module: Yardstick

Defined in:
lib/yardstick.rb,
lib/yardstick/cli.rb,
lib/yardstick/rule.rb,
lib/yardstick/config.rb,
lib/yardstick/parser.rb,
lib/yardstick/version.rb,
lib/yardstick/document.rb,
lib/yardstick/processor.rb,
lib/yardstick/measurement.rb,
lib/yardstick/ordered_set.rb,
lib/yardstick/rake/verify.rb,
lib/yardstick/rule_config.rb,
lib/yardstick/document_set.rb,
lib/yardstick/report_output.rb,
lib/yardstick/rules/api_tag.rb,
lib/yardstick/rules/summary.rb,
lib/yardstick/measurement_set.rb,
lib/yardstick/rake/measurement.rb,
lib/yardstick/rules/return_tag.rb,
lib/yardstick/rules/example_tag.rb

Defined Under Namespace

Modules: Rake, Rules Classes: CLI, Config, Document, DocumentSet, Measurement, MeasurementSet, OrderedSet, Parser, Processor, ReportOutput, Rule, RuleConfig

Constant Summary collapse

ROOT =
Pathname(__FILE__).dirname.parent.expand_path.freeze
VERSION =

Gem version

'0.9.9'.freeze

Class Method Summary collapse

Class Method Details

.measure(config = Config.new) ⇒ Yardstick::MeasurementSet

Measure a list of files

Examples:

config = Yardstick::Config.coerce(path: 'article.rb')
Yardstick.measure(config)  # => [ MeasurementSet ]

Parameters:

  • config (Config) (defaults to: Config.new)

    optional configuration

Returns:



48
49
50
# File 'lib/yardstick.rb', line 48

def self.measure(config = Config.new)
  Processor.new(config).process
end

.measure_string(string, config = Config.new) ⇒ Yardstick::MeasurementSet

Measure a string of code and YARD documentation

Examples:

string = "def my_method; end"

Yardstick.measure_string(string)  # => [ Measurement ]

Parameters:

  • string (#to_str)

    the string to measure

  • config (Config) (defaults to: Config.new)

    optional configuration

Returns:



68
69
70
# File 'lib/yardstick.rb', line 68

def self.measure_string(string, config = Config.new)
  Processor.new(config).process_string(string)
end

.round_percentage(percentage) ⇒ Float

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Round percentage to 1/10th of a percent

Parameters:

  • percentage (Float)

    the percentage to round

Returns:

  • (Float)

    the rounded percentage



81
82
83
# File 'lib/yardstick.rb', line 81

def self.round_percentage(percentage)
  (percentage * 10).floor / 10.0
end