Class: ReleasedCookbook

Inherits:
Cookbook show all
Defined in:
lib/mofa/released_cookbook.rb

Instance Attribute Summary collapse

Attributes inherited from Cookbook

#cookbooks_url, #name, #pkg_uri, #source_uri, #token, #type, #version

Instance Method Summary collapse

Methods inherited from Cookbook

#autodetect_type, create, #error, #ok, #run, #say

Constructor Details

#initialize(cookbook_name_or_path) ⇒ ReleasedCookbook

Returns a new instance of ReleasedCookbook.



5
6
7
8
9
10
# File 'lib/mofa/released_cookbook.rb', line 5

def initialize(cookbook_name_or_path)
  super()
  # TODO: this needs proper vaidation!
  @name = cookbook_name_or_path.split(/:/).first
  @version = cookbook_name_or_path.split(/:/).last
end

Instance Attribute Details

#pkg_dirObject

Returns the value of attribute pkg_dir.



2
3
4
# File 'lib/mofa/released_cookbook.rb', line 2

def pkg_dir
  @pkg_dir
end

#pkg_nameObject

Returns the value of attribute pkg_name.



3
4
5
# File 'lib/mofa/released_cookbook.rb', line 3

def pkg_name
  @pkg_name
end

Instance Method Details

#cleanupObject



24
25
26
27
28
# File 'lib/mofa/released_cookbook.rb', line 24

def cleanup
  say "Removing folder #{pkg_dir}...#{nl}"
  run "rm -r #{pkg_dir}"
  ok
end

#cleanup!Object

————- /Interface Methods



32
33
34
35
36
37
38
39
# File 'lib/mofa/released_cookbook.rb', line 32

def cleanup!
  unless (Dir.entries("#{Mofa::Config.config['tmp_dir']}/.mofa") - %w{ . .. }).empty?
    say "Removing content of folder #{Mofa::Config.config['tmp_dir']}/.mofa"
    run "rm -r #{Mofa::Config.config['tmp_dir']}/.mofa/*"
  else
    say "Folder #{Mofa::Config.config['tmp_dir']}/.mofa is (already) clean."
  end
end

#executeObject



19
20
21
22
# File 'lib/mofa/released_cookbook.rb', line 19

def execute
  # TODO: Download & unpack released cookbook
  # Important for guessing role runlists (when cookbook is an env-cookbook)
end

#prepareObject

————- Interface Methods



14
15
16
17
# File 'lib/mofa/released_cookbook.rb', line 14

def prepare
  @pkg_name = "#{name}-#{version}.tar.gz"
  @pkg_dir = "#{Mofa::Config.config['tmp_dir']}/.mofa/#{token}"
end