class Slipspace::Navigation

Public Instance Methods

drop(slipspace,dream) click to toggle source
# File lib/slipspace/cli.rb, line 16
def drop(slipspace,dream)
  if !File.exist?(slipspace)
    puts 'Error: Unable to locate slipspace.yml'
    puts 'Shutting down...'
  elsif !File.exists?(dream)
    puts 'Error: Unable to locate dream.yml'
    puts 'Shutting down...'
  else
    portal = Slipspace::Stream.new(YAML::load_file(slipspace), YAML::load_file(dream))
    portal.throttle()
    puts portal.drop()
  end
end
prepare() click to toggle source
# File lib/slipspace/cli.rb, line 11
def prepare()
  install('slipspace.yml')
  system('dream sleep')
end

Private Instance Methods

install(template_file) click to toggle source
# File lib/slipspace/cli.rb, line 30
def install(template_file)
    install_path = options[:install] ? options[:install] : '.'
    filename = options[:name] ? options[:name] : template_file
    template = File.read(File.join(File.dirname(__FILE__),'templates',template_file))
    success = false
    msg = ''
    file = File.join(install_path, filename)
    if File.exists?(file)
        warn "[skip] `#{filename}' already exists"
        if yes?("Would you like to overwrite the existing file?")
            msg = "#{filename} has been overwritten"
            success=true
        end
    elsif File.exists?(file.downcase)
        warn "[skip] `#{filename.downcase}' exists, which could conflict with `#{filename}'"
        if yes?("Would you like to overwrite the existing file?")
            msg = "#{filename} has been overwritten"
            success=true
        end
    elsif !File.exists?(File.dirname(file))
        warn "[skip] directory `#{File.dirname(file)}' does not exist"
        if yes?("Would you like to make the directory?")
            FileUtils.mkdir_p(install_path)
            msg = "The directory #{install_path} was created"
            success=true
        end
    else
        msg = "There were no issues with the installation"
        success=true
    end

    if success
        puts "[add] writing `#{filename}'"
        File.open(file, "w") { |f| f.write(template) }
        puts "#{msg}"
        puts "[done] Slipspace was successfully installed. Travel well."
    else
        puts "[error] Slipspace was not successfully installed."
    end
end