Class: Gizzard::TopologyCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/gizzard/commands.rb

Instance Attribute Summary

Attributes inherited from Command

#argv, #buffer, #command_options, #global_options, #job_injector, #manager

Instance Method Summary collapse

Methods inherited from Command

classify, #confirm!, #get_base_name, #help!, #initialize, make_job_injector, make_manager, #output, #require_tables, #require_template_options, run

Constructor Details

This class inherits a constructor from Gizzard::Command

Instance Method Details

#runObject



789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'lib/gizzard/commands.rb', line 789

def run
  require_tables

  manifest  = manager.manifest(*global_options.tables)
  templates = manifest.templates

  if command_options.forwardings
    templates.
      inject([]) { |h, (t, fs)| fs.each { |f| h << [f.inspect, t.to_config] }; h }.
      sort.
      each { |a| puts "%s\t%s" % a }
  elsif command_options.root_shards
    templates.
      inject([]) { |a, (t, fs)| fs.each { |f| a << [f.shard_id.inspect, t.to_config] }; a }.
      sort.
      each { |a| puts "%s\t%s" % a }
  else
    templates.
      map { |(t, fs)| [fs.length, t.to_config] }.
      sort.reverse.
      each { |a| puts "%4d %s" % a }
  end
end