class GeneSystem::Manifest

Manifest is an in memory representation of a manifest file

Constants

DEFAULT_QUERY
SUPPORTED_PLATFORMS

list of supported platforms

Public Class Methods

incompatible?(manifest) click to toggle source

Incompatible returns true if the current manifest is not compatible with this version of GeneSystem.

A manifest is not compatible if it was created with a version greater than this the installed version.

@param [Hash] manifest

@return [Boolean]

# File lib/gene_system/manifest.rb, line 43
def incompatible?(manifest)
  manifest_version = manifest['metadata']['gene_system']['version']
  manifest_version > GeneSystem::VERSION
rescue NoMethodError
  true
end
new(path, data) click to toggle source
# File lib/gene_system/manifest.rb, line 54
def initialize(path, data)
  @path = path
  @data = Hashie::Mash.new(data)
  @steps = GeneSystem::Step.load_steps(@data.steps)
end
new_from_file(file_path) click to toggle source

Creates a [GeneSystem::Manifest] from a manifest json so long as the manifest is compatible with this version of GeneSystem.

@param [String] file_path

# File lib/gene_system/manifest.rb, line 16
def new_from_file(file_path)
  manifest = Jsonnet.evaluate(
    File.read(file_path)
  )

  if incompatible?(manifest)
    raise 'provided manifest is invalid or incompatible with '\
    'this version of gene_system'
  end

  new(
    file_path,
    manifest
  )
end

Public Instance Methods

metadata() click to toggle source

Manifest metadata getter

@return

# File lib/gene_system/manifest.rb, line 83
def metadata
  @data.metadata
end
name() click to toggle source

Manifest name getter

@return [String]

# File lib/gene_system/manifest.rb, line 65
def name
  @data.name
end
platform() click to toggle source

Platform metadata getter

Prints a warning when the platform is not recognized

@return

# File lib/gene_system/manifest.rb, line 94
def platform
  platform = @data.platform

  unless SUPPORTED_PLATFORMS.include?(platform)
    CLI.print_warning("WARN: unrecognized platform: #{@data.platform}")
  end

  platform
end
steps(query = DEFAULT_QUERY) click to toggle source

Steps executes a query function in a select call against each step to return a list of steps relevant to an operation.

The given query function should evaluate to true when the desired step should be in the return set.

By default a all steps will be returned.

@example query = ->(step) { step.tags.include?(“foo”) } manifest.steps(query)

@param [Lambda] query

@return [Array]

# File lib/gene_system/manifest.rb, line 121
def steps(query = DEFAULT_QUERY)
  @steps.select do |step|
    query.call(step)
  end
end
version() click to toggle source

Manifest version getter

@return [String]

# File lib/gene_system/manifest.rb, line 74
def version
  @data.version
end