Class: Heirloom::CLI::Catalog

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/heirloom/cli/catalog.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shared

#ensure_archive_domain_empty, #ensure_archive_exists, #ensure_buckets_available, #ensure_buckets_exist, #ensure_catalog_domain_exists, #ensure_directory_is_writable, #ensure_domain_exists, #ensure_entry_does_not_exist_in_catalog, #ensure_entry_exists_in_catalog, #ensure_metadata_in_upload_region, #ensure_path_is_directory, #ensure_valid_bucket_prefix, #ensure_valid_metadata_region, #ensure_valid_name, #ensure_valid_options, #ensure_valid_region, #ensure_valid_regions, #ensure_valid_secret, #latest_id, #load_config, #read_secret

Constructor Details

#initializeCatalog

Returns a new instance of Catalog.



11
12
13
14
15
16
17
18
19
20
# File 'lib/heirloom/cli/catalog.rb', line 11

def initialize
  @opts = read_options
  @logger = HeirloomLogger.new :log_level => @opts[:level]
  @config = load_config :logger => @logger,
                        :opts   => @opts

  ensure_valid_options :provided => @opts,
                       :required => [],
                       :config   => @config
end

Class Method Details

.command_summaryObject



7
8
9
# File 'lib/heirloom/cli/catalog.rb', line 7

def self.command_summary
  'Show catalog of Heirlooms'
end

Instance Method Details

#allObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/heirloom/cli/catalog.rb', line 22

def all
  regions = detected_regions
  @logger.info "Querying regions #{regions.join(', ')} for Heirloom catalogs."
  regions.each do |region|
    @config. = region

     @config

    unless catalog_domain_exists?
      @logger.info "No heirloom catalog in '#{region}'."
      next
    end

    @catalog_list = Hash[@catalog.all]

    unless @opts[:name]
      heirloom_summary region
      @heirloom_found = true
      next
    end

    if heirloom_exists_in_catalog? @opts[:name]
      @logger.info "Heirloom \'#{@opts[:name]}\' found in catalog for #{region}."
      heirloom_details region, @opts[:name]
      @heirloom_found = true
    else
      @logger.info "Heirloom \'#{@opts[:name]}\' not found in catalog for #{region}."
    end
  end

  unless @heirloom_found
    if @opts[:name]
      @logger.info "Heirloom \'#{@opts[:name]}\' not found in any regions."
    else
      @logger.info "Heirloom catalog not found in any regions."
    end
  end
end