Class: Dapp::Dimg::Builder::Chef::Berksfile::FromConfBuilder

Inherits:
Builder
  • Object
show all
Defined in:
lib/dapp/dimg/builder/chef/berksfile.rb

Overview

Builder

Instance Method Summary collapse

Methods inherited from Builder

#cookbook, #method_missing

Constructor Details

#initialize(berksfile, cookbooks) ⇒ FromConfBuilder

Returns a new instance of FromConfBuilder.



85
86
87
88
89
90
91
92
93
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 85

def initialize(berksfile, cookbooks)
  super(berksfile)

  @cookbooks = cookbooks

  @cookbooks.each do |name, desc|
    cookbook(name, desc[:version_constraint], **desc)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dapp::Dimg::Builder::Chef::Berksfile::Builder

Instance Method Details

#dumpObject



95
96
97
98
99
100
101
102
103
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 95

def dump
  [].tap do |lines|
    lines << "source 'https://supermarket.chef.io'\n\n "
    @cookbooks.each do |name, desc|
      params = desc.reject {|key, _value| [:name, :version_constraint].include? key}
      lines << "cookbook #{name.inspect}, #{desc[:version_constraint].inspect}, #{params.inspect}\n"
    end
  end.join
end