19 lines
641 B
Ruby
Executable File
19 lines
641 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
#
|
|
# usage: validate somefile.xson somefile.bson
|
|
#
|
|
# Reads somefile.xson file (XML that describes a Mongo-type document),
|
|
# converts it into a Ruby OrderedHash, runs that through the BSON
|
|
# serialization code, and writes the BSON bytes to somefile.bson.
|
|
#
|
|
# This script is used by the mongo-qa project
|
|
# (http://github.com/mongodb/mongo-qa).
|
|
|
|
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
|
require 'mongo'
|
|
require 'mongo/util/xml_to_ruby'
|
|
|
|
obj = File.open(ARGV[0], 'r') { |f| XMLToRuby.new.xml_to_ruby(f) }
|
|
bson = BSON.new.serialize(obj).to_a
|
|
File.open(ARGV[1], 'wb') { |f| bson.each { |b| f.putc(b) } }
|