Class: Integrity::Installer

Inherits:
Thor
  • Object
show all
Includes:
FileUtils
Defined in:
lib/integrity/installer.rb

Instance Method Summary collapse

Instance Method Details

#install(path) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/integrity/installer.rb', line 19

def install(path)
  @root = Pathname(path).expand_path

  if options[:heroku]
    cp_r Pathname(__FILE__).join("../../../config/heroku"), root
    puts post_heroku_install_message
  else
    create_dir_structure
    copy_template_files
    edit_template_files
    puts post_install_message
  end
end

#launchObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/integrity/installer.rb', line 46

def launch
  require "thin"
  require "do_sqlite3"

  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]

  migrate_db(config)

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

#migrate_db(config) ⇒ Object



36
37
38
39
40
41
# File 'lib/integrity/installer.rb', line 36

def migrate_db(config)
  Integrity.new(config)

  require "integrity/migrations"
  Integrity.migrate_db
end