Class: Aspen::Actions::Push
- Inherits:
-
Object
- Object
- Aspen::Actions::Push
- Defined in:
- lib/aspen/actions/push.rb
Instance Method Summary collapse
- #call ⇒ Object
- #drop ⇒ Object
-
#initialize(path: nil, config_path: 'config/db.yml') ⇒ Push
constructor
A new instance of Push.
- #push ⇒ Object
Constructor Details
#initialize(path: nil, config_path: 'config/db.yml') ⇒ Push
Returns a new instance of Push.
8 9 10 11 12 13 14 15 16 17 |
# 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. puts e.backtrace end |
Instance Method Details
#call ⇒ Object
19 20 21 22 |
# File 'lib/aspen/actions/push.rb', line 19 def call drop push end |
#drop ⇒ Object
24 25 26 27 28 |
# 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 ⇒ Object
30 31 32 33 34 35 |
# 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 |