Sha256: 518385781f1b2bdc3108dc1f39d89e480d23970382983e43e2f843920dc544cf

Contents?: true

Size: 543 Bytes

Versions: 1

Compression:

Stored size: 543 Bytes

Contents

module M
  class TestCollection
    include Enumerable
    extend Forwardable
    def_delegators :@collection, :size, :<<, :each

    def initialize(collection = nil)
      @collection = collection || []
    end

    def within(line)
      self.class.new(select do |test|
        line.zero? || (test.start_line..test.end_line).include?(line)
      end)
    end

    def column_size
      @column_size ||= map { |test| test.name.to_s.size }.max
    end

    def by_line_number(&block)
      sort_by(&:start_line).each(&block)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
m-0.0.1 lib/m/test_collection.rb