lib/neetob/cli/github/issues/list.rb in neetob-0.2.2 vs lib/neetob/cli/github/issues/list.rb in neetob-0.2.3

- old
+ new

@@ -10,32 +10,32 @@ module Github module Issues class List < Base include ActionView::Helpers::DateHelper - attr_accessor :apps, :issue_state, :issue_assignee, :issue_search_query, :show_issues_count, :issue_label, + attr_accessor :repos, :issue_state, :issue_assignee, :issue_search_query, :show_issues_count, :issue_label, :sandbox - def initialize(apps, issue_assignee = "", issue_state = "open", + def initialize(repos, issue_assignee = "", issue_state = "open", issue_search_query = "", show_issues_count = false, issue_label = "", sandbox = false) super() - @apps = apps + @repos = repos @issue_state = issue_state @issue_assignee = issue_assignee @show_issues_count = show_issues_count @issue_search_query = issue_search_query @issue_label = issue_label @sandbox = sandbox end def run - matching_apps = find_all_matching_apps(apps, :github, sandbox) - matching_apps.each do |app| - ui.info("\n Issues of #{app} \n") + matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox) + matching_repos.each do |repo| + ui.info("\n Issues of #{repo} \n") begin - issues = client.search_issues(uri_with_query_options(app)) + issues = client.search_issues(uri_with_query_options(repo)) ui.info("There are #{issues[:total_count]} issues with matching query") if show_issues_count table_rows = create_table(issues[:items]) table = Terminal::Table.new headings: table_columns, rows: table_rows ui.success(table) rescue StandardError => e @@ -62,31 +62,31 @@ ] issue_label.nil? ? row_data : row_data.push(labels_names(issue[:labels])) end end - def uri_with_query_options(app) - uri = "repo:#{app} is:issue state:#{issue_state}" + def uri_with_query_options(repo) + uri = "repo:#{repo} is:issue state:#{issue_state}" unless issue_label.nil? - check_valid_labels(app) + check_valid_labels(repo) uri.concat(" label:#{issue_label}") end uri.concat(issue_assignee == "none" ? " no:assignee" : " assignee:#{issue_assignee}") if issue_assignee "#{uri} #{issue_search_query}" end def labels_names(labels) labels.map { |label| label[:name] }.join(", ") end - def check_valid_labels(app) - issue_label.split(",").each { |label| valid_label?(app, label) } + def check_valid_labels(repo) + issue_label.split(",").each { |label| valid_label?(repo, label) } end - def valid_label?(app, label) - client.label(app, label) + def valid_label?(repo, label) + client.label(repo, label) rescue Octokit::NotFound => e - ui.error("There is no \"#{label}\" label in the \"#{app}\" repo.") + ui.error("There is no \"#{label}\" label in the \"#{repo}\" repo.") end end end end end