Skip to content

Instantly share code, notes, and snippets.

@mikz
Created October 8, 2021 14:38
Show Gist options
  • Save mikz/b0246d2eeaa63a672e1e98a9b2961d1b to your computer and use it in GitHub Desktop.
Save mikz/b0246d2eeaa63a672e1e98a9b2961d1b to your computer and use it in GitHub Desktop.
Parse unity yaml to ruby objects.
#!/usr/bin/env ruby
require 'yaml'
require 'psych'
require 'pry'
parser = Psych::Parser.new(Unity3DStream.new(&Proc.new{ |doc| binding.pry }))
str = ARGF.read.gsub(/^--- [!]u[!](\d+)/) { "--- !<tag:unity3d.com,2011/#{$1}>" }.gsub(/^(--- .+?) stripped/) { $1 }
parser.parse str
puts parser.handler.root.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment