class EmbeddedJs::GemPackage

Attributes

engine[R]
gem_specs[R]
io[R]
package_config[R]

Public Class Methods

new( engine, io: Adaptors::IO.new, package_config: PackageConfig.new(EmbeddedJs.gem_specs.find { |s| s.name == engine }&.full_gem_path) ) click to toggle source
# File lib/embedded_js/gem_package.rb, line 8
def initialize(
  engine,
  io: Adaptors::IO.new,
  package_config: PackageConfig.new(EmbeddedJs.gem_specs.find { |s| s.name == engine }&.full_gem_path)
)
  @engine = engine
  @io = io
  @package_config = package_config
end

Public Instance Methods

with_path() { |tmp_path| ... } click to toggle source
# File lib/embedded_js/gem_package.rb, line 18
def with_path
  io.mkdir(path: tmp_path)
  copy_specified_files(tmp_path)

  yield tmp_path
end

Private Instance Methods

copy_specified_files(dir) click to toggle source
# File lib/embedded_js/gem_package.rb, line 29
def copy_specified_files(dir)
  io.copy_files(
    files: package_config.package_files_paths,
    to: dir
  )
end
package_json?() click to toggle source
# File lib/embedded_js/gem_package.rb, line 36
def package_json?
  io.exist?(path: "#{engine_path}/package.json")
end
tmp_path() click to toggle source
# File lib/embedded_js/gem_package.rb, line 40
def tmp_path
  "#{io.tmpdir}/EmbeddedJs/#{engine}"
end