github.com/replit/upm@v0.0.0-20240423230255-9ce4fc3ea24c/resources/ruby/list-lockfile.rb (about)

     1  # This is a Ruby script which dumps relevant information from the
     2  # Gemfile.lock to stdout in JSON format. The JSON is a map from
     3  # package names to versions, both strings.
     4  
     5  require 'bundler'
     6  require 'json'
     7  
     8  # https://stackoverflow.com/a/40098825/3538165
     9  lockfile = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile))
    10  
    11  result = {}
    12  lockfile.specs.each do |spec|
    13    result[spec.name] = spec.version
    14  end
    15  
    16  puts result.to_json