Class: Avm::Stereotypes::EacWebappBase0::Runner::Data::Load

Inherits:
EacRubyUtils::Console::DocoptRunner
  • Object
show all
Includes:
EacRubyUtils::Console::Speaker, EacRubyUtils::SimpleCache
Defined in:
lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb

Constant Summary collapse

DOC =
"Load utility for EacRailsBase instance.\n\nUsage:\n  __PROGRAM__ (<dump-path>|--source-instance=<source-instance>)\n  __PROGRAM__ -h | --help\n\nOptions:\n  -h --help                               Show this screen.\n  -S --source-instance=<source-instance>  Informa a inst\u00E2ncia a ser extra\u00EDda o dump.\n"

Instance Method Summary collapse

Instance Method Details

#dump_instance_methodObject



54
55
56
# File 'lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb', line 54

def dump_instance_method
  :dump_database
end

#dump_path_uncachedObject



36
37
38
39
40
41
# File 'lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb', line 36

def dump_path_uncached
  return options.fetch('<dump-path>').to_s if options.fetch('<dump-path>').present?
  return source_instance_dump_path if options.fetch('--source-instance').present?

  raise "Dump path unknown (Options: #{options})"
end

#load_dumpObject



49
50
51
52
# File 'lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb', line 49

def load_dump
  info "Loading dump \"#{dump_path}\"..."
  package_load.run
end

#runObject



28
29
30
31
32
33
34
# File 'lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb', line 28

def run
  return ::Dev::Result.error("Dump \"#{dump_path}\" does not exist") unless
  ::File.exist?(dump_path)

  load_dump
  success("Dump loaded from \"#{dump_path}\"")
end

#source_instance_dump_pathObject



43
44
45
46
47
# File 'lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb', line 43

def source_instance_dump_path
  context(:instance).class.by_id(
    options.fetch('--source-instance')
  ).data_dump
end