Sha256: f797715eb55caa9c7b29f9d6948df10d1505fa1bdfb802c0c7ce2bfad1f15c6e

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

module Minimart
  module InventoryRequirement

    # A requirement to a cookbook found in the local file system
    class LocalPathRequirement < BaseRequirement

      # @return [String] the path to the cookbook
      attr_reader :path

      # @param [String] name The name of the cookbook
      # @param [Hash] opts
      # @option opts [String] path The path to the cookbook
      def initialize(name, opts)
        super
        @path = opts[:path]
      end

      # Local path requirements explicitly define their location, so this method will return true.
      # @return [Boolean] TRUE
      def explicit_location?
        true
      end

      # Convert this requirement to a hash
      # @return [Hash]
      def to_hash
        result = super
        result[:path] = @path
        result[:source_type] = :local_path
        result
      end

      def matching_source?(metadata)
        if metadata.has_key?('metadata_version') && metadata['metadata_version'] == '2.0'
          metadata['source_type'] == 'local_path' &&
            metadata['path'] == @path
        else
          metadata['source_type'] == 'local_path'
        end
      end

      private

      def download_cookbook(&block)
        Configuration.output.puts "-- Fetching '#{name}' from path '#{path}'"
        block.call(Minimart::Cookbook.from_path(path))
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
minimart-1.2.5 lib/minimart/inventory_requirement/local_path_requirement.rb
minimart-1.2.4 lib/minimart/inventory_requirement/local_path_requirement.rb
minimart-1.2.3 lib/minimart/inventory_requirement/local_path_requirement.rb
minimart-1.2.0 lib/minimart/inventory_requirement/local_path_requirement.rb