Class: Awestruct::CLI::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/cli/manifest.rb

Defined Under Namespace

Classes: CopyFile, InstallCompass, MkDir, TouchFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil, &block) ⇒ Manifest

Returns a new instance of Manifest.



42
43
44
45
46
# File 'lib/awestruct/cli/manifest.rb', line 42

def initialize(parent=nil,&block)
  @parent = parent
  @steps = []
  instance_eval &block if block
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



39
40
41
# File 'lib/awestruct/cli/manifest.rb', line 39

def parent
  @parent
end

#stepsObject (readonly)

Returns the value of attribute steps.



40
41
42
# File 'lib/awestruct/cli/manifest.rb', line 40

def steps
  @steps
end

Instance Method Details

#copy_file(path, input_path) ⇒ Object



52
53
54
# File 'lib/awestruct/cli/manifest.rb', line 52

def copy_file(path, input_path)
  steps << CopyFile.new( path, input_path )
end

#install_compass(framework) ⇒ Object



60
61
62
# File 'lib/awestruct/cli/manifest.rb', line 60

def install_compass(framework)
  steps << InstallCompass.new(framework)
end

#mkdir(path) ⇒ Object



48
49
50
# File 'lib/awestruct/cli/manifest.rb', line 48

def mkdir(path)
  steps << MkDir.new( path )
end

#perform(dir) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/awestruct/cli/manifest.rb', line 64

def perform(dir)
  parent.perform(dir) if parent
  steps.each do |step|
    begin
      step.perform( dir )
    rescue => e
      puts e
      puts e.backtrace
    end
  end
end

#touch_file(path) ⇒ Object



56
57
58
# File 'lib/awestruct/cli/manifest.rb', line 56

def touch_file(path)
  steps << TouchFile.new(path)
end

#unperform(dir) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/awestruct/cli/manifest.rb', line 76

def unperform(dir)
  steps.each do |step|
    begin
      step.unperform( dir )
    rescue => e
      puts e
      puts e.backtrace
    end
  end
end