Sha256: b0475a1aaa65401c4742a53ceb7c6227f0380294530b4ec4767b55da908c5065

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

module Lono::Bundler
  class Exporter
    include LB::Component::Concerns::PathConcern
    include LB::Util::Logging

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

    def run
      purge_all
      components.each do |component|
        logger.info "Exporting #{component.export_path}"
        purge(component)
        export(component)
      end
    end

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

    def export(component)
      fetcher = Component::Fetcher.new(component).instance
      fetcher.run
      fetcher.switch_version(component.sha)
      copy = Copy.new(component)
      copy.component
    end

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

    def purge(component)
      FileUtils.rm_rf(component.export_path)
    end

    def lockfile
      Lockfile.instance
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/bundler/exporter.rb
lono-8.0.0.pre.rc5 lib/lono/bundler/exporter.rb
lono-8.0.0.pre.rc4 lib/lono/bundler/exporter.rb
lono-8.0.0.pre.rc3 lib/lono/bundler/exporter.rb
lono-8.0.0.pre.rc2 lib/lono/bundler/exporter.rb
lono-8.0.0.pre.rc1 lib/lono/bundler/exporter.rb