Sha256: 5546f29a67cd93377249c17ef18e2cb3273e9bc3e5feaef70dfc08e02025ccfd
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
require 'fileutils' require 'quartz_flow/model' # Class used to setup a new QuartzFlow home directory, and get information about it. class Home def initialize(dir = ".") @dir = dir @subdirs = [ "etc", "log", "download", "meta", "public", "db", "views", ] @installRoot = Home.determineAppRoot("quartz_flow") end def validate rc = true @subdirs.each do |subdir| path = File.join(@dir, subdir) if ! File.directory?(path) puts "Error: The home directory is invalid: the subdirectory #{subdir} doesn't exist under the home directory. Was the setup command run?" rc = false break end end rc end def setup @subdirs.each do |subdir| if File.directory?(subdir) puts "Directory #{subdir} already exists. Skipping creation." else installedPath = @installRoot + File::SEPARATOR + subdir if File.directory? installedPath FileUtils.cp_r installedPath, @dir puts "Copying #{subdir}" else FileUtils.mkdir @dir + File::SEPARATOR + subdir puts "Creating #{subdir}" end end end # Create database dbFile = "#{File.expand_path(@dir)}/db/quartz.sqlite" if ! File.exists?(dbFile) puts "Creating database file" path = "sqlite://#{File.expand_path(@dir)}/db/quartz.sqlite" DataMapper.setup(:default, path) DataMapper.auto_migrate! else puts "Database file already exists. Running upgrade." path = "sqlite://#{File.expand_path(@dir)}/db/quartz.sqlite" DataMapper.setup(:default, path) DataMapper.auto_upgrade! end end def self.determineAppRoot(gemname) # Are we running as a Gem, or from the source directory? if Gem.loaded_specs[gemname] Gem.loaded_specs[gemname].full_gem_path else "." end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quartz_flow-0.0.1 | lib/quartz_flow/home.rb |