Class: LogicaCompiler::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/logica_compiler/manifest.rb

Constant Summary collapse

VERSION =
1

Class Method Summary collapse

Class Method Details

.build(engine:, logica_version:, queries:, compiled_at: Time.now.utc) ⇒ Object



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

def self.build(engine:, logica_version:, queries:, compiled_at: Time.now.utc)
  {
    "version" => VERSION,
    "engine" => engine.to_s,
    "logica" => { "pypi" => "logica", "version" => logica_version.to_s },
    "compiled_at" => compiled_at.iso8601,
    "queries" => queries.transform_keys(&:to_s),
  }
end

.load(path) ⇒ Object



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

def self.load(path)
  JSON.parse(File.read(path.to_s))
end

.write!(path, manifest) ⇒ Object



25
26
27
28
29
# File 'lib/logica_compiler/manifest.rb', line 25

def self.write!(path, manifest)
  path = path.to_s
  FileUtils.mkdir_p(File.dirname(path))
  File.write(path, "#{JSON.pretty_generate(manifest)}\n")
end