Ruby Protocol Buffers
-
I just came across these open source Ruby Protocol Buffers from Mozy.com - I have no clue how to use them, but figured I'd share them with developers here...hopefully they are useful!
-
hm... wonder what it does....
-
@unknownuser said:
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.This library has two components: a compiler to turn <tt>.proto</tt> definitions
into Ruby modules (extension <tt>.pb.rb</tt>), and a runtime to use protocol
buffers defined by these modules. The compiler relies on Google's C++ based
compiler (+protoc+) for much of the heavy lifting -- this has huge advantages in
ensuring compatibility and correctness.This library is heavily optimized for encoding and decoding speed. There is a
small C extension available in the ext/ dir that will improve performance even
further, but it is currently disabled to avoid rubygems having to compile a
native extension. TODO: anybody know if we can make this optional?Because this is a tool for generating code, the RDoc documentation is a bit
unusual. See the text in the ProtocolBuffers::Message class for details on what
code is generated.Certainly sounds interesting.
-
Protocol Buffers are a serialization format. Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be "resurrected" later in the same or another computer environment. (wikipedia)
I can imagine that with Protocol Buffers one can build a efficient way for communication between ruby and some program... even over network. Sounds interesting. -
@remus said:
Certainly sounds interesting.
Interesting indeed - but I don't understand exactly what it do or what you can do with it.
-
I am trying to make an interface from my Sketchup BIM-Tools plugin, to a BIMserver(BIMserver.org) using protocol buffers.
These Ruby Protocol Buffers are exactly what I need!
I have been trying to copy parts of the code into my plugin folder, but frankly I have no idea what I'm doing here
Is there anyone with some experience in using this "library"?
Or maybe a few tips on "plugging" external libraries into the sketchup-ruby installation?Any help is greatly appreciated!
Cheers!
Jan -
I would instead make a Ruby C Extension. Bundling along lots of ruby libs opens up for lots of potential clashes. Imagine if another plugin was bundling a slightly different version.
-
I took a quick look through the code.
It requires a full Ruby install as it needs several standard library files. (I also novice some code in there for Ruby v1.9.x compatibility. Don't know if that would cause problems.)
Generally, from what I read, I do not care for the implementation. It creates modules (and perhaps only toplevel modules. This would heighten the probability of namespace clashes.)
Why they didn't implement a class and have the Ruby individual protocol buffer be an instance I do not know. It's what I would done.)
You need to realize that most Ruby Gems are written to run in their own Ruby process, started from the command line. The ruby script does it's task, and then that Ruby process ends.
SketchUp Embedded Ruby uses a persistent SHARED Ruby process, where we must be careful to run all out code within each of our own toplevel modules (namespaces.)
This code for example requires the Ruby command line option parser, which means it expects arguments to be in the
ARGV
array. In SketchUp Embedded Ruby this array is empty. NONE of the command line parameters used to start SketchUp.exe are passed into it's Ruby process.Looks to me like WAY too much work to "SketchUpize" this utility.
What is wrong with class
PStore
? .. or JSON string files ? -
Hi Dan,
Thanks for looking into this!
Too bad it's not easy to use from SketchUp.A single protocol buffers class for ruby does indeed seem much better than all these modules.
Writing my own class for this seems way over my head(figuring out how the data is "serialized" and all).JSON seems to have a similar purpose, and could be a good alternative.
But there are only a few ways to communicate with the TNO bimserver, from which protocol buffers seems to be the preferred solution.
Check out this page: http://code.google.com/p/bimserver/wiki/Interfaces
So in this case I don't think I can use JSON...(and would that be easy to load in SketchUp?)(interesting subject though "serialization"(YAML, Marshall, JSON), using this I might be able to store my complete "wall"/"floor" objects in a sketchup attribute. Re-load an object instead of re-creating it!)
I hope I can find SOME way to communicate with bim-server, would be great if I could make a direct connection!
-
[off:g7kpsrm3]( but possibly related )
Nested Attribute Dictionaries[/off:g7kpsrm3]
-
@brewsky said:
Check out this page: http://code.google.com/p/bimserver/wiki/Interfaces
So in this case I don't think I can use JSON...Ruby standard library has an extensive [url=http://www.ruby-doc.org/stdlib-1.8.6/libdoc/soap/rdoc/index.html:pxzi4drt]SOAP[/url:pxzi4drt] class, however again a full Ruby install is needed.
You may be better off trying the [url=http://code.google.com/p/bimserver/wiki/RESTInterface:pxzi4drt]REST[/url:pxzi4drt] interface as it uses HTTP1.1 protocol. See: [url=http://en.wikipedia.org/wiki/REST:pxzi4drt]wikipedia/REST[/url:pxzi4drt]
-
@dan rathbun said:
What is wrong with class
PStore
? .. or JSON string files ?BIMserver.org is implementing a JSON interface!
I have absolutely no idea where to start, but lets see if I can somehow make a connection from my BIM-Tools plugin to BIMserver using JSON -
@brewsky said:
@dan rathbun said:
... or JSON string files ?
BIMserver.org is implementing a JSON interface!I have absolutely no idea where to start, ...
Start here... topic : JSON in Ruby... read the first few posts where I explain the basics of converting to and from a Ruby
Hash
into a JSON string.Then... scroll down to the method posts by Aerilius in which he "standardized" the conversions into methods. These can be pasted into your plugin sub-module, or added as a library sub-module, just within your toplevel "author" module, so it can be used by many of your plugins.
I show examples of doing this in the post prior to Aerilius' method postings. -
-
... also an Attribute Dictionary is basically a hash written into the model dB. So they can be converted similarly.
Advertisement