Sha256: 26456f72f111d300a29bb0b23eba69c81d0d7e5f343e3c2dffebadc0f2704a7f

Contents?: true

Size: 1.34 KB

Versions: 36

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'semantic_puppet'
require 'bolt/module_installer/puppetfile/module'

# This class represents a resolved Forge module.
#
module Bolt
  class ModuleInstaller
    class Puppetfile
      class ForgeModule < Module
        attr_reader :version

        def initialize(name, version)
          super(name)
          @version = parse_version(version)
          @type    = :forge
        end

        # Parses the version into a Semantic Puppet version.
        #
        private def parse_version(version)
          return unless version.is_a?(String)

          unless SemanticPuppet::Version.valid?(version)
            raise Bolt::ValidationError,
                  "Invalid version for Forge module #{@full_name}: #{version.inspect}"
          end

          SemanticPuppet::Version.parse(version)
        end

        # Returns a Puppetfile module specification.
        #
        def to_spec
          if @version
            "mod '#{@full_name}', '#{@version}'"
          else
            "mod '#{@full_name}'"
          end
        end

        # Returns a hash that can be used to create a module specification.
        #
        def to_hash
          {
            'name'                => @full_name,
            'version_requirement' => @version ? @version.to_s : nil
          }.compact
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
bolt-3.17.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.16.1 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.16.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.15.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.14.1 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.13.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.12.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.11.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.10.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.9.2 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.9.1 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.9.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.8.1 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.8.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.7.1 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.7.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.6.1 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.6.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.5.0 lib/bolt/module_installer/puppetfile/forge_module.rb
bolt-3.4.0 lib/bolt/module_installer/puppetfile/forge_module.rb