Sha256: 4af28854960d4657ad77f66ac70a568d92b88efee5c1e1eaff53fee2532b0b67

Contents?: true

Size: 1.54 KB

Versions: 9

Compression:

Stored size: 1.54 KB

Contents

module Ridley
  # @author Jamie Winsor <jamie@vialstudios.com>
  class Cookbook    
    include Ridley::Resource

    class << self
      # Save a new Cookbook Version of the given name, version with the
      # given manifest of files and checksums.
      #
      # @param [Ridley::Connection] connection
      # @param [String] name
      # @param [String] version
      # @param [String] manifest
      #   a JSON blob containing file names, file paths, and checksums for each
      #   that describe the cookbook version being uploaded.
      #
      # @option options [Boolean] :freeze
      # @option options [Boolean] :force
      #
      # @return [Hash]
      def save(connection, name, version, manifest, options = {})
        freeze = options.fetch(:freeze, false)
        force  = options.fetch(:force, false)

        url = "cookbooks/#{name}/#{version}"
        url << "?force=true" if force

        connection.put(url, manifest)
      end
    end

    set_chef_id "name"
    set_chef_type "cookbook"
    set_chef_json_class "Chef::Cookbook"
    set_resource_path "cookbooks"

    attribute :name
    validates_presence_of :name
  end

  module DSL
    # Coerces instance functions into class functions on Ridley::Cookbook. This coercion
    # sends an instance of the including class along to the class function.
    #
    # @see Ridley::ChainLink
    #
    # @return [Ridley::ChainLink]
    #   a context object to delegate instance functions to class functions on Ridley::Cookbook
    def cookbook
      ChainLink.new(self, Ridley::Cookbook)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ridley-0.6.3 lib/ridley/resources/cookbook.rb
ridley-0.6.2 lib/ridley/resources/cookbook.rb
ridley-0.6.1 lib/ridley/resources/cookbook.rb
ridley-0.6.0 lib/ridley/resources/cookbook.rb
ridley-0.5.2 lib/ridley/resources/cookbook.rb
ridley-0.5.1 lib/ridley/resources/cookbook.rb
ridley-0.5.0 lib/ridley/resources/cookbook.rb
ridley-0.4.1 lib/ridley/resources/cookbook.rb
ridley-0.4.0 lib/ridley/resources/cookbook.rb