Skip to content
This repository has been archived by the owner on Jan 11, 2018. It is now read-only.

Commit

Permalink
Installer#launch: save database in $HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Apr 15, 2009
1 parent 54a76b2 commit 4a0ef65
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/integrity/installer.rb
Expand Up @@ -5,6 +5,11 @@ module Integrity
class Installer < Thor
include FileUtils

def self.database_path
File.join(ENV["HOME"], ".integrity.sqlite3")
end
private_class_method :database_path

desc "install [PATH]",
"Copy template files to PATH for desired deployement strategy
(either Thin, Passenger or Heroku). Next, go there and edit them."
Expand Down Expand Up @@ -36,21 +41,24 @@ def migrate_db(config)
end

desc "launch [CONFIG]",
"Launch Integrity real quick."
method_options :config => :optional, :port => 4567
"Launch Integrity real quick. Database is saved in #{database_path}."
method_options :config => :optional, :port => :optional
def launch
require "thin"
require "do_sqlite3"

File.file?(options[:config].to_s) ?
Integrity.new(options[:config]) : Integrity.new
Integrity.config[:base_uri] = "http://0.0.0.0:#{options[:port]}"
options[:port] ||= 4567
config = { :database_uri => "sqlite3://#{ENV["HOME"]}/.integrity.db",
:base_uri => "http://0.0.0.0:#{options[:port]}",
:export_directory => "/tmp/integrity-exports" }
config.merge!(YAML.load_file(options[:config])) if options[:config]

DataMapper.auto_migrate!
migrate_db(config)

Thin::Server.start("0.0.0.0", options[:port], Integrity::App)
rescue LoadError => boom
puts "Make sure thin and do_sqlite3 are insatalled"
$stderr << "Make sure thin and do_sqlite3 are insatalled\n\n"
raise
end

private
Expand Down

0 comments on commit 4a0ef65

Please sign in to comment.