Sha256: c0d50821d10cc91d65d2f5c5e9d4f172c5cff5ee7de046c384bd53ba0d5a9540

Contents?: true

Size: 1.54 KB

Versions: 11

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::Context
    #
    # @return [Ridley::Context]
    #   a context object to delegate instance functions to class functions on Ridley::Cookbook
    def cookbook
      Context.new(Ridley::Cookbook, self)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ridley-0.3.2 lib/ridley/resources/cookbook.rb
ridley-0.3.1 lib/ridley/resources/cookbook.rb
ridley-0.3.0 lib/ridley/resources/cookbook.rb
ridley-0.2.2 lib/ridley/resources/cookbook.rb
ridley-0.2.1 lib/ridley/resources/cookbook.rb
ridley-0.2.0 lib/ridley/resources/cookbook.rb
ridley-0.1.0 lib/ridley/resources/cookbook.rb
ridley-0.0.6 lib/ridley/resources/cookbook.rb
ridley-0.0.5 lib/ridley/resources/cookbook.rb
ridley-0.0.4 lib/ridley/resources/cookbook.rb
ridley-0.0.3 lib/ridley/resources/cookbook.rb