Module: Octonaut::Printers::Repositories

Included in:
Octonaut::Printer
Defined in:
lib/octonaut/printers/repositories.rb

Constant Summary collapse

REPOSITORY_FIELDS =
{
  "id"             => "ID",
  "name"           => "NAME",
  "full_name"      => "FULL NAME",
  "description"    => "DESCRIPTION",
  "default_branch" => "DEFAULT BRANCH",
  "homepage"       => "HOMEPAGE",
  "language"       => "PRIMARY LANGUAGE",
  "open_issues"    => "OPEN ISSUES",
  "fork"           => "FORK",
  "forks_count"    => "FORKS",
  "watchers"       => "STARS",
  "private"        => "PRIVATE",
  "has_downloads"  => "DOWNLOADS ENABLED",
  "has_issues"     => "ISSUES ENABLED",
  "has_wiki"       => "WIKI ENABLED",
  "created_at"     => "CREATED",
  "pushed_at"      => "LAST PUSH",
  "updated_at"     => "UPDATED"
}

Instance Method Summary collapse

Instance Method Details

#ls_repos(repos, options = {}) ⇒ Object



44
45
46
# File 'lib/octonaut/printers/repositories.rb', line 44

def ls_repos(repos, options = {})
  repos.each {|r| puts r.full_name }
end


39
40
41
42
# File 'lib/octonaut/printers/repositories.rb', line 39

def print_csv_repos(repos, options = {})
  options[:fields] = REPOSITORY_FIELDS
  print_csv repos, options
end


26
27
28
29
30
31
32
33
# File 'lib/octonaut/printers/repositories.rb', line 26

def print_repo_table(repo, options = {})
  data = {}
  REPOSITORY_FIELDS.each do |field, heading|
    data[heading] = repo[field]
  end

  print_table(data)
end


35
36
37
# File 'lib/octonaut/printers/repositories.rb', line 35

def print_repos(repos, options = {})
  options[:csv] ? print_csv_repos(repos) : ls_repos(repos)
end