Class: Teapot::Command::Fetch

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/teapot/command/fetch.rb

Instance Method Summary collapse

Instance Method Details

#contextObject



50
51
52
# File 'lib/teapot/command/fetch.rb', line 50

def context
  parent.context
end

#invokeObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/teapot/command/fetch.rb', line 54

def invoke
  selection = context.select
  
  packages = selection.configuration.packages
  
  if specified_packages = self.packages
    packages = packages.slice(specified_packages)
  end
  
  logger = parent.logger
  
  # If no additional packages were resolved, we have reached a fixed point:
  while packages.any?
    packages.each do |package|
      fetch_package(context, selection.configuration, package, logger, **@options)
    end
    
    selection = context.select
    
    # If there are no unresolved packages, we are done.
    if selection.unresolved.empty?
      break
    end
    
    packages = selection.unresolved
  end

  if selection.unresolved.count > 0
    logger.error(self) do |buffer|
      buffer.puts "Could not fetch all packages!"
      
      selection.unresolved.each do |package|
        buffer.puts "\t#{package}"
      end
    end
  else
    logger.info "Completed fetch successfully."
  end
end