class Aspen::Actions::Push
Public Class Methods
new(path: nil, config_path: 'config/db.yml')
click to toggle source
# File lib/aspen/actions/push.rb, line 8 def initialize(path: nil, config_path: 'config/db.yml') @path_to_cql = path || Dir["build/main-*.cql"].first config = YAML::load_file(config_path) url = config.fetch("url").strip adapter = Neo4j::Core::CypherSession::Adaptors::HTTP.new(url, {}) @session = Neo4j::Core::CypherSession.new(adapter) rescue => e puts e.message puts e.backtrace end
Public Instance Methods
call()
click to toggle source
# File lib/aspen/actions/push.rb, line 19 def call drop push end
drop()
click to toggle source
# File lib/aspen/actions/push.rb, line 24 def drop print "Dropping data from database..." @session.query("MATCH (n) DETACH DELETE n") print "OK\n" end
push()
click to toggle source
# File lib/aspen/actions/push.rb, line 30 def push file = File.read(@path_to_cql) print "Pushing data to database from #{@path_to_cql}..." @session.query(file) print "OK\n" end