class GithubTable

Public Class Methods

new(github_account:, application_branches:) click to toggle source
# File lib/deploy_nanny/github_table.rb, line 5
def initialize(github_account:, application_branches:)
  @github_commits = []
  application_branches.each do |application, branch|
    @github_commits << GithubCommit.new(application, branch, github_account)
  end

  render
end

Public Instance Methods

build_rows() click to toggle source
# File lib/deploy_nanny/github_table.rb, line 31
def build_rows
  rows = []
  @github_commits.each do |gc|
    rows << [gc.application.yellow, gc.branch.magenta, gc.sha.green]
  end
  rows
end
fetch_all() click to toggle source
# File lib/deploy_nanny/github_table.rb, line 23
def fetch_all
  threads = []
  @github_commits.each do |github_commit|
    threads << Thread.new {github_commit.fetch_sha; render}
  end
  threads.map(&:join)
end
match(application, sha) click to toggle source
# File lib/deploy_nanny/github_table.rb, line 14
def match(application, sha)
  @github_commits.each do |gc|
    if gc.application == application && gc.sha == sha
      return true
    end
  end
  false
end
print_title() click to toggle source
render() click to toggle source
# File lib/deploy_nanny/github_table.rb, line 39
def render
  print_title
  puts Terminal::Table.new(
    :title => "Latest github commits",
    :headings => ['app', 'branch', 'sha'],
    :rows => build_rows
  )
end