Class: Tinychef::NewDirectory

Inherits:
Object
  • Object
show all
Defined in:
lib/tinychef/new_directory.rb

Constant Summary collapse

DIR_MAP =
{
  'cookbooks' => nil,
  'data_bags' => nil,
  'imported_cookbooks' => nil,
  'nodes' => nil,
  'roles' => nil,
  'vendor' => nil,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ NewDirectory

Returns a new instance of NewDirectory.



18
19
20
# File 'lib/tinychef/new_directory.rb', line 18

def initialize(name)
  @path = Pathname.new(name)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



16
17
18
# File 'lib/tinychef/new_directory.rb', line 16

def path
  @path
end

Instance Method Details

#copy_solo_fileObject



32
33
34
35
# File 'lib/tinychef/new_directory.rb', line 32

def copy_solo_file
  solo_file = Pathname.new(File.join(File.expand_path('../../../files', __FILE__), 'solo.rb'))
  FileUtils.cp solo_file, path.join('solo.rb')
end

#createObject



22
23
24
25
26
27
28
29
30
# File 'lib/tinychef/new_directory.rb', line 22

def create
  path.mkpath unless path.exist?

  DIR_MAP.each do |key, value|
    path.join(key).mkpath
  end

  copy_solo_file
end