Skip to content

Commit

Permalink
Merge pull request #4 from apainintheneck/add-author-command
Browse files Browse the repository at this point in the history
Add author command
  • Loading branch information
apainintheneck authored Dec 7, 2024
2 parents 535811f + bc322d8 commit 6f70f66
Show file tree
Hide file tree
Showing 6 changed files with 542 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ An unofficial CLI interface for querying information from rubygems.org.
TODO: Write installation instructions here

## Usage

```
Commands:
gemview info NAME # Show gem info
gemview releases # List the most recent new gem releases
gemview search TERM # Search for gems
gemview updates # List the most recent gem updates
gemview version # Print version
gemview author USERNAME # Find gems by rubygems.org username
gemview info NAME # Show gem info
gemview releases # List the most recent new gem releases
gemview search TERM # Search for gems
gemview updates # List the most recent gem updates
gemview version # Print version
```

## Development
Expand Down
17 changes: 17 additions & 0 deletions lib/gemview/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ def call(term:, **)
end
end

class Author < Dry::CLI::Command
desc "Find gems by rubygems.org username"

argument :username, type: :string, required: true, desc: "rubygems.org username"

def call(username:, **)
gems = Gem.author(username: username)

if gems.empty?
abort("Error: No gems found for the rubygems.org username: #{username}")
end

View.list(gems: gems)
end
end

class Releases < Dry::CLI::Command
desc "List the most recent new gem releases"

Expand Down Expand Up @@ -91,6 +107,7 @@ def call(*)

register "info", Info
register "search", Search
register "author", Author
register "releases", Releases
register "updates", Updates
register "version", Version, aliases: ["v", "-v", "--version"]
Expand Down
6 changes: 6 additions & 0 deletions lib/gemview/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ def self.search(term:)
Client.v1.search(term).map { |gem_hash| new gem_hash }
end

# @param username [String] rubygems.org username
# @return [Array<Gemview::Gem>]
def self.author(username:)
Client.v1.gems(username).map { |gem_hash| new gem_hash }
end

# @return [Array<Gemview::Gem>]
def self.latest
Client.v1.latest.map { |gem_hash| new gem_hash }
Expand Down
92 changes: 92 additions & 0 deletions spec/fixtures/cassettes/gems-by-author-bbatsov.yml

Large diffs are not rendered by default.

Loading

0 comments on commit 6f70f66

Please sign in to comment.