Sha256: 4f34553fd89795939315970dcbcec03577d55c84c81410e7226585531a1ff003

Contents?: true

Size: 726 Bytes

Versions: 60

Compression:

Stored size: 726 Bytes

Contents

require 'table_print'

module PactBroker
  module Client
    class Versions
      class TextFormatter

        Line = Struct.new(:number, :tags)

        OPTIONS = [
          { number: {:width => 40} },
          { tags: {} }
        ]

        def self.call(version_hash)
          tags = (lookup(version_hash, [], :_embedded, :tags) || []).collect{ | t| t[:name] }.join(" ")
          data = Line.new(version_hash[:number], tags)

          printer = TablePrint::Printer.new([data], OPTIONS)
          printer.table_print
        end

        def self.lookup line, default, *keys
          keys.reduce(line) { | line, key | line[key] }
        rescue NoMethodError
          default
        end
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
pact_broker-client-1.43.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.42.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.41.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.40.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.39.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.38.3 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.38.2 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.38.1 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.38.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.37.1 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.37.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.36.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.35.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.34.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.33.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.32.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.31.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.30.0 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.29.1 lib/pact_broker/client/versions/text_formatter.rb
pact_broker-client-1.29.0 lib/pact_broker/client/versions/text_formatter.rb