Class: Gemview::Commands::Search
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Gemview::Commands::Search
- Defined in:
- lib/gemview/commands.rb
Instance Method Summary collapse
Instance Method Details
#call(term:, downloads: nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gemview/commands.rb', line 47 def call(term:, downloads: nil, **) gems = Gem.search(term: term) if gems.empty? abort("Error: No gems found for the search term: #{term}") end case downloads when "total" gems.sort_by! { |gem| -gem.downloads } when "version" gems.sort_by! { |gem| -gem.version_downloads } end View.list(gems: gems) end |