Class: Ghost::Seeder::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/ghost/seeder/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Runner

Returns a new instance of Runner.



28
29
30
# File 'lib/ghost/seeder/runner.rb', line 28

def initialize(environment)
  @environment = environment
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



26
27
28
# File 'lib/ghost/seeder/runner.rb', line 26

def environment
  @environment
end

Class Method Details

.environmentObject



17
18
19
# File 'lib/ghost/seeder/runner.rb', line 17

def environment
  ENV["NODE_ENV"] || "development"
end

.runObject



13
14
15
# File 'lib/ghost/seeder/runner.rb', line 13

def run
  new(environment).run
end

.wipe_db?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/ghost/seeder/runner.rb', line 21

def wipe_db?
  ENV["WIPE_DB"]
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ghost/seeder/runner.rb', line 32

def run
  db.connect!
  Logger.warn "seeding database for", environment
  klasses.each do |klass|
    klass.wipe_records! if self.class.wipe_db?
    klass.perform_queries
    Logger.success klass
  end
  db.disconnect!
  Logger.success "finished seeding!"
end