Class: Dapp::Dimg::Builder::Chef::Berksfile
- Inherits:
-
Object
- Object
- Dapp::Dimg::Builder::Chef::Berksfile
show all
- Defined in:
- lib/dapp/dimg/builder/chef/berksfile.rb
Defined Under Namespace
Classes: Builder, FromConfBuilder, FromFileBuilder
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(cookbook_path) ⇒ Berksfile
Returns a new instance of Berksfile.
8
9
10
11
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 8
def initialize(cookbook_path)
@cookbook_path = Pathname.new(cookbook_path)
@local_cookbooks = {}
end
|
Instance Attribute Details
#builder ⇒ Object
Returns the value of attribute builder.
4
5
6
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 4
def builder
@builder
end
|
#cookbook_path ⇒ Object
Returns the value of attribute cookbook_path.
5
6
7
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 5
def cookbook_path
@cookbook_path
end
|
#local_cookbooks ⇒ Object
Returns the value of attribute local_cookbooks.
6
7
8
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 6
def local_cookbooks
@local_cookbooks
end
|
Class Method Details
.from_conf(cookbook_path:, cookbooks:) ⇒ Object
50
51
52
53
54
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 50
def from_conf(cookbook_path:, cookbooks:)
new(cookbook_path).tap do |berksfile|
berksfile.builder = FromConfBuilder.new(berksfile, cookbooks)
end
end
|
.from_file(cookbook_path:, berksfile_file_path:) ⇒ Object
44
45
46
47
48
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 44
def from_file(cookbook_path:, berksfile_file_path:)
new(cookbook_path).tap do |berksfile|
berksfile.builder = FromFileBuilder.new(berksfile, berksfile_file_path)
end
end
|
Instance Method Details
#add_local_cookbook_path(name, path) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 17
def add_local_cookbook_path(name, path)
raise(Error::Chef, code: :berksfile_absolute_path_forbidden, data: {cookbook: name, path: path}) if path.start_with? '/'
desc = {
name: name,
path: cookbook_path.join(path),
chefignore: []
}
if desc[:path].join('chefignore').exist?
chefignore_patterns = desc[:path].join('chefignore').read.split("\n").map(&:strip)
desc[:chefignore] = Dir[*chefignore_patterns.map {|pattern| desc[:path].join(pattern)}]
.map(&Pathname.method(:new))
end
@local_cookbooks[name] = desc
end
|
#dump ⇒ Object
13
14
15
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 13
def dump
builder.send(:dump) end
|
#local_cookbook(name) ⇒ Object
39
40
41
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 39
def local_cookbook(name)
local_cookbooks[name]
end
|
#local_cookbook?(name) ⇒ Boolean
35
36
37
|
# File 'lib/dapp/dimg/builder/chef/berksfile.rb', line 35
def local_cookbook?(name)
local_cookbooks.key? name
end
|