Class: Dapp::Dimg::Config::Directive::Chef

Inherits:
Base show all
Defined in:
lib/dapp/dimg/config/directive/chef.rb

Defined Under Namespace

Classes: Attributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#clone_to_artifact

Methods inherited from Config::Directive::Base

#clone

Constructor Details

#initialize(**kwargs, &blk) ⇒ Chef

Returns a new instance of Chef.



8
9
10
11
12
13
14
# File 'lib/dapp/dimg/config/directive/chef.rb', line 8

def initialize(**kwargs, &blk)
  @_dimod = []
  @_recipe = []
  @_cookbook = {}

  super(**kwargs, &blk)
end

Instance Attribute Details

#_attributesObject

Returns the value of attribute _attributes.



6
7
8
# File 'lib/dapp/dimg/config/directive/chef.rb', line 6

def _attributes
  @_attributes
end

#_cookbookObject

Returns the value of attribute _cookbook.



6
7
8
# File 'lib/dapp/dimg/config/directive/chef.rb', line 6

def _cookbook
  @_cookbook
end

#_dimodObject

Returns the value of attribute _dimod.



6
7
8
# File 'lib/dapp/dimg/config/directive/chef.rb', line 6

def _dimod
  @_dimod
end

#_recipeObject

Returns the value of attribute _recipe.



6
7
8
# File 'lib/dapp/dimg/config/directive/chef.rb', line 6

def _recipe
  @_recipe
end

Instance Method Details

#attributesObject



27
28
29
# File 'lib/dapp/dimg/config/directive/chef.rb', line 27

def attributes
  @_attributes ||= Attributes.new
end

#cookbook(name, version_constraint = nil, **kwargs) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/dapp/dimg/config/directive/chef.rb', line 31

def cookbook(name, version_constraint = nil, **kwargs)
  sub_directive_eval do
    @_cookbook[name] = {}.tap do |desc|
      desc.update(kwargs)
      desc[:name] = name
      desc[:version_constraint] = version_constraint if version_constraint
      desc[:path] = File.expand_path(desc[:path], dapp.path) if desc.key? :path
    end
  end
end

#dimod(name, *args) ⇒ Object



16
17
18
19
20
21
# File 'lib/dapp/dimg/config/directive/chef.rb', line 16

def dimod(name, *args)
  sub_directive_eval do
    @_dimod << name
    cookbook(name, *args)
  end
end

#empty?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/dapp/dimg/config/directive/chef.rb', line 63

def empty?
  (@_dimod + @_recipe).empty? && attributes.empty?
end

#recipe(name) ⇒ Object



23
24
25
# File 'lib/dapp/dimg/config/directive/chef.rb', line 23

def recipe(name)
  sub_directive_eval { @_recipe << name }
end