class TerraspaceBundler::Exporter

Public Class Methods

new(options={}) click to toggle source
# File lib/terraspace_bundler/exporter.rb, line 6
def initialize(options={})
  @options = options
end

Public Instance Methods

export(mod) click to toggle source
# File lib/terraspace_bundler/exporter.rb, line 27
def export(mod)
  fetcher = Mod::Fetcher.new(mod).instance
  fetcher.run
  fetcher.switch_version(mod.sha)
  copy = Copy.new(mod)
  copy.mod
  copy.stacks
  logger.debug "Exported: #{copy.mod_path}"
end
mods() click to toggle source
# File lib/terraspace_bundler/exporter.rb, line 19
def mods
  mods = lockfile.mods
  if TB.update_mode? && !@options[:mods].empty?
    mods.select! { |mod| @options[:mods].include?(mod.name) }
  end
  mods
end
run() click to toggle source
# File lib/terraspace_bundler/exporter.rb, line 10
def run
  purge_all
  mods.each do |mod|
    logger.info "Exporting #{mod.name}"
    purge(mod)
    export(mod)
  end
end

Private Instance Methods

lockfile() click to toggle source
# File lib/terraspace_bundler/exporter.rb, line 49
def lockfile
  Lockfile.instance
end
purge(mod) click to toggle source
# File lib/terraspace_bundler/exporter.rb, line 44
def purge(mod)
  mod_path = get_mod_path(mod)
  FileUtils.rm_rf(mod_path)
end
purge_all() click to toggle source
# File lib/terraspace_bundler/exporter.rb, line 38
def purge_all
  return if TB.update_mode?
  return unless TB.config.export_purge
  FileUtils.rm_rf(TB.config.export_to)
end