Sha256: 7943bba20bbad5c208eb2f541b19ec26620244a09a07495d26ce810a9d68c69e

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

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

module Puppet::ModuleTool

  class Dependency
    include Puppet::Network::FormatSupport
    alias :to_json :to_pson

    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

    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

6 entries across 6 versions & 1 rubygems

Version Path
puppet-3.6.2 lib/puppet/module_tool/dependency.rb
puppet-3.6.2-x86-mingw32 lib/puppet/module_tool/dependency.rb
puppet-3.6.1 lib/puppet/module_tool/dependency.rb
puppet-3.6.1-x86-mingw32 lib/puppet/module_tool/dependency.rb
puppet-3.6.0 lib/puppet/module_tool/dependency.rb
puppet-3.6.0-x86-mingw32 lib/puppet/module_tool/dependency.rb