Class: ReleasedCookbook

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

Instance Attribute Summary

Attributes inherited from Cookbook

#cookbooks_url, #mofa_yml, #mofa_yml_local, #name, #pkg_dir, #pkg_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



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

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 Method Details

#cleanupObject



22
23
24
25
26
# File 'lib/mofa/released_cookbook.rb', line 22

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

#cleanup!Object

————- /Interface Methods



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

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



17
18
19
20
# File 'lib/mofa/released_cookbook.rb', line 17

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

#prepareObject

————- Interface Methods



12
13
14
15
# File 'lib/mofa/released_cookbook.rb', line 12

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