Sha256: 850132bcb13ab796e23b4760b0d627f51314d9173f2e34f7fb31db8ba94ced20
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true require 'bolt/error' # This class represents a module specification. It used by the Bolt::Puppetfile # class to have a consistent API for accessing a module's attributes. # module Bolt class Puppetfile class Module attr_reader :owner, :name, :version def initialize(owner, name, version = nil) @owner = owner @name = name @version = version end # Creates a new module from a hash. # def self.from_hash(mod) unless mod['name'].is_a?(String) raise Bolt::ValidationError, "Module name must be a String, not #{mod['name'].inspect}" end owner, name = mod['name'].tr('/', '-').split('-', 2) unless owner && name raise Bolt::ValidationError, "Module name #{mod['name']} must include both the owner and module name." end new(owner, name) end # Returns the module's title. # def title "#{@owner}-#{@name}" end # Checks two modules for equality. # def eql?(other) self.class == other.class && @owner == other.owner && @name == other.name end alias == eql? # Hashes the module. # def hash [@owner, @name].hash end # Returns the Puppetfile specification for the module. # def to_spec if @version "mod #{title.inspect}, #{@version.inspect}" else "mod #{title.inspect}" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bolt-2.28.0 | lib/bolt/puppetfile/module.rb |
bolt-2.27.0 | lib/bolt/puppetfile/module.rb |