Sha256: a279701e4c15029b7856d8654250a10ae518379c04217572c1ba3fd90558e4b1

Contents?: true

Size: 1.42 KB

Versions: 80

Compression:

Stored size: 1.42 KB

Contents

require 'puppet/module_tool'
require 'puppet/network/format_support'

module Puppet::ModuleTool

  class Dependency
    include Puppet::Network::FormatSupport

    attr_reader :full_module_name, :username, :name, :version_requirement, :repository

    # Instantiates a new module dependency with a +full_module_name+ (e.g.
    # "myuser-mymodule"), and optional +version_requirement+ (e.g. "0.0.1") and
    # optional repository (a URL string).
    def initialize(full_module_name, version_requirement = nil, repository = nil)
      @full_module_name = full_module_name
      # TODO: add error checking, the next line raises ArgumentError when +full_module_name+ is invalid
      @username, @name = Puppet::ModuleTool.username_and_modname_from(full_module_name)
      @version_requirement = version_requirement
      @repository = repository ? Puppet::Forge::Repository.new(repository) : nil
    end

    # We override Object's ==, eql, and hash so we can more easily find identical
    # dependencies.
    def ==(o)
      self.hash == o.hash
    end

    alias :eql? :==

    def hash
      [@full_module_name, @version_requirement, @repository].hash
    end

    def to_data_hash
      result = { :name => @full_module_name }
      result[:version_requirement] = @version_requirement if @version_requirement && ! @version_requirement.nil?
      result[:repository] = @repository.to_s if @repository && ! @repository.nil?
      result
    end
  end
end

Version data entries

80 entries across 80 versions & 2 rubygems

Version Path
puppet-5.3.7 lib/puppet/module_tool/dependency.rb
puppet-5.3.7-x86-mingw32 lib/puppet/module_tool/dependency.rb
puppet-5.3.7-x64-mingw32 lib/puppet/module_tool/dependency.rb
puppet-5.3.7-universal-darwin lib/puppet/module_tool/dependency.rb
bolt-0.20.3 vendored/puppet/lib/puppet/module_tool/dependency.rb
bolt-0.20.2 vendored/puppet/lib/puppet/module_tool/dependency.rb
bolt-0.19.1 vendored/puppet/lib/puppet/module_tool/dependency.rb
puppet-5.3.6 lib/puppet/module_tool/dependency.rb
puppet-5.3.6-x86-mingw32 lib/puppet/module_tool/dependency.rb
puppet-5.3.6-x64-mingw32 lib/puppet/module_tool/dependency.rb
puppet-5.3.6-universal-darwin lib/puppet/module_tool/dependency.rb
bolt-0.19.0 vendored/puppet/lib/puppet/module_tool/dependency.rb
bolt-0.18.2 vendored/puppet/lib/puppet/module_tool/dependency.rb
bolt-0.18.1 vendored/puppet/lib/puppet/module_tool/dependency.rb
bolt-0.18.0 vendored/puppet/lib/puppet/module_tool/dependency.rb
puppet-5.5.0 lib/puppet/module_tool/dependency.rb
puppet-5.5.0-x86-mingw32 lib/puppet/module_tool/dependency.rb
puppet-5.5.0-x64-mingw32 lib/puppet/module_tool/dependency.rb
puppet-5.5.0-universal-darwin lib/puppet/module_tool/dependency.rb
bolt-0.17.2 vendored/puppet/lib/puppet/module_tool/dependency.rb