Class: CapistranoMulticonfigParallel::BundlerTerminalTable

Inherits:
TerminalTable
  • Object
show all
Defined in:
lib/capistrano_multiconfig_parallel/celluloid/bundler_terminal_table.rb

Instance Attribute Summary

Attributes inherited from TerminalTable

#errors, #job_manager, #manager, #options, #position, #screen_erased, #terminal_rows

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TerminalTable

#display_table_on_terminal, #initialize, #managers_alive?, #notify_time_change, #print_errors, #rescue_exception, #show_confirmation, #signal_complete

Methods included from BaseActorHelper

included

Constructor Details

This class inherits a constructor from CapistranoMulticonfigParallel::TerminalTable

Class Method Details

.topicObject



4
5
6
# File 'lib/capistrano_multiconfig_parallel/celluloid/bundler_terminal_table.rb', line 4

def self.topic
  'bundler_terminal'
end

Instance Method Details

#default_heaadingsObject



8
9
10
# File 'lib/capistrano_multiconfig_parallel/celluloid/bundler_terminal_table.rb', line 8

def default_heaadings
  ['Job UUID', 'App', 'Action', 'Current Status']
end

#fetch_table_size(jobs) ⇒ Object



22
23
24
25
# File 'lib/capistrano_multiconfig_parallel/celluloid/bundler_terminal_table.rb', line 22

def fetch_table_size(jobs)
  job_rows = jobs.sum { |job, _bundler_worker| job.row_size }
  (job_rows + 2)**2
end

#notify_bundler_install_status(_channel, _message) ⇒ Object



16
17
18
19
20
# File 'lib/capistrano_multiconfig_parallel/celluloid/bundler_terminal_table.rb', line 16

def notify_bundler_install_status(_channel, _message)
  table = Terminal::Table.new(title: 'Bundler Check Status Table', headings: default_heaadings)
  jobs = setup_table_jobs(table)
  display_table_on_terminal(table, jobs)
end

#runObject



12
13
14
# File 'lib/capistrano_multiconfig_parallel/celluloid/bundler_terminal_table.rb', line 12

def run
  subscribe(CapistranoMulticonfigParallel::BundlerTerminalTable.topic, :notify_bundler_install_status)
end

#setup_table_jobs(table) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/capistrano_multiconfig_parallel/celluloid/bundler_terminal_table.rb', line 28

def setup_table_jobs(table)
  jobs = managers_alive? ? @job_manager.bundler_workers_store.dup : []
  jobs.each do |job, bundler_worker|
    table.add_row(job.bundler_check_terminal_row)
    table.add_separator if jobs.keys.last != job
  end
  jobs
end