Class: OctocatalogDiff::API::V1::Catalog

Inherits:
Object
  • Object
show all
Defined in:
lib/octocatalog-diff/api/v1/catalog.rb

Overview

This is a wrapper class around OctocatalogDiff::Catalog. This contains the methods we are choosing to expose, and will be a compatibility layer should underlying methods change in the future. The raw object will be available as `#raw` but this is not guaranteed to be stable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Catalog

Constructor: Accepts a raw OctocatalogDiff::Catalog object and stores it.

Parameters:


18
19
20
21
22
23
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 18

def initialize(raw)
  unless raw.is_a?(OctocatalogDiff::Catalog)
    raise ArgumentError, 'OctocatalogDiff::API::V1::Catalog#initialize expects OctocatalogDiff::Catalog argument'
  end
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw


14
15
16
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 14

def raw
  @raw
end

Instance Method Details

#builderString

Public: Get the builder for the catalog

Returns:

  • (String)

    Class of backend used


27
28
29
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 27

def builder
  @raw.builder
end

#compilation_dirString

Public: Get the compilation directory

Returns:

  • (String)

    Compilation directory


39
40
41
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 39

def compilation_dir
  @raw.compilation_dir
end

#error_messageString

Public: Get the error message

Returns:

  • (String)

    Error message, or nil if no error


45
46
47
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 45

def error_message
  @raw.error_message
end

#puppet_versionString

Public: Get the Puppet version used to compile the catalog

Returns:


51
52
53
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 51

def puppet_version
  @raw.puppet_version
end

#resource(opts = {}) ⇒ Hash

Public: Get a specific resource identified by type and title. This is intended for use when a O(1) lookup is required.

Parameters:

  • :type (String)

    Type of resource

  • :title (String)

    Title of resource

Returns:

  • (Hash)

    Resource item


60
61
62
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 60

def resource(opts = {})
  @raw.resource(opts)
end

#resourcesArray

Public: Get the resources in the catalog

Returns:

  • (Array)

    Resource array


66
67
68
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 66

def resources
  @raw.resources
end

#to_hHash

Public: Return catalog as hash.

Returns:

  • (Hash)

    Catalog as hash


78
79
80
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 78

def to_h
  @raw.catalog
end

#to_jsonString

Public: Get the JSON for the catalog

Returns:


33
34
35
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 33

def to_json
  @raw.catalog_json
end

#valid?Boolean

Public: Determine if the catalog build was successful.

Returns:

  • (Boolean)

    Whether the catalog is valid


72
73
74
# File 'lib/octocatalog-diff/api/v1/catalog.rb', line 72

def valid?
  @raw.valid?
end