Class: Michael::Commands::Repos::PullRequests

Inherits:
Models::Guard show all
Defined in:
lib/michael/commands/repos/pull_requests.rb

Instance Attribute Summary

Attributes inherited from Models::Guard

#config, #repos_config

Instance Method Summary collapse

Methods inherited from Michael::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #pastel, #platform, #prompt, #screen, #spinner, #which

Constructor Details

#initialize(options) ⇒ PullRequests

Returns a new instance of PullRequests.



16
17
18
19
20
21
22
23
24
25
# File 'lib/michael/commands/repos/pull_requests.rb', line 16

def initialize(options)
  super()

  @prs = Michael::Models::Github::PullRequest.new
  @user = Michael::Models::Github::User.new
  @repos = repos_config.fetch(:repos)
  abort 'No repositories configured' if @repos.nil? || @repos.empty?

  @options = options
end

Instance Method Details

#execute(out: $stdout) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/michael/commands/repos/pull_requests.rb', line 27

def execute(out: $stdout)
  list = get_repos_with_spinner(out)

  print_good_prs(out, repos_with_prs(list))
  print_repos_w_no_prs(out, repos_no_prs(list)) if options[:show_empty]
  print_broken_repos(out, list.select { |item| item[:state] == :failed })
end