Repository is archived
No commit activity in last 3 years
No release in over 3 years
A wrapper for native protocol buffer javascript compiler which generates closure library proto2 messages.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Protocol buffer javascript compiler for closure library

This gem is a wrapper for native protocol buffer javascript compiler which generates closure library proto2 messages.

At the time of writing this gem, google does not provide an official protocol buffer compiler for closure library. An almost identical open source alternative is protobuf-plugin-closure which this gem is based on.

Installation

Protobuf runtime compiler and development header and libraries must be present at gem installation time.

  • Under linux, user the right development package, eg libprotoc-dev for ubuntu.
  • Under osx, use brew install protobuf.
  • Under windows, use the official protobuf binaries.

Then, install the gem:

gem install protobuf-closure-library

Working with rails

When using this gem with rails, try yellow-brick-road.

Usage

require 'protobuf-closure-library'
ProtobufClosureLibrary::ProtocJs.compile input_proto_file,
                                         output_dir, {
                                           generator_options: {key: value},
                                           protoc_options: []
                                         }

This generated a .pb.js file correponded to input_proto_file in output_dir. The output file contains a subclass of goog.proto2.Message.

By default, the generated message classes are subclasses of goog.proto2.Message. This can be overriden by using generator_options: {js_superclass: 'cusom_package.CustomClass'} which generates message classes with cusom_package.CustomClass as the superclass.

Other protoc options can be passed to the compiler by protoc_options key.