Method: BoltSpec::Plans::DownloadStub#call

Defined in:
lib/bolt_spec/plans/action_stubs/download_stub.rb

#call(targets, source, destination, options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bolt_spec/plans/action_stubs/download_stub.rb', line 22

def call(targets, source, destination, options)
  @calls += 1
  if @return_block
    results = @return_block.call(targets: targets, source: source, destination: destination, params: options)
    check_resultset(results, source)
  else
    results = targets.map do |target|
      if @data[:default].is_a?(Bolt::Error)
        default_for(target)
      else
        download = File.join(destination, Bolt::Util.windows_basename(source))
        Bolt::Result.for_download(target, source, destination, download)
      end
    end
    Bolt::ResultSet.new(results)
  end
end