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.



44
45
46
47
48
# File 'lib/awestruct/cli/manifest.rb', line 44

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.



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

def parent
  @parent
end

#stepsObject (readonly)

Returns the value of attribute steps.



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

def steps
  @steps
end

Instance Method Details

#copy_file(path, input_path) ⇒ Object



54
55
56
# File 'lib/awestruct/cli/manifest.rb', line 54

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

#install_compass(framework) ⇒ Object



62
63
64
# File 'lib/awestruct/cli/manifest.rb', line 62

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

#mkdir(path) ⇒ Object



50
51
52
# File 'lib/awestruct/cli/manifest.rb', line 50

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

#perform(dir) ⇒ Object



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

def perform(dir)
  parent.perform(dir) if parent
  steps.each do |step|
    begin
      step.perform( dir )
    rescue => e
      $LOG.error e if $LOG.error?
      $LOG.error e.backtrace.join("\n") if $LOG.error?
    end
  end
end

#touch_file(path) ⇒ Object



58
59
60
# File 'lib/awestruct/cli/manifest.rb', line 58

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

#unperform(dir) ⇒ Object



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

def unperform(dir)
  steps.each do |step|
    begin
      step.unperform( dir )
    rescue => e
      $LOG.error e if $LOG.error?
      $LOG.error e.backtrace.join("\n") if $LOG.error?
    end
  end
end