Sha256: 48f0b6faf84c0f40600a363a8603dd6b9fd6a4cd321e7f8cac31d9d8b5f00c4c

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

module TerraspaceBundler
  class Exporter
    include TB::Mod::Concerns::PathConcern
    include TB::Util::Logging

    def initialize(options={})
      @options = options
    end

    def run
      purge_all
      mods.each do |mod|
        logger.info "Exporting #{mod.name}"
        purge(mod)
        export(mod)
      end
    end

    def mods
      mods = lockfile.mods
      if TB.update_mode? && !@options[:mods].empty?
        mods.select! { |mod| @options[:mods].include?(mod.name) }
      end
      mods
    end

    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

  private
    def purge_all
      return if TB.update_mode?
      return unless TB.config.export_purge
      FileUtils.rm_rf(TB.config.export_to)
    end

    def purge(mod)
      mod_path = get_mod_path(mod)
      FileUtils.rm_rf(mod_path)
    end

    def lockfile
      Lockfile.instance
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
terraspace-bundler-0.5.0 lib/terraspace_bundler/exporter.rb
terraspace-bundler-0.4.4 lib/terraspace_bundler/exporter.rb
terraspace-bundler-0.4.3 lib/terraspace_bundler/exporter.rb
terraspace-bundler-0.4.2 lib/terraspace_bundler/exporter.rb
terraspace-bundler-0.4.1 lib/terraspace_bundler/exporter.rb
terraspace-bundler-0.4.0 lib/terraspace_bundler/exporter.rb