Sha256: c6be2cd8882f9df3c3b30b55f42a5beab53aa6628af9caabd372a3a3015a631e

Contents?: true

Size: 788 Bytes

Versions: 2

Compression:

Stored size: 788 Bytes

Contents

#! /usr/bin/env ruby

require 'pathname'
require 'uri'

def restore( db, directory )
  require 'wyrm/restore_schema'
  rs = RestoreSchema.new db, directory
  rs.create
  rs.restore_tables
  rs.index
end

def dump( db, directory )
  require 'wyrm/dump_schema'
  ds = DumpSchema.new db, directory
  ds.dump_schema
  ds.dump_tables
end

if ARGV.empty?
  puts "Provide source and destination"
  puts "Either can be a sequel db string or a directory"
end

src, dst = ARGV.map{|arg| URI.parse arg}

if src.scheme && Pathname(dst.to_s).exist?
  # src is a db path, so dump from it
  dump( src.to_s, dst.to_s )
elsif dst.scheme && Pathname(src.to_s).exist?
  # dst is a path and src is a url, so restore
  restore( dst.to_s, src.to_s )
else
  puts "Don't know how to handle #{src} -> #{dst}"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wyrm-0.2.1 bin/wyrm
wyrm-0.2.0 bin/wyrm