Class: Dydra::Command::Import

Inherits:
Dydra::Command show all
Defined in:
lib/dydra/command/import.rb

Overview

Imports data into a repository.

Constant Summary

BUCKET =

an Amazon S3 bucket for temporary file uploads

'tmp.datagraph.org'

Instance Method Summary (collapse)

Methods inherited from Dydra::Command

#abort, #basename, #catch_errors, #debug?, #initialize, #parse_repository_specs, #parse_resource_specs, #require_gem!, #stderr, #stdout, #validate_repository_specs, #validate_resource_specs, #verbose?, #wrap_errors

Methods included from Dydra::Client

authenticate!, credentials_file, delete, get, get_json, post, reset!, resource, rpc, setup?

Constructor Details

This class inherits a constructor from Dydra::Command

Instance Method Details

- execute(repository_spec, *urls)

This method returns an undefined value.

Parameters:

  • repository_spec (String)
  • urls (Array<String>)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dydra/command/import.rb', line 16

def execute(repository_spec, *urls)
  if urls.empty?
    puts "No import URL or file specified"
    Kernel.abort
  end
  repository = Repository.new(repository_spec)
  something_suceeded = false
  urls.each do |input_url|
    begin
      stdout.puts "Importing #{input_url} into #{repository.path}..." if verbose?
      info = repository.import!(input_url, @options).wait!.info
      something_suceeded = true if info[:status] == 'completed'
      puts "#{info['status']}: #{info['message']}"
    rescue RepositoryMisspecified => e
      puts e
    rescue XMLRPC::FaultException => e
      puts e.message.sub(/Uncaught exception /,'')
    end
  end
  puts "#{repository.}/#{repository.name} has #{repository.info['triple_count']} triples" if something_suceeded
end