Class: PuppetMetadata::Metadata
- Inherits:
-
Object
- Object
- PuppetMetadata::Metadata
- Defined in:
- lib/puppet_metadata/metadata.rb
Overview
An abstraction over Puppet metadata
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #beaker_setfiles(use_fqdn: false, pidfile_workaround: false) {|setfile| ... } ⇒ Object
-
#dependencies ⇒ Hash[String, SemanticPuppet::VersionRange]
A hash representation of the dependencies.
- #eol_operatingsystems(at = nil) ⇒ Hash[String, Array[String]]
-
#github_actions ⇒ PuppetMetadata::GithubActions
A GithubActions instance.
-
#initialize(metadata, validate = true) ⇒ Metadata
constructor
A new instance of Metadata.
-
#license ⇒ String
The license.
-
#name ⇒ String
The name.
-
#operatingsystems ⇒ Hash[String, Array[String]]
The supported operating system and its major releases.
-
#os_release_supported?(operatingsystem, release) ⇒ Boolean
Returns whether an operating system’s release is supported.
-
#puppet_major_versions ⇒ Array[Integer]
Supported major Puppet versions.
-
#requirements ⇒ Hash[String, SemanticPuppet::VersionRange]
A hash representation of the requirements.
- #satisfies_dependency?(name, version) ⇒ Boolean
- #satisfies_requirement?(name, version) ⇒ Boolean
-
#version ⇒ String
The version.
Constructor Details
#initialize(metadata, validate = true) ⇒ Metadata
Returns a new instance of Metadata.
34 35 36 37 38 39 40 41 42 |
# File 'lib/puppet_metadata/metadata.rb', line 34 def initialize(, validate = true) if validate require 'metadata_json_lint' schema_errors = MetadataJsonLint::Schema.new.validate() raise InvalidMetadataException.new(schema_errors) if schema_errors.any? end = end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
23 24 25 |
# File 'lib/puppet_metadata/metadata.rb', line 23 def end |
Instance Method Details
#beaker_setfiles(use_fqdn: false, pidfile_workaround: false) {|setfile| ... } ⇒ Object
193 194 195 196 197 198 199 200 201 |
# File 'lib/puppet_metadata/metadata.rb', line 193 def beaker_setfiles(use_fqdn: false, pidfile_workaround: false) .each do |os, releases| next unless PuppetMetadata::Beaker.os_supported?(os) releases&.each do |release| setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, release, use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround) yield setfile if setfile end end end |
#dependencies ⇒ Hash[String, SemanticPuppet::VersionRange]
A hash representation of the dependencies
Every element in the original array is converted. The name is used as a key while version_requirement is used as a value. No value indicates any version is accepted.
170 171 172 |
# File 'lib/puppet_metadata/metadata.rb', line 170 def dependencies @dependencies ||= build_version_requirement_hash(['dependencies']) end |
#eol_operatingsystems(at = nil) ⇒ Hash[String, Array[String]]
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/puppet_metadata/metadata.rb', line 96 def (at = nil) at ||= Date.today unsupported = .map do |os, rels| next unless rels eol = rels.select { |rel| .eol?(os, rel, at) } [os, eol] if eol.any? end Hash[unsupported.compact] end |
#github_actions ⇒ PuppetMetadata::GithubActions
Returns A GithubActions instance.
182 183 184 |
# File 'lib/puppet_metadata/metadata.rb', line 182 def github_actions PuppetMetadata::GithubActions.new(self) end |
#license ⇒ String
The license
58 59 60 |
# File 'lib/puppet_metadata/metadata.rb', line 58 def license ['license'] end |
#name ⇒ String
The name
46 47 48 |
# File 'lib/puppet_metadata/metadata.rb', line 46 def name ['name'] end |
#operatingsystems ⇒ Hash[String, Array[String]]
Returns The supported operating system and its major releases.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/puppet_metadata/metadata.rb', line 64 def ||= begin return {} if ['operatingsystem_support'].nil? supported = ['operatingsystem_support'].map do |os| next unless os['operatingsystem'] [os['operatingsystem'], os['operatingsystemrelease']] end Hash[supported.compact] end end |
#os_release_supported?(operatingsystem, release) ⇒ Boolean
Returns whether an operating system’s release is supported
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/puppet_metadata/metadata.rb', line 82 def os_release_supported?(, release) # If no OS is present, everything is supported. An example of this is # modules with only functions. return true if .empty? # if the key present, nil indicates all releases are supported return false unless .key?() releases = [] releases.nil? || releases.include?(release) end |
#puppet_major_versions ⇒ Array[Integer]
Returns Supported major Puppet versions.
140 141 142 143 144 145 146 147 |
# File 'lib/puppet_metadata/metadata.rb', line 140 def puppet_major_versions requirement = requirements['puppet'] raise Exception, 'No Puppet requirement found' unless requirement (requirement.begin.major..requirement.end.major).select do |major| requirement.include?(SemanticPuppet::Version.new(major, 0, 0)) || requirement.include?(SemanticPuppet::Version.new(major, 99, 99)) end end |
#requirements ⇒ Hash[String, SemanticPuppet::VersionRange]
A hash representation of the requirements
Every element in the original array is converted. The name is used as a key while version_requirement is used as a value. No value indicates any version is accepted.
127 128 129 |
# File 'lib/puppet_metadata/metadata.rb', line 127 def requirements @requirements ||= build_version_requirement_hash(['requirements']) end |
#satisfies_dependency?(name, version) ⇒ Boolean
177 178 179 |
# File 'lib/puppet_metadata/metadata.rb', line 177 def satisfies_dependency?(name, version) matches?(dependencies[name], version) end |
#satisfies_requirement?(name, version) ⇒ Boolean
134 135 136 |
# File 'lib/puppet_metadata/metadata.rb', line 134 def satisfies_requirement?(name, version) matches?(requirements[name], version) end |
#version ⇒ String
The version
52 53 54 |
# File 'lib/puppet_metadata/metadata.rb', line 52 def version ['version'] end |