Sha256: eb83e4a1d17414532d1497e416beb8aff448d0474346aa83e47129db0014b139

Contents?: true

Size: 1.38 KB

Versions: 225

Compression:

Stored size: 1.38 KB

Contents

require 'semantic_puppet/dependency'

module SemanticPuppet
  module Dependency
    class ModuleRelease
      include GraphNode

      attr_reader :name, :version

      # Create a new instance of a module release.
      #
      # @param source [SemanticPuppet::Dependency::Source]
      # @param name [String]
      # @param version [SemanticPuppet::Version]
      # @param dependencies [{String => SemanticPuppet::VersionRange}]
      def initialize(source, name, version, dependencies = {})
        @source      = source
        @name        = name.freeze
        @version     = version.freeze

        dependencies.each do |name, range|
          add_constraint('initialize', name, range.to_s) do |node|
            range === node.version
          end

          add_dependency(name)
        end
      end

      def priority
        @source.priority
      end

      def <=>(oth)
        our_key   = [ priority, name, version ]
        their_key = [ oth.priority, oth.name, oth.version ]

        return our_key <=> their_key
      end

      def eql?(other)
        other.is_a?(ModuleRelease) &&
          @name.eql?(other.name) &&
          @version.eql?(other.version) &&
          dependencies.eql?(other.dependencies)
      end
      alias == eql?

      def hash
        @name.hash ^ @version.hash
      end

      def to_s
        "#<#{self.class} #{name}@#{version}>"
      end
    end
  end
end

Version data entries

225 entries across 225 versions & 4 rubygems

Version Path
semantic_puppet-1.1.1 lib/semantic_puppet/dependency/module_release.rb
semantic_puppet-1.1.0 lib/semantic_puppet/dependency/module_release.rb
semantic_puppet-1.0.4 lib/semantic_puppet/dependency/module_release.rb
semantic_puppet-1.0.3 lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.22 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.22-x86-mingw32 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.22-x64-mingw32 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.22-universal-darwin lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.21 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.21-x86-mingw32 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.21-x64-mingw32 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.21-universal-darwin lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.20 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.20-x86-mingw32 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.20-x64-mingw32 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.20-universal-darwin lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.19 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.19-x86-mingw32 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.19-x64-mingw32 lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb
puppet-5.5.19-universal-darwin lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb