Class: ForemanDebian::Command::Install

Inherits:
ForemanDebian::Command show all
Defined in:
lib/foreman_debian/command/install.rb

Instance Method Summary collapse

Methods inherited from ForemanDebian::Command

#get_engine

Instance Method Details

#decode_concurrency(concurrency_encoded) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/foreman_debian/command/install.rb', line 51

def decode_concurrency(concurrency_encoded)
  concurrency_hash = {}
  concurrency_encoded.split(',').each do |entry|
    parts = entry.split('=')
    raise 'Invalid concurrency option' unless parts.size == 2
    name, concurrency = parts
    concurrency_hash[name] = concurrency.to_i
  end
  concurrency_hash
end

#dir_rootPathname

Returns:

  • (Pathname)


47
48
49
# File 'lib/foreman_debian/command/install.rb', line 47

def dir_root
  Pathname.new(working_dir)
end

#executeObject



19
20
21
22
23
24
25
26
# File 'lib/foreman_debian/command/install.rb', line 19

def execute
  jobs = {}
  procfile.entries do |name, command|
    jobs[name] = expand_procfile_command(command)
  end
  concurrency = decode_concurrency(concurrency_encoded)
  get_engine.install(jobs, concurrency, user)
end

#expand_procfile_command(command) ⇒ Object



28
29
30
31
32
# File 'lib/foreman_debian/command/install.rb', line 28

def expand_procfile_command(command)
  args = Shellwords.split(command)
  args[0] = Pathname.new(args[0]).expand_path(dir_root).to_s
  Shellwords.join(args)
end

#procfileForeman::Procfile

Returns:

  • (Foreman::Procfile)


41
42
43
44
# File 'lib/foreman_debian/command/install.rb', line 41

def procfile
  raise "Procfile `#{procfile_path.to_s}` does not exist" unless procfile_path.file?
  Foreman::Procfile.new(procfile_path)
end

#procfile_pathPathname

Returns:

  • (Pathname)


35
36
37
38
# File 'lib/foreman_debian/command/install.rb', line 35

def procfile_path
  path_relative = procfile_path_relative || "#{working_dir}/Procfile"
  Pathname.new(path_relative).expand_path(Dir.getwd)
end