Class: Awestruct::CLI::Manifest

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

Overview

noinspection RubyResolve

Defined Under Namespace

Classes: AddRequires, CopyFile, InstallCompass, MkDir, RemoveFile, TemplateFile, TouchFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Manifest.



18
19
20
21
22
# File 'lib/awestruct/cli/manifest.rb', line 18

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.



15
16
17
# File 'lib/awestruct/cli/manifest.rb', line 15

def parent
  @parent
end

#stepsObject (readonly)

Returns the value of attribute steps.



16
17
18
# File 'lib/awestruct/cli/manifest.rb', line 16

def steps
  @steps
end

Instance Method Details

#add_requires(path, libs = []) ⇒ Object



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

def add_requires(path, libs = [])
  steps << AddRequires.new(path, libs)
end

#copy_file(path, input_path, opts = {}) ⇒ Object



32
33
34
# File 'lib/awestruct/cli/manifest.rb', line 32

def copy_file(path, input_path, opts = {})
  steps << CopyFile.new(path, input_path, opts)
end

#install_compass(framework) ⇒ Object



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

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

#mkdir(path) ⇒ Object



24
25
26
# File 'lib/awestruct/cli/manifest.rb', line 24

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

#perform(dir) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/awestruct/cli/manifest.rb', line 52

def perform(dir)
  parent.perform(dir) if parent
  begin
    steps.each do |step|
      step.perform(dir)
    end
    true
  rescue => e
    ExceptionHelper.log_error e
    ExceptionHelper.log_backtrace e
    false
  end
end

#remove_file(path) ⇒ Object



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

def remove_file(path)
  steps << RemoveFile.new(path)
end

#template_file(path, input_path, state = {}) ⇒ Object



28
29
30
# File 'lib/awestruct/cli/manifest.rb', line 28

def template_file(path, input_path, state = {})
  steps << TemplateFile.new(path, input_path, state.merge(load_gem))
end

#touch_file(path) ⇒ Object



36
37
38
# File 'lib/awestruct/cli/manifest.rb', line 36

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

#unperform(dir) ⇒ Object



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

def unperform(dir)
  steps.each do |step|
    begin
      step.unperform(dir)
      true
    rescue => e
      ExceptionHelper.log_error e
      ExceptionHelper.log_backtrace e
    end
  end
end