Sha256: cfbaa729014cfb09b03cef9dfe3fe300fd36db835030ced156bf43e0dbe0b0e5

Contents?: true

Size: 734 Bytes

Versions: 10

Compression:

Stored size: 734 Bytes

Contents

module Tap
  module Support
    class Summary
      def initialize
        @map = []
        @width = 10
      end
      
      def add(env_key, env, map)
        unless map.empty?
          @map << [env_key, env, map]
          map.each {|(key, path)| @width = key.length if @width < key.length }
        end
      end
      
      def lines
        lines = []
        @map.each do |(env_lookup, env, map)|
          lines <<  "#{env_lookup}:" if @map.length > 1
          map.each do |(key, path)|
            desc = block_given? ? (yield(path) || '') : ''
            desc = "  # #{desc}" unless desc.empty?
            lines << ("  %-#{@width}s%s" % [key, desc])
          end
        end
        lines
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
bahuvrihi-tap-0.10.0 lib/tap/support/summary.rb
bahuvrihi-tap-0.10.1 lib/tap/support/summary.rb
bahuvrihi-tap-0.10.2 lib/tap/support/summary.rb
bahuvrihi-tap-0.10.3 lib/tap/support/summary.rb
bahuvrihi-tap-0.10.4 lib/tap/support/summary.rb
bahuvrihi-tap-0.10.5 lib/tap/support/summary.rb
bahuvrihi-tap-0.10.6 lib/tap/support/summary.rb
bahuvrihi-tap-0.10.7 lib/tap/support/summary.rb
tap-0.10.0 lib/tap/support/summary.rb
tap-0.10.1 lib/tap/support/summary.rb