Sha256: b545b2e74ea67a2863b4f70dd8a2c76a1809ac8d6635ef95847022416f2b332d

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# encoding: utf-8

require 'rake'
require 'rake/tasklib'

require 'pathname'
require 'yardstick'

module Yardstick
  module Rake

    # A rake task for measuring docs in a set of files
    class Measurement < ::Rake::TaskLib

      # Initializes a Measurement task
      #
      # @example
      #   task = Yardstick::Rake::Measurement
      #
      # @param [Symbol] name
      #   optional task name
      #
      # @yieldparam [Yardstick::Config] config
      #   the config object
      #
      # @return [Yardstick::Rake::Measurement]
      #   the measurement task
      #
      # @api public
      def initialize(name = :yardstick_measure, options = {}, &block)
        @name   = name
        @config = Config.coerce(options, &block)

        define
      end

      # Measure the documentation
      #
      # @example
      #   task.yardstick_measure  # (output measurement report)
      #
      # @return [undefined]
      #
      # @api public
      def yardstick_measure
        @config.output.write { |io| Yardstick.measure(@config).puts(io) }
      end

    private

      # Define the task
      #
      # @return [undefined]
      #
      # @api private
      def define
        desc "Measure docs in #{@config.path} with yardstick"
        task(@name) { yardstick_measure }
      end

    end # class Measurement
  end # module Rake
end # module Yardstick

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yardstick-0.9.7 lib/yardstick/rake/measurement.rb