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.



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

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.



12
13
14
# File 'lib/awestruct/cli/manifest.rb', line 12

def parent
  @parent
end

#stepsObject (readonly)

Returns the value of attribute steps.



13
14
15
# File 'lib/awestruct/cli/manifest.rb', line 13

def steps
  @steps
end

Instance Method Details

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



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

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

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



30
31
32
# File 'lib/awestruct/cli/manifest.rb', line 30

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

#install_compass(framework, lib) ⇒ Object



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

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

#mkdir(path) ⇒ Object



21
22
23
# File 'lib/awestruct/cli/manifest.rb', line 21

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

#perform(dir) ⇒ Object



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

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



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

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

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



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

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

#touch_file(path) ⇒ Object



34
35
36
# File 'lib/awestruct/cli/manifest.rb', line 34

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

#unperform(dir) ⇒ Object



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

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