Class: GemContribute::CLI::Scan
- Inherits:
-
Object
- Object
- GemContribute::CLI::Scan
- Defined in:
- lib/gem_contribute/cli/scan.rb
Overview
‘gem-contribute scan [path]` — Stage 1’s command.
Reads a Gemfile.lock, resolves each rubygems-sourced gem, hits the GitHub adapter for ‘good first issue`-tagged issue counts on every github.com project, and prints:
<N> gems · <N> on github.com · <N> on <other> · <N> unknown source
Top contributable projects (by open `good first issue` count):
<gem-name> <count> <github.com/owner/repo>
...
Constant Summary collapse
- DEFAULT_LABEL =
GitHub’s ‘labels=foo,bar` query is an AND, not an OR, so passing the full set of beginner-friendly variants returns almost nothing. Stage 1 uses the canonical `good first issue` label only — the “render labels verbatim” promise in ADR-0005 belongs to display, not to server-side filtering. Future stages can call once per label and dedupe.
"good first issue"
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr, resolver: Resolver.new, adapter: HostAdapters::GitHubAdapter.new) ⇒ Scan
constructor
A new instance of Scan.
-
#run(argv) ⇒ Integer
Exit status.
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, resolver: Resolver.new, adapter: HostAdapters::GitHubAdapter.new) ⇒ Scan
Returns a new instance of Scan.
24 25 26 27 28 29 |
# File 'lib/gem_contribute/cli/scan.rb', line 24 def initialize(stdout: $stdout, stderr: $stderr, resolver: Resolver.new, adapter: HostAdapters::GitHubAdapter.new) @stdout = stdout @stderr = stderr @resolver = resolver @adapter = adapter end |
Instance Method Details
#run(argv) ⇒ Integer
Returns exit status.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gem_contribute/cli/scan.rb', line 33 def run(argv) path = argv.first || "Gemfile.lock" gems = LockfileParser.parse(path) @stdout.puts "Scanning #{path} (#{gems.size} gems)..." projects = gems.map { |gem| @resolver.resolve(gem) } # Summary tally reflects only the lockfile contents — the # self-injection is intentionally additive, not part of the count. print_summary(tally_hosts(projects), gems.size) scan_github_projects(projects) 0 rescue LockfileNotFound => e @stderr.puts "gem-contribute: #{e.}" 1 rescue Errno::ECONNREFUSED, SocketError => e @stderr.puts "gem-contribute: network unreachable (#{e.class}: #{e.})" @stderr.puts "Re-run when you have connectivity, or use cached data with --refresh disabled." 1 end |