Skip to content

Instantly share code, notes, and snippets.

@jaynetics
Last active December 28, 2022 18:53
Show Gist options
  • Save jaynetics/1f9cdd8156809379db8ab6951be20411 to your computer and use it in GitHub Desktop.
Save jaynetics/1f9cdd8156809379db8ab6951be20411 to your computer and use it in GitHub Desktop.
fetch release dates of gem versions in your gemfile / bundle
require 'json'
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'excon'
gem 'fortschritt'
end
# get list of gems from bundle
list = `bundle list --without-group test --without-group development`
gems_with_version = list.scan(/\* (\S+) \(([^\)\s]+)\)/).to_h
# fetch release dates from rubygems.org API
with_release_date = gems_with_version.with_fortschritt.map do |gem, version|
res = Excon.get(
"https://www.rubygems.org/api/v2/rubygems/#{gem}/versions/#{version}.json",
expects: [200],
)
sleep 0.2 # https://guides.rubygems.org/rubygems-org-rate-limits/
fortschritt
data = JSON(res.body)
version_created_at = data['version_created_at']
[gem, [version, version_created_at]]
end.to_h
# store results in a json file
path = 'gem_release_dates.json'
File.open(path, 'w') { |f| f.puts(with_release_date.to_json) }
puts '', "done, data stored in: #{path}"
@jaynetics
Copy link
Author

@ericmathison thanks for the pointer! fixed it. may i ask how you found this gist? just curious - i didn't expect anyone to find it and it doesn't seem very google-able.

@ericmathison
Copy link

This was my exact search: https://duckduckgo.com/?q=show+release+dates+in+gemfile

You are the first hit!

@jaynetics
Copy link
Author

thats nice! maybe i should use the search engine that flatters me most 😁

my gist does not seem to be on google at all, but if anyone ends up here, my googling turned up this other gist that does the same, but is a bit more feature rich: https://gist.github.com/ixti/3680c400850e8fefe52ceeb94dac8b03

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