Sha256: b42b67235f333cc441b4ad120326eac1ca12785f8ae98d487753e5ef5db8227c

Contents?: true

Size: 856 Bytes

Versions: 2

Compression:

Stored size: 856 Bytes

Contents

require_relative 'adaptors/io'
require_relative 'package_config'

module EnginePack
  class EnginePackage
    def initialize(
      engine,
      io: Adaptors::IO.new,
      package_config: PackageConfig.new(EnginePack.gem_specs.find { |s| s.name == engine }&.full_gem_path)
    )
      @engine = engine
      @io = io
      @package_config = package_config
    end

    def with_path
      io.mkdir(path: tmp_path)
      copy_specified_files(tmp_path)

      yield tmp_path
    end

    private

    attr_reader :engine, :gem_specs, :io, :package_config

    def copy_specified_files(dir)
      io.copy_files(
        files: package_config.package_files_paths,
        to: dir
      )
    end

    def package_json?
      io.exist?(path: "#{engine_path}/package.json")
    end

    def tmp_path
      "#{io.tmpdir}/enginepack/#{engine}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
engine_pack-0.2.0 lib/engine_pack/engine_package.rb
engine_pack-0.1.0 lib/engine_pack/engine_package.rb