Class: Lemans::Config::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/lemans/config/setup.rb

Overview

One phase's preparation: the files uploaded into the sandbox and the commands run against them. A bare list is shorthand for commands only.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSetup

Returns a new instance of Setup.



28
29
30
31
# File 'lib/lemans/config/setup.rb', line 28

def initialize
  @files = []
  @commands = []
end

Instance Attribute Details

#commandsObject

Files are [local absolute, remote relative] pairs; commands run in order.



26
27
28
# File 'lib/lemans/config/setup.rb', line 26

def commands
  @commands
end

#filesObject

Files are [local absolute, remote relative] pairs; commands run in order.



26
27
28
# File 'lib/lemans/config/setup.rb', line 26

def files
  @files
end

Class Method Details

.from_config(data, root:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lemans/config/setup.rb', line 9

def from_config(data, root:)
  return if data.nil?

  conf = new
  case data
  when Hash
    conf.commands = Array(data["commands"])
    conf.files = Array(data["files"]).map { [ root.join(it), it ] }
  else
    conf.commands = Array(data)
  end

  conf
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


40
# File 'lib/lemans/config/setup.rb', line 40

def empty? = files.empty? && commands.empty?

#merge(other) ⇒ Object



33
34
35
36
37
38
# File 'lib/lemans/config/setup.rb', line 33

def merge(other)
  dup.tap do |merged|
    merged.files = files + other.files
    merged.commands = commands + other.commands
  end
end