Class: Wasify

Inherits:
Object
  • Object
show all
Defined in:
lib/wasify.rb,
lib/wasify/version.rb,
lib/wasify/cmd_runner.rb,
lib/wasify/deps_manager.rb

Overview

wrapper for Wasify

Defined Under Namespace

Classes: CMDRunner, DepsManager

Constant Summary collapse

VERSION =
'0.1.2'

Class Method Summary collapse

Class Method Details

.build_wasmObject



21
22
23
# File 'lib/wasify.rb', line 21

def self.build_wasm
  CMDRunner.run_vfs
end

.cleanupObject



25
26
27
# File 'lib/wasify.rb', line 25

def self.cleanup
  CMDRunner.cleanup
end

.generate_html(entrypoint) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/wasify.rb', line 35

def self.generate_html(entrypoint)
  entrypoint_txt = DepsManager.add_entrypoint(entrypoint)
  template = 'wasify/template.erb'
  html = ERB.new(File.read(File.join(__dir__, template))).result(binding)
  File.rename('index.html', 'index.html.bak') if File.exist?('index.html')
  File.open('index.html', 'w+') do |f|
    f.write html
  end
end

.packObject



29
30
31
32
33
# File 'lib/wasify.rb', line 29

def self.pack
  prepack
  build_wasm
  cleanup
end

.prepackObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/wasify.rb', line 10

def self.prepack
  CMDRunner.download_binary unless File.exist?('ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz')
  CMDRunner.unzip_binary unless Dir.exist?('ruby-3_2-wasm32-unknown-wasi-full-js')
  CMDRunner.move_binary unless File.exist?('ruby.wasm')
  CMDRunner.fix_lockfile
  CMDRunner.copy_gemfile
  File.delete('packed_ruby.wasm') if File.exist?('packed_ruby.wasm')
  DepsManager.copy_deps
  DepsManager.copy_specs
end