Module: GemContribute::CLI::IssueAnnouncer
- Defined in:
- lib/gem_contribute/cli/issue_announcer.rb
Overview
CLI-side helpers for the “I’m working on this” claim machinery.
The actual posting (and gating) lives in ‘Operations::Announce` (output-free, Result-returning) — see ADR-0012. What remains here is the index-fetching used by `scan` and `issues` to flag claimed issues in their output. Both halves share `Operations::Announce::WORKING_MARKER`.
Constant Summary collapse
- MARKER =
Operations::Announce::WORKING_MARKER
Class Method Summary collapse
-
.fetch_claim_index(adapter) ⇒ Object
Builds a lookup hash of => Set<issue_number> from GitHub’s issue search for our marker.
- .parse_issue_url(url) ⇒ Object
Class Method Details
.fetch_claim_index(adapter) ⇒ Object
Builds a lookup hash of => Set<issue_number> from GitHub’s issue search for our marker. Used by ‘scan` and `issues` to flag claimed issues. One search call per process (the adapter caches the result for the issues TTL). Degrades to an empty hash if the search fails (anonymous rate limits, network, etc.).
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gem_contribute/cli/issue_announcer.rb', line 21 def fetch_claim_index(adapter) items = adapter.search_issues("\"#{MARKER}\" is:issue is:open") items.each_with_object(Hash.new { |h, k| h[k] = [] }) do |item, index| parsed = parse_issue_url(item["html_url"]) next unless parsed owner, repo, number = parsed index["#{owner}/#{repo}"] << number end rescue GemContribute::AdapterError, GemContribute::AuthRequired {} end |
.parse_issue_url(url) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/gem_contribute/cli/issue_announcer.rb', line 34 def parse_issue_url(url) match = url.to_s.match(%r{github\.com/([^/]+)/([^/]+)/issues/(\d+)}) return nil unless match [match[1], match[2], match[3].to_i] end |