Skip to content

Instantly share code, notes, and snippets.

@logicrime
Last active September 16, 2015 10:57
Show Gist options
  • Save logicrime/f800c55fc799b301fef5 to your computer and use it in GitHub Desktop.
Save logicrime/f800c55fc799b301fef5 to your computer and use it in GitHub Desktop.
searchgems
#!/usr/bin/env ruby
# gem search, by hayden jones
# License: whatever
# usage: ./searchgems eventmachine
# prints all gems that contain eventmachine in the name
# if a lot of people use this, maybe somebody will fix rubygems so that gem search
# searches from cache instead of over the wire
puts `gem search ""`.split("\n").select { |line| line.include?(ARGV[0]) }.sort
@baweaver
Copy link

`gem search ""`
  .split("\n")
  .select { |line| line.include?(ARGV[0]) }
  .map { |line| line.split.first }
  .sort

or faster:

`gem search ""`.split("\n").reduce([]) { |a, line| line.include?(ARGV[0]) ? a.concat(line.split.first) : a }.sort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment