Sha256: 61ab63edc90081bac53451ca4d6c871d8b9e86996f36afd10e04c630dd1c0bca
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
= Protopuffs! A new implementation of Protocol Buffers in Ruby. If you're not familiar with Protocol Buffers, start with Google's homepage: http://code.google.com/apis/protocolbuffers Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data -- think XML, but smaller, faster, and simpler. == Installation Rubyforge is cuckoo for protopuffs. sudo gem install protopuffs == Usage Start with a +proto+ file, say, <tt>proto/animals.proto</tt>: message Bird { required string name = 1; optional string species = 2; } First, require Protopuffs and tell it where your +proto+ files are: require 'protopuffs' Protopuffs.proto_load_path << "proto" Protopuffs.load_message_classes That makes the Bird message dynamically available in Ruby. Everything's namespaced under <tt>Protopuffs::Message</tt>, which should help with your OCD. bird = Protopuffs::Message::Bird.new bird.name = "Sonny" bird.species = "Cuculus canorus" # encode this message to the super-efficient binary wire format binary_bird = bird.to_wire_format # or encode to the human-friendly text format, for debugging puts bird.inspect You can also decode incoming binary wire-format messages: decoded_bird = Protopuffs::Message::Bird.new decoded_bird.from_wire_format(binary_bird) decoded_bird.name # => "Sonny" === Mass-assignment TODO: explain <tt>Message::Base.new</tt> with strings containing the wire format or hashes, as well as <tt>#attributes=</tt> == Missing functionality Protopuffs currently only supports a base set of the <tt>.proto</tt> file syntax. Here's what's missing: * sfixed32 and sfixed64 types * sint32 and sint64 types (due to lack of support for ZigZag encoding) * packed repeated fields (the <tt>[packed=true]</tt> option) * enumerations * importing definitions * nested message types * extensions * nested extensions * packages * services * built-in options * custom options * groups (deprecated)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chrisk-protopuffs-0.2.1 | README.rdoc |