class Aspen::Actions::Compile

Attributes

options[R]

Public Class Methods

new(path, options = {}) click to toggle source
# File lib/aspen/actions/compile.rb, line 7
def initialize(path, options = {})
  @path = path
  @basename = File.basename(@path, ".aspen")
  dir       = File.dirname(@path)
  @dest     = File.expand_path("#{@basename}.cql", dir)
  @options  = options
end

Public Instance Methods

call() click to toggle source
# File lib/aspen/actions/compile.rb, line 15
def call
  compile_to_file
  send_to_database if options.fetch(:database, false)
end

Private Instance Methods

compile_to_file() click to toggle source
# File lib/aspen/actions/compile.rb, line 22
def compile_to_file
  @cypher ||= Aspen.compile_text(File.read(@path))
  File.open(@dest, 'w') { |file| file << @cypher }
  puts "Compiled #{@basename}.aspen to #{@basename}.cql."
end