Class: Gizzard::TransformCommand

Inherits:
BaseTransformCommand 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 BaseTransformCommand

#run

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

#get_transformationsObject



883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
# File 'lib/gizzard/commands.rb', line 883

def get_transformations
  help!("must have an even number of arguments") unless @argv.length % 2 == 0
  require_tables
  require_template_options

  scheduler_options = command_options.scheduler_options || {}
  manifest          = manager.manifest(*global_options.tables)
  copy_wrapper      = scheduler_options[:copy_wrapper]
  skip_copies       = scheduler_options[:skip_copies] || false
  transformations   = {}

  @argv.each_slice(2) do |(from_template_s, to_template_s)|
    from, to       = [from_template_s, to_template_s].map {|s| ShardTemplate.parse(s) }
    transformation = Transformation.new(from, to, copy_wrapper, skip_copies)
    forwardings    = Set.new(manifest.templates[from] || [])
    trees          = manifest.trees.reject {|(f, s)| !forwardings.include?(f) }

    transformations[transformation] = trees
  end

  transformations
end