Class: Zon::Zig::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/zon/zig.rb

Overview

An abstraction of the Zig package manifest.

Every Zig package should have a build.zig.zon in its package root, the manifest. Like a manifest in Ruby, it is used to describe the package and specify required dependencies.

Instance Method Summary collapse

Constructor Details

#initialize(zon) ⇒ Manifest

Returns a new instance of Manifest.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zon/zig.rb', line 15

def initialize(zon)
  raise "Missing '.name'" if not zon[:name]
  raise "Missing '.version'" if not zon[:version]
  raise "Missing '.fingerprint'" if not zon[:fingerprint]
  raise "Missing '.paths'" if not zon[:paths]

  if zon[:dependencies]
    zon[:dependencies].each do |key, value|
      if value[:url]
        raise "Missing '.hash' for dependency '#{key}'" if not value[:hash]
      elsif not value[:path]
        raise "Expected either '.url' or '.path' for dependency '#{key}'" if not value[:hash]
      end 
    end
  end

  @zon = zon
end

Instance Method Details

#dependenciesObject

Get the '.dependencies' field of the manifest.

This will return nil if the '.dependencies' field does not exist.



56
57
58
# File 'lib/zon/zig.rb', line 56

def dependencies
  @zon[:dependencies]
end

#fingerprintObject

Get the '.fingerprint' field of the manifest.



48
49
50
# File 'lib/zon/zig.rb', line 48

def fingerprint
  @zon[:fingerprint]
end

#minimum_zig_versionObject

Get the '.minimum_zig_version' field of the manifest.

This will return nil if the '.minimum_zig_version' field does not exist.



72
73
74
# File 'lib/zon/zig.rb', line 72

def minimum_zig_version
  @zon[:minimum_zig_version]
end

#nameObject

Get the '.name' field of the manifest.



36
37
38
# File 'lib/zon/zig.rb', line 36

def name
  @zon[:name]
end

#pathsObject

Get the '.paths' field of the manifest.

This will return nil if the '.paths' field does not exist.



64
65
66
# File 'lib/zon/zig.rb', line 64

def paths
  @zon[:paths]
end

#versionObject

Get the '.version' field of the manifest.



42
43
44
# File 'lib/zon/zig.rb', line 42

def version
  @zon[:version]
end