Sha256: cbff808fb58a0cebad80d32aad9ad12c18c839c28c9aacdfd9057f17603bd5ff

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 Bytes

Contents

# encoding: utf-8

module Yardstick

  # Handles writing reports
  class ReportOutput

    # Coerces string path into proper output object
    #
    # @param [String, Pathname] target
    #   path of the output
    #
    # @return [Yardstick::ReportOutput]
    #
    # @api private
    def self.coerce(target)
      new(Pathname(target))
    end

    # Initializes ReportOutput instance
    #
    # @param [Pathname] target
    #
    # @return [undefined]
    #
    # @api private
    def initialize(target)
      @target = target
    end

    # 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 [undefined]
    #
    # @api private
    def write(&block)
      @target.dirname.mkpath
      @target.open('w', &block)
    end

    # @see [Pathname#to_s]
    #
    # @return [String]
    #
    # @api private
    def to_s
      @target.to_s
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yardstick-0.9.7 lib/yardstick/report_output.rb