Class: Yardstick::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/yardstick/processor.rb

Overview

Handle procesing a docstring or path of files

Class Method Summary collapse

Class Method Details

.measurementsYardstick::MeasurementSet

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.

Measure method objects in YARD registry

Returns:



42
43
44
45
46
47
48
# File 'lib/yardstick/processor.rb', line 42

def self.measurements
  measurements = MeasurementSet.new
  method_objects.each do |method_object|
    measurements.merge(method_object.docstring.measure)
  end
  measurements
end

.method_objectsArray<YARD::CodeObjects::MethodObject>

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.

Return method objects in YARD registry

Returns:

  • (Array<YARD::CodeObjects::MethodObject>)

    a collection of method objects



56
57
58
59
60
61
62
# File 'lib/yardstick/processor.rb', line 56

def self.method_objects
  YARD::Registry.all(:method).sort_by do |method_object|
    [ method_object.file, method_object.line ]
  end
ensure
  YARD::Registry.clear
end

.process_path(path) ⇒ Yardstick::MeasurementSet

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.

Measure files provided

Parameters:

  • path (Array<#to_s>, #to_s)

    the files to measure

Returns:



17
18
19
20
# File 'lib/yardstick/processor.rb', line 17

def self.process_path(path)
  YARD.parse(Array(path).map(&:to_s), [], YARD::Logger::ERROR)
  measurements
end

.process_string(string) ⇒ Yardstick::MeasurementSet

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.

Measure string provided

Parameters:

  • string (#to_str)

    the string to measure

Returns:



31
32
33
34
# File 'lib/yardstick/processor.rb', line 31

def self.process_string(string)
  YARD.parse_string(string.to_str)
  measurements
end