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



12
13
14
15
16
17
18
19
20
# File 'lib/integrity/installer.rb', line 12

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

  create_dir_structure
  copy_template_files
  edit_template_files
  migrate_db(root.join("config.yml"))
  after_setup_message
end

#launchObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/integrity/installer.rb', line 35

def launch
  require "thin"
  require "do_sqlite3"

  if File.file?(options[:config].to_s)
    Integrity.new(options[:config])
  else
    DataMapper.setup(:default, "sqlite3::memory:")
  end

  DataMapper.auto_migrate!

  Thin::Server.start("0.0.0.0", options[:port], Integrity::App)
rescue LoadError => boom
  missing_dependency = boom.message.split("--").last.lstrip
  puts "Please install #{missing_dependency} to launch Integrity"
end

#migrate_db(config) ⇒ Object



25
26
27
28
29
30
# File 'lib/integrity/installer.rb', line 25

def migrate_db(config)
  Integrity.new(config)

  require "integrity/migrations"
  Integrity.migrate_db
end

#versionObject



55
56
57
# File 'lib/integrity/installer.rb', line 55

def version
  puts Integrity.version
end