Sha256: 61f4331fd2f0dde9b9206df42a834f52db3c64cd1c0fd43f98e3490b997cbf11

Contents?: true

Size: 910 Bytes

Versions: 7

Compression:

Stored size: 910 Bytes

Contents

module Heirloom
  module CLI
    module Formatter
      class Catalog
        def format(args)
          @catalog = args[:catalog]
          @name    = args[:name]

          return summary unless @name

          return "Heirloom #{@name} not found in catalog." unless name_exists?

          filter_by_name
          details
        end

        private

        def name_exists?
          @catalog.include? @name
        end

        def filter_by_name
          @catalog.select! {|k| @name == k }
        end

        def summary
          @catalog.keys.join "\n"
        end

        def details
          data = @catalog.each_pair.map do |k,v|
            d = k + "\n"
            d << "  Regions       : " + @catalog[k]["regions"].join(", ") + "\n"
            d << "  Bucket Prefix : " + @catalog[k]["bucket_prefix"].first
          end
          data.join "\n"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
heirloom-0.10.1 lib/heirloom/cli/formatter/catalog.rb
heirloom-0.10.0 lib/heirloom/cli/formatter/catalog.rb
heirloom-0.9.0 lib/heirloom/cli/formatter/catalog.rb
heirloom-0.8.3 lib/heirloom/cli/formatter/catalog.rb
heirloom-0.8.2 lib/heirloom/cli/formatter/catalog.rb
heirloom-0.8.1 lib/heirloom/cli/formatter/catalog.rb
heirloom-0.8.0 lib/heirloom/cli/formatter/catalog.rb