Class: Datagraph::Command::Query

Inherits:
Datagraph::Command show all
Defined in:
lib/datagraph/command/query.rb

Overview

Queries a repository.

Instance Method Summary (collapse)

Methods inherited from Datagraph::Command

#basename, #parse_repository_specs, #parse_resource_specs, #validate_repository_specs, #validate_resource_specs

Methods included from Datagraph::Client

rpc

Instance Method Details

- execute(repository_spec, query = nil)

This method returns an undefined value.

Parameters:

  • (String) repository_spec
  • (String, #to_s) query (defaults to: nil)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/datagraph/command/query.rb', line 10

def execute(repository_spec, query = nil)
  repository = validate_repository_specs([repository_spec]).first
  query = case query
    when nil       then $stdin.read             # < filename.rq
    when /^@(.*)$/ then open($1) { |f| f.read } # @filename.rq, @url.rq
    else query.to_s                             # 'SELECT ...'
  end
  process = repository.query(query)
  puts "Query #{process} successfully submitted; waiting for results..." if $VERBOSE # FIXME
  process.wait!
end