Last active
November 4, 2019 23:01
-
-
Save MartinHarding/ab98dc4f8d52dd3ee3bcc0f06601664e to your computer and use it in GitHub Desktop.
Get info about your project's gems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Use with output of `bundle list` to get a CSV of your gems and when they were last updated | |
echo "gem,current_version,current_version_date,latest_version,latest_version_date" | |
while read line; do | |
if [[ $line == 'Gems included by the bundle:' ]]; then | |
continue | |
fi | |
gem_name=`echo "$line" | cut -d' ' -f2` | |
current_version_num=`echo "$line" | cut -d' ' -f3 | sed 's/[\(\)]//g'` | |
gem_versions="`curl -s https://rubygems.org/gems/$gem_name/versions`" | |
latest_version_info=`echo "$gem_versions" | pup '.versions ul li:first-child'` | |
latest_version_num=`echo $latest_version_info | pup 'a text{}' | tr -d "\n\r" | sed 's/-//g' | awk '{$1=$1;print}'` | |
latest_version_date_raw=`echo $latest_version_info | pup 'small text{}' | tr -d "\n\r" | sed 's/-//g' | awk '{$1=$1;print}'` | |
latest_version_date=`date -j -f "%B %d, %Y" "$latest_version_date_raw" +"%Y/%m/%d"` | |
current_version_info=`echo "$gem_versions" | pup '.versions ul li' | grep -A 4 "$current_version_num\$"` | |
current_version_date_raw=`echo $current_version_info | pup 'small text{}' | tr -d "\n\r" | sed 's/-//g' | awk '{$1=$1;print}'` | |
current_version_date=`date -j -f "%B %d, %Y" "$current_version_date_raw" +"%Y/%m/%d"` | |
echo "\"$gem_name\",\"$current_version_num\",\"$current_version_date\",\"$latest_version_num\",\"$latest_version_date\"" | |
done <gemlist.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment