Class: SCV::CLI

Inherits:
Thor
  • Object
show all
Includes:
Rails::Generators::Actions, Thor::Actions
Defined in:
lib/scv/cli.rb

Instance Method Summary collapse

Instance Method Details

#bootstrapObject



14
15
16
17
18
# File 'lib/scv/cli.rb', line 14

def bootstrap
  invoke :config, [], :force => true
  invoke :db, [], :seed => false
  invoke :populate, :truncate => false
end

#configObject



27
28
29
30
# File 'lib/scv/cli.rb', line 27

def config
  source_paths.push(destination_root = ".")
  directory("config/examples", "config")
end

#dbObject



35
36
37
38
39
40
41
42
43
# File 'lib/scv/cli.rb', line 35

def db
  rake([].tap do |commands|
    commands.push "db:drop" if options.drop?
    commands.push "db:create"
    commands.push "db:migrate"
    commands.push "db:seed" if options.seed?
    commands.push "db:test:prepare"
  end.join(" "))
end

#populateObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/scv/cli.rb', line 47

def populate
  log :load, "environment"
  require './config/environment'

  if options.truncate?
    log :truncate, "database"
    DatabaseCleaner.clean_with(:truncation)
  end
  load_seed_file("db/seeds.rb")
  load_seed_file("db/populate.rb")
end

#resetObject



21
22
23
24
# File 'lib/scv/cli.rb', line 21

def reset
  invoke :db, [], :drop => true, :seed => false
  invoke :populate, [], :truncate => false
end