Class: Datagraph::Command

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/datagraph/command.rb,
lib/datagraph/command/url.rb,
lib/datagraph/command/open.rb,
lib/datagraph/command/list.rb,
lib/datagraph/command/drop.rb,
lib/datagraph/command/abort.rb,
lib/datagraph/command/clear.rb,
lib/datagraph/command/count.rb,
lib/datagraph/command/query.rb,
lib/datagraph/command/create.rb,
lib/datagraph/command/status.rb,
lib/datagraph/command/rename.rb,
lib/datagraph/command/import.rb,
lib/datagraph/command/export.rb,
lib/datagraph/command/register.rb

Overview

Base class for CLI commands.

Direct Known Subclasses

Command::Abort, Command::Clear, Command::Count, Command::Create, Command::Drop, Command::Export, Command::Import, Command::List, Command::Open, Command::Query, Command::Register, Command::Rename, Command::Status, Command::URL

Defined Under Namespace

Classes: Abort, Clear, Count, Create, Drop, Export, Import, List, Open, Query, Register, Rename, Status, URL

Instance Method Summary (collapse)

Methods included from Client

rpc

Instance Method Details

- (Object) basename



22
23
24
# File 'lib/datagraph/command.rb', line 22

def basename
  RDF::CLI.basename
end

- (Object) parse_repository_specs(resource_specs)



50
51
52
53
54
55
56
57
58
# File 'lib/datagraph/command.rb', line 50

def parse_repository_specs(resource_specs)
  resources = parse_resource_specs(resource_specs)
  resources.each do |resource|
    unless resource.is_a?(Repository)
      RDF::CLI.abort "invalid repository spec `#{resource}'"
    end
  end
  resources
end

- (Object) parse_resource_specs(resource_specs)



60
61
62
63
64
65
66
67
68
69
# File 'lib/datagraph/command.rb', line 60

def parse_resource_specs(resource_specs)
  resources = []
  resource_specs.each do |resource_spec|
    unless resource = Resource.new(resource_spec)
      RDF::CLI.abort "invalid resource spec `#{resource_spec}'"
    end
    resources << resource
  end
  resources
end

- (Object) validate_repository_specs(resource_specs)



26
27
28
29
30
31
32
33
34
# File 'lib/datagraph/command.rb', line 26

def validate_repository_specs(resource_specs)
  resources = validate_resource_specs(resource_specs)
  resources.each do |resource|
    unless resource.is_a?(Repository)
      RDF::CLI.abort "invalid repository spec `#{resource}'"
    end
  end
  resources
end

- (Object) validate_resource_specs(resource_specs)



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/datagraph/command.rb', line 36

def validate_resource_specs(resource_specs)
  resources = parse_resource_specs(resource_specs)
  resources.each do |resource|
    case resource
      when Account
        RDF::CLI.abort "unknown account `#{resource}'" unless resource.exists?
      when Repository
        RDF::CLI.abort "unknown account `#{resource.}'" unless resource..exists?
        RDF::CLI.abort "unknown repository `#{resource}'" unless resource.exists?
    end
  end
  resources
end