Sha256: a90c3c57ab7954af342397b5282d2ee64213c1319bbd9a7c70124a2342345c58
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module CassandraObject class Schema module Tasks def dump(io) column_families.each do |column_family| io.puts run_command("DESCRIBE COLUMNFAMILY #{column_family}") io.puts end end 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 def column_families run_command('DESCRIBE COLUMNFAMILIES').split.sort end private def run_command(command) `echo "#{command};" | #{cqlsh} -2 -k #{keyspace} #{server}`.sub(/^(.*)$/, '').strip end def cqlsh ENV['CQLSH'] || 'cqlsh' end def keyspace CassandraObject::Base.config.keyspace end def server CassandraObject::Base.config.servers.first.gsub(/:.*/, '') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gotime-cassandra_object-4.12.0 | lib/cassandra_object/schema/tasks.rb |