Sha256: 0b02b6b6f8d7877bf424d13d093c64f2df73379998f56ed0b2529e0f4f02eea2

Contents?: true

Size: 917 Bytes

Versions: 1

Compression:

Stored size: 917 Bytes

Contents

module Berkshelf
  module DSL
    @@active_group = nil

    def cookbook(*args)
      source = CookbookSource.new(*args)
      source.add_group(@@active_group) if @@active_group
      add_source(source)
    end

    def group(*args)
      @@active_group = args
      yield
      @@active_group = nil
    end

    def metadata(options = {})
      path = options[:path] || File.expand_path('.')

      metadata_file = Berkshelf.find_metadata(path)

      unless metadata_file
        raise CookbookNotFound, "No 'metadata.rb' found at #{path}"
      end

      metadata = Chef::Cookbook::Metadata.new
      metadata.from_file(metadata_file.to_s)

      name = if metadata.name.empty? || metadata.name.nil?
        File.basename(File.dirname(metadata_file))
      else
        metadata.name
      end

      source = CookbookSource.new(name, path: File.dirname(metadata_file))
      add_source(source)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
berkshelf-0.4.0.rc1 lib/berkshelf/dsl.rb