title: Comparing YAML files in ruby without loading
body: <p>I am looking for a way to compare (and, best case, also diff) two YAML files in Ruby; regardless of key order, naturally. So far all solutions I found depended on loading the files with <code>YAML::load_file()</code>. I cannot do that, however, because the files are dumps of Ruby objects whose class declarations I do not have, so that loading them throws <code>undefined class/module</code>.</p>
  
  <p>I think I need to load them as string hashes and compare that, but how do I tell Ruby to ignore the type information and just include it into the comparison?</p>
  
  <p>Based on comments: I'm basically interested in text-based comparison, but it must be aware of the "depth" of the data structure. For instance this is an excerpt from one of the files I have:</p>
  
  <pre><code>attributes: !ruby/hash:Example::Attributes
    !binary "b2NjaQ==": !ruby/hash:Example::Attributes
      !binary "Y29yZQ==": !ruby/hash:Example::Attributes
        !binary "aWQ=": !ruby/object:Example::Properties
          type: string
          required: false
          mutable: false
        !binary "dGl0bGU=": !ruby/object:Example::Properties
          type: string
          required: false
          mutable: false
  </code></pre>
  
  <p>So the comparison must be able to identify a match even if the two attributes are in reverse order.</p>