Skip to content

Instantly share code, notes, and snippets.

@wacko

wacko/gemcount

Last active Jun 21, 2017
Embed
What would you like to do?
List all the different gems on your Gemfile.lock
#!/bin/bash
print_gems() {
awk '/([[:alnum:]_]+) \(/{ print $1 }' Gemfile.lock | sort -u
}
count() {
grep -c ^
}
if [ "$1" == "-c" ]; then
print_gems | count
else
print_gems
fi
@wacko

This comment has been minimized.

Copy link
Owner Author

@wacko wacko commented Jun 21, 2016

$ cat Gemfile
source 'https://rubygems.org'
gem 'rails'
$ gemcount
actionmailer
actionpack
...
$ gemcount -c
36
@wacko

This comment has been minimized.

Copy link
Owner Author

@wacko wacko commented Jun 21, 2016

I like grep -c ^ over wc -l as it doesn't print spaces ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.