Sha256: 36aa80835a52e6d2cf4a9031f3cba9ccd7226c1c0f4ea35f3424d3759b8be89d

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 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[:source_type] = :local_path
        result
      end

      def matching_source?(metadata)
        metadata['source_type'] == 'local_path'
      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

5 entries across 5 versions & 1 rubygems

Version Path
minimart-1.1.6 lib/minimart/inventory_requirement/local_path_requirement.rb
minimart-1.1.3 lib/minimart/inventory_requirement/local_path_requirement.rb
minimart-1.0.2 lib/minimart/inventory_requirement/local_path_requirement.rb
minimart-1.0.1 lib/minimart/inventory_requirement/local_path_requirement.rb
minimart-0.0.1 lib/minimart/inventory_requirement/local_path_requirement.rb