Class: Kdeploy::CommandGrouper

Inherits:
Object
  • Object
show all
Defined in:
lib/kdeploy/command_grouper.rb

Overview

Groups commands by type and generates task descriptions

Class Method Summary collapse

Class Method Details

.group(commands) ⇒ Object



6
7
8
9
10
# File 'lib/kdeploy/command_grouper.rb', line 6

def self.group(commands)
  commands.group_by do |cmd|
    group_key_for(cmd)
  end
end

.group_key_for(cmd) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/kdeploy/command_grouper.rb', line 12

def self.group_key_for(cmd)
  case cmd[:type]
  when :upload, :upload_template, :sync
    "#{cmd[:type]}_#{cmd[:source]}"
  when :run
    "#{cmd[:type]}_#{cmd[:command].to_s.lines.first.strip}"
  else
    cmd[:type].to_s
  end
end

.task_description(command) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kdeploy/command_grouper.rb', line 23

def self.task_description(command)
  case command[:type]
  when :upload
    "upload #{command[:source]}"
  when :upload_template
    "template #{command[:source]}"
  when :sync
    "sync #{command[:source]}"
  when :run
    command[:command].to_s.lines.first.strip
  else
    command[:type].to_s
  end
end