Sha256: 25c4a89695334b714d650d4b5b8b4828c698d39af60aff3df8f1396cc6689f48
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 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 =~ /;$/ CassandraObject::Base.execute_cql 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gotime-cassandra_object-4.11.6 | lib/cassandra_object/schema/tasks.rb |
gotime-cassandra_object-4.11.5 | lib/cassandra_object/schema/tasks.rb |