Class: Zui::LiteRuntime

Inherits:
Client
  • Object
show all
Defined in:
lib/zui/lite_runtime.rb

Constant Summary collapse

FORMAT =
1
MRUBY_VERSION =
"4.0.0"
MRUBY_REVISION =
"831da26b9021de0369d17b71b5667e2941a1a32d"
MRUBY_JSON_REVISION =
"f99d9428025469f2400f93c53b185f65f963e507"

Constants inherited from Client

Client::MAX_ARCHIVE_BYTES, Client::MAX_ENTRIES, Client::MAX_EXPANDED_BYTES, Client::REDIRECT_LIMIT

Instance Attribute Summary

Attributes inherited from Client

#platform, #version

Instance Method Summary collapse

Methods inherited from Client

#configured?, #copy_to, #environment, #environment_entries, #executable, #executable_relative_path, #initialize, #manifest

Constructor Details

This class inherits a constructor from Zui::Client

Instance Method Details

#archive_nameObject



20
# File 'lib/zui/lite_runtime.rb', line 20

def archive_name = "zui-runtime-lite-#{platform.id}.tar.gz"

#archive_urlObject



31
32
33
34
35
36
# File 'lib/zui/lite_runtime.rb', line 31

def archive_url
  override = @environment["ZUI_LITE_RUNTIME_ARCHIVE"]
  return File.expand_path(override) if override && !override.empty?

  URI.join("#{release_base_url}/", archive_name)
end

#checksum_urlObject



38
39
40
41
42
43
44
# File 'lib/zui/lite_runtime.rb', line 38

def checksum_url
  override = @environment["ZUI_LITE_RUNTIME_CHECKSUM"]
  return File.expand_path(override) if override && !override.empty?

  source = archive_url
  source.is_a?(URI) ? URI("#{source}.sha256") : "#{source}.sha256"
end

#configure!Object



22
23
24
25
26
27
28
29
# File 'lib/zui/lite_runtime.rb', line 22

def configure!
  return root if configured?
  if client_root_override?
    raise ArgumentError, "ZUI_LITE_RUNTIME_ROOT is not a valid configured lite runtime: #{root}"
  end

  super
end

#install(project:, destination:) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/zui/lite_runtime.rb', line 46

def install(project:, destination:)
  unless configured?
    raise ArgumentError,
          "Zui lite runtime is not configured for #{platform.id}; run `zui doctor --fix` before bundling"
  end

  copy_to(destination)
  File.write(File.join(destination, "app.rb"), LiteSource.new(project:).call)
  ApplicationRuntime.new(
    engine: "mruby", version: manifest.fetch("engine_version"),
    executable: manifest.fetch("executable"), program: "app.rb", load_path: ""
  ).write(destination)
end

#rootObject



13
14
15
16
17
18
# File 'lib/zui/lite_runtime.rb', line 13

def root
  override = @environment["ZUI_LITE_RUNTIME_ROOT"]
  return File.expand_path(override) if override && !override.empty?

  File.join(cache_root, "zui", "runtimes", version, platform.id, "lite")
end