Class: Duracloud::Commands::FindItems

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

Constant Summary collapse

HEADERS =
%i( content_id md5 size content_type modified )

Instance Method Summary collapse

Methods inherited from Command

call, #cli

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/duracloud/commands/find_items.rb', line 8

def call
  CSV.instance($stdout, headers: HEADERS, write_headers: true) do |csv|
    CSV.foreach(infile, headers: false) do |row|
      begin
        item = Duracloud::Content.find(space_id: space_id, store_id: store_id, content_id: row[0], md5: row[1])
        csv << HEADERS.map { |header| item.send(header) }
      rescue Duracloud::NotFoundError, Duracloud::MessageDigestError => e
        $stderr.puts "ERROR: Content ID #{row[0]} -- #{e.message}"
      end
    end
  end
end