gemset_snapshot 548 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env bash
  2. printf "\nBeginning snapshot of the current environment gem list into snapshot.gems\n"
  3. file_name="snapshot.gems"
  4. gems=($(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | \tr ' ' ';'))
  5. for gem in "${gems[@]}" ; do
  6. name="${gem%%;*}"
  7. versions=${gem#*;}
  8. versions=(${versions/,/ })
  9. for version in "${versions[@]}" ; do
  10. echo "$name -v$version" >> "$file_name"
  11. done ; unset version versions
  12. done ; unset file_name
  13. printf "\nCompleted snapshot of the current environment gem list into snapshot.gems\n"
  14. exit $?