Class: Zui::ApplicationRuntime

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

Constant Summary collapse

FORMAT =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine:, version:, executable:, environment: {}, gems: [], program: nil, load_path: nil) ⇒ ApplicationRuntime

Returns a new instance of ApplicationRuntime.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zui/application_runtime.rb', line 11

def initialize(engine:, version:, executable:, environment: {}, gems: [], program: nil, load_path: nil)
  @engine = engine.to_s
  @version = version.to_s
  @executable = executable.to_s
  @environment = environment.transform_keys(&:to_s).transform_values do |paths|
    Array(paths).map(&:to_s).freeze
  end.freeze
  @gems = Array(gems).map(&:to_s).sort.freeze
  @program = program&.to_s
  @load_path = load_path&.to_s
  freeze
end

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



9
10
11
# File 'lib/zui/application_runtime.rb', line 9

def engine
  @engine
end

#environmentObject (readonly)

Returns the value of attribute environment.



9
10
11
# File 'lib/zui/application_runtime.rb', line 9

def environment
  @environment
end

#executableObject (readonly)

Returns the value of attribute executable.



9
10
11
# File 'lib/zui/application_runtime.rb', line 9

def executable
  @executable
end

#gemsObject (readonly)

Returns the value of attribute gems.



9
10
11
# File 'lib/zui/application_runtime.rb', line 9

def gems
  @gems
end

#load_pathObject (readonly)

Returns the value of attribute load_path.



9
10
11
# File 'lib/zui/application_runtime.rb', line 9

def load_path
  @load_path
end

#programObject (readonly)

Returns the value of attribute program.



9
10
11
# File 'lib/zui/application_runtime.rb', line 9

def program
  @program
end

#versionObject (readonly)

Returns the value of attribute version.



9
10
11
# File 'lib/zui/application_runtime.rb', line 9

def version
  @version
end

Instance Method Details

#to_hObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/zui/application_runtime.rb', line 29

def to_h
  result = {
    "format" => FORMAT,
    "engine" => engine,
    "version" => version,
    "executable" => executable,
    "environment" => environment,
    "gems" => gems
  }
  result["program"] = program unless program.nil?
  result["load_path"] = load_path unless load_path.nil?
  result
end

#write(directory) ⇒ Object



24
25
26
27
# File 'lib/zui/application_runtime.rb', line 24

def write(directory)
  File.write(File.join(directory, "runtime.json"), "#{JSON.pretty_generate(to_h)}\n")
  self
end