Sha256: af27d8aa812aeec25d78f35cfe89373451218661136e499b1e03ca3fb58e6740

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

module Yardstick
  class Processor

    # Measure files provided
    #
    # @param [Array<#to_s>, #to_s] path
    #   the files to measure
    #
    # @return [MeasurementSet]
    #   a collection of measurements
    #
    # @api private
    def self.process_path(path)
      YARD.parse(Array(path).map { |file| file.to_s })
      measurements
    end

    # Measure string provided
    #
    # @param [#to_str] string
    #   the string to measure
    #
    # @return [MeasurementSet]
    #   a collection of measurements
    #
    # @api private
    def self.process_string(string)
      YARD.parse_string(string.to_str)
      measurements
    end

    # Measure method objects in YARD registry
    #
    # @return [MeasurementSet]
    #   a collection of measurements
    #
    # @api private
    def self.measurements
      measurements = MeasurementSet.new
      method_objects.each do |method_object|
        measurements.merge(method_object.docstring.measure)
      end
      measurements
    end

    # Return method objects in YARD registry
    #
    # @return [Array<YARD::CodeObjects::MethodObject>]
    #   a collection of method objects
    #
    # @api private
    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

    class << self
      private :measurements, :method_objects
    end

  end # class Processor
end # module Yardstick

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
dkubb-yardstick-0.1.0 lib/yardstick/processor.rb
yardstick-0.1.0 lib/yardstick/processor.rb