Class: Dato::Dump::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/dato/dump/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path, client, preview_mode, loader, destination_path = Dir.pwd) ⇒ Runner

Returns a new instance of Runner.



13
14
15
16
17
18
19
# File 'lib/dato/dump/runner.rb', line 13

def initialize(config_path, client, preview_mode, loader, destination_path = Dir.pwd)
  @config_path = config_path
  @preview_mode = preview_mode
  @client = client
  @destination_path = destination_path
  @loader = loader
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



11
12
13
# File 'lib/dato/dump/runner.rb', line 11

def client
  @client
end

#config_pathObject (readonly)

Returns the value of attribute config_path.



11
12
13
# File 'lib/dato/dump/runner.rb', line 11

def config_path
  @config_path
end

#destination_pathObject (readonly)

Returns the value of attribute destination_path.



11
12
13
# File 'lib/dato/dump/runner.rb', line 11

def destination_path
  @destination_path
end

#loaderObject (readonly)

Returns the value of attribute loader.



11
12
13
# File 'lib/dato/dump/runner.rb', line 11

def loader
  @loader
end

#preview_modeObject (readonly)

Returns the value of attribute preview_mode.



11
12
13
# File 'lib/dato/dump/runner.rb', line 11

def preview_mode
  @preview_mode
end

Instance Method Details

#operationObject



36
37
38
# File 'lib/dato/dump/runner.rb', line 36

def operation
  @operation ||= Operation::Root.new(destination_path)
end

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dato/dump/runner.rb', line 21

def run
  I18n.available_locales = loader.items_repo.available_locales
  I18n.locale = I18n.available_locales.first

  Dsl::Root.new(
    File.read(config_path),
    loader.items_repo,
    operation
  )

  operation.perform

  puts "\e[32m✓\e[0m Done!"
end