Class: Sprout::Generator::DirectoryManifest

Inherits:
Manifest
  • Object
show all
Defined in:
sprout/lib/sprout/generator/directory_manifest.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Manifest

#say

Constructor Details

- (DirectoryManifest) initialize

A new instance of DirectoryManifest



6
7
8
9
10
# File 'sprout/lib/sprout/generator/directory_manifest.rb', line 6

def initialize
  super
  @children = []
  @generators = []
end

Instance Attribute Details

- (Object) children (readonly)

Returns the value of attribute children



3
4
5
# File 'sprout/lib/sprout/generator/directory_manifest.rb', line 3

def children
  @children
end

- (Object) generators (readonly)

Returns the value of attribute generators



4
5
6
# File 'sprout/lib/sprout/generator/directory_manifest.rb', line 4

def generators
  @generators
end

Instance Method Details

- (Object) create



12
13
14
15
16
17
18
19
20
21
# File 'sprout/lib/sprout/generator/directory_manifest.rb', line 12

def create
  if !File.directory?(path)
    FileUtils.mkdir_p path
      say "Created directory: #{path}"
  else
      say "Skipped directory: #{path}" unless(path == Dir.pwd)
  end
  create_children
  execute_generators
end

- (Object) destroy



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'sprout/lib/sprout/generator/directory_manifest.rb', line 23

def destroy
  unexecute_generators
  success = destroy_children

  if success && can_remove?
    FileUtils.rmdir path
    say "Removed directory:           #{path}"
    true
  else
    say "Skipped remove directory:    #{path}"
    false
  end
end