Class: Aq::AqCmd

Inherits:
Thor
  • Object
show all
Defined in:
lib/aq/command.rb

Instance Method Summary collapse

Instance Method Details

#head(table) ⇒ Object



26
27
28
29
# File 'lib/aq/command.rb', line 26

def head(table)
  query = QueryBuilder.head table, options[:max_rows]
  Aq::Query.new(options[:bucket], options[:object_prefix]).run(query)
end

#load(table, source, schema) ⇒ Object



40
41
42
43
44
# File 'lib/aq/command.rb', line 40

def load(table, source, schema)
  schema = SchemaLoader.new.load schema
  query = QueryBuilder.load table, source, schema, options[:source_format], options[:partitioning]
  Aq::Query.new(options[:bucket], options[:object_prefix]).run(query)
end

#ls(database = nil) ⇒ Object



19
20
21
22
# File 'lib/aq/command.rb', line 19

def ls(database=nil)
  query = QueryBuilder.ls database
  Aq::Query.new(options[:bucket], options[:object_prefix]).run(query)
end

#mk(name) ⇒ Object



32
33
34
35
# File 'lib/aq/command.rb', line 32

def mk(name)
  query = QueryBuilder.mk name
  Aq::Query.new(options[:bucket], options[:object_prefix]).run(query)
end

#query(query) ⇒ Object



65
66
67
# File 'lib/aq/command.rb', line 65

def query(query)
  Aq::Query.new(options[:bucket], options[:object_prefix]).run(query, options[:timeout])
end

#rm(name) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/aq/command.rb', line 48

def rm(name)
  if options[:force]
    answer = true
  else
    answer = agree("Would you remove #{name}? (y)es or (n)o")
  end
  unless answer
    puts 'Canceled'
    exit 1
  end

  query = QueryBuilder.rm name
  Aq::Query.new(options[:bucket], options[:object_prefix]).run(query)
end

#versionObject



70
71
72
# File 'lib/aq/command.rb', line 70

def version
  puts "aq v#{Aq::VERSION}"
end