Module: Builderator::Util::Cookbook

Defined in:
lib/builderator/util/cookbook.rb

Defined Under Namespace

Classes: Metadata

Constant Summary collapse

DEFAULT_VENDOR =
Util.working_dir('vendor/chef/cookbooks')
EXCLUDED_VCS_FILES =
[
'.arch-ids', '{arch}', '.bzr', '.bzrignore', '.bzrtags',
'CVS', '.cvsignore', '_darcs', '.git', '.hg', '.hgignore',
'.hgrags', 'RCS', 'SCCS', '.svn', '**/.git', '.temp'].freeze

Class Method Summary collapse

Class Method Details

.archive_path(metadata, file) ⇒ Object



63
64
65
# File 'lib/builderator/util/cookbook.rb', line 63

def archive_path(, file)
  Pathname.new(.name).join(Pathname.new(file).relative_path_from(path))
end

.berksfileObject



67
68
69
# File 'lib/builderator/util/cookbook.rb', line 67

def berksfile
  path.join('Berksfile')
end

.metadataObject



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/builderator/util/cookbook.rb', line 71

def 
  Metadata.new.tap do |c|
    if path.join('metadata.rb').exist?
      c.from_file(path.join('metadata.rb').to_s)

    elsif path.join('metadata.json').exist?
      c.from_json(path.join('metadata.json').read)

    else
      fail IOError, 'Unable to read metadata.rb or metadata.json!'
    end
  end
end

.path(arg = nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/builderator/util/cookbook.rb', line 52

def path(arg = nil)
  ## Set an explicit path to a cookbook
  return @path = Pathname.new(arg) unless arg.nil?
  return @path unless @path.nil?

  ## Check for an embedded cookbook? ('./cookbook')
  return @path = Util.working_dir('cookbook') if Util.working_dir('cookbook').exist?

  @path = Util.working_dir
end