Class: Cupper::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/cupper/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_name, directory = nil) ⇒ Project

Returns a new instance of Project.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cupper/project.rb', line 18

def initialize(project_name, directory = nil)
  @name = project_name
  @dir = directory.nil? ? Dir.getwd : directory
  @subdirs = [
    'cookbooks'
  ]
  @files = [
    'Cupperfile',
  ]
  # TODO: this should not be separated from the others
  #   files. Try to get them together.
  @hidden = [
    'sensibles'
  ]
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



16
17
18
# File 'lib/cupper/project.rb', line 16

def dir
  @dir
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/cupper/project.rb', line 15

def name
  @name
end

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cupper/project.rb', line 34

def create
  # Root project directory
  struct = Structure.new(@name, @dir, nil, Entity::DIR)
  struct.create

  @subdirs.zip(@files).each do |dir, file|
    Structure.new(dir, "#{@dir}/#{@name}", nil, Entity::DIR).create
    Structure.new(file, "#{@dir}/#{@name}", file).create
  end

  @hidden.each do |file|
    Structure.new(".#{file}", "#{@dir}/#{@name}", file).create
  end
end