Skip to content

Instantly share code, notes, and snippets.

@Kalimaha
Created July 15, 2020 05:46
Show Gist options
  • Save Kalimaha/c7744f8aa1cb96676e9f98ac951a282c to your computer and use it in GitHub Desktop.
Save Kalimaha/c7744f8aa1cb96676e9f98ac951a282c to your computer and use it in GitHub Desktop.
Decompress binary content from VCR's YAML file
require 'json'
require 'zlib'
require 'yaml'
require 'base64'
abort('Please proide the absolute path to VCR YAML file') if ARGV.size < 1
begin
filepath = ARGV[0]
yaml = YAML.load(File.read(filepath))
binary = yaml["http_interactions"].first["response"]["body"]["string"]
gzipped = Base64.decode64(binary)
reader = Zlib::GzipReader.new(StringIO.new(gzipped))
uncompressed = reader.read
dictionary = JSON.parse(uncompressed)
puts
puts '================================================================================================================================================================'
puts
puts dictionary
puts
puts '================================================================================================================================================================'
puts
rescue => e
puts
puts 'Have you deleted "!binary " from the YAML file?'
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment