AddClassnames

Constants

Methods

#default_path

def default_path
  Rails.root if defined? Rails
end

#initialize

def initialize(path = default_path)
  @classnames_filename = 'add_classnames.yml'
  @classnames_filepath = File.join(joined_path(path), classnames_filename)
end

#joined_path

def joined_path(path)
  File.join(path.to_s, 'db', 'neo4j-migrate')
end

#migrate

def migrate
  output 'Adding classnames. This make take some time.'
  execute(true)
end

#output

def output(string = '')
  puts string unless !!ENV['silenced']
end

#print_output

def print_output(string)
  print string unless !!ENV['silenced']
end

#setup

def setup
  output "Creating file #{classnames_filepath}. Please use this as the migration guide."
  FileUtils.mkdir_p('db/neo4j-migrate')

  return if File.file?(classnames_filepath)

  source = File.join(File.dirname(__FILE__), '..', '..', 'config', 'neo4j', classnames_filename)
  FileUtils.copy_file(source, classnames_filepath)
end

#test

def test
  output 'TESTING! No queries will be executed.'
  execute(false)
end