Class: CHBuild::Config::Before

Inherits:
Array
  • Object
show all
Defined in:
lib/chbuild/config/before.rb

Overview

Before section

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(before_commands) ⇒ Before

before_commands is required so no default value



7
8
9
10
11
# File 'lib/chbuild/config/before.rb', line 7

def initialize(before_commands)
  super([])
  validate!(before_commands)
  replace(before_commands) unless before_commands.nil?
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



19
20
21
# File 'lib/chbuild/config/before.rb', line 19

def errors
  @errors
end

Instance Method Details

#nameObject



21
22
23
# File 'lib/chbuild/config/before.rb', line 21

def name
  "Section 'before'"
end

#to_bash_scriptObject



25
26
27
# File 'lib/chbuild/config/before.rb', line 25

def to_bash_script
  reduce('') { |a, e| a + "#{e}\n" }
end

#validate!(before_commands) ⇒ Object



13
14
15
16
17
# File 'lib/chbuild/config/before.rb', line 13

def validate!(before_commands)
  @errors = []
  @errors << 'Required' if before_commands.nil?
  @errors << 'Cannot be empty' if before_commands == []
end