Module: Superstore::Tasks

Included in:
CassandraSchema
Defined in:
lib/superstore/cassandra_schema/tasks.rb

Instance Method Summary collapse

Instance Method Details

#dump(io) ⇒ Object



3
4
5
6
7
8
# File 'lib/superstore/cassandra_schema/tasks.rb', line 3

def dump(io)
  table_names.each do |column_family|
    io.puts run_command("DESCRIBE COLUMNFAMILY #{column_family}")
    io.puts
  end
end

#load(io) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/superstore/cassandra_schema/tasks.rb', line 10

def load(io)
  current_cql = ''

  io.each_line do |line|
    next if line.blank?

    current_cql << line.rstrip

    if current_cql =~ /;$/
      keyspace_execute current_cql
      current_cql = ''
    end
  end
end

#table_namesObject



25
26
27
# File 'lib/superstore/cassandra_schema/tasks.rb', line 25

def table_names
  run_command('DESCRIBE COLUMNFAMILIES').split.sort
end