Commit Graph

32 Commits

Author SHA1 Message Date
Josh Haberman
194ad621bb Ruby JSON: always accept both camelCase and original field names.
For JSON encoding we provide a new option to decide at
encode time whether to use camelCase or original proto field
names:

  json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true)
2016-04-14 18:33:17 -07:00
Joshua Haberman
e70f9256af Merge pull request #1139 from haberman/rubyjsoncamel
Changed Ruby to properly camelCase its JSON by default.
2016-03-04 17:31:11 -08:00
Josh Haberman
513875da77 Generate well-known types in Ruby extension and prune unneeded proto2 dependencies. 2016-03-03 14:08:54 -08:00
Josh Haberman
78da66698b Changed Ruby to properly camelCase its JSON by default. 2016-02-18 10:50:14 -08:00
Anders Carling
0559f3ee9e Add field name to initialization map exceptions 2015-11-20 21:57:28 +01:00
Anders Carling
0df1e398eb Raise NoMethodError for unknown fields
More informative and more ruby-like
2015-11-20 21:55:18 +01:00
Bo Yang
5db217305f down-integrate internal changes 2015-05-21 19:32:02 -07:00
Chris Fallin
a526605aec Merge pull request #338 from skippy/encode-decode-helpers
ruby: Encode decode cleanup and behavior normalization
2015-05-15 10:52:56 -07:00
Adam Greene
cd7ebbe54f make repeated_field quack like an array 2015-05-14 10:38:11 -07:00
Chris Fallin
eb37551ae4 Added Ruby to Travis testing.
- Added RVM-based Ruby test driver that tests MRI and JRuby.
- Fixed JRuby compilation (at least in my current setup): force source
  version to 1.6 (Java 6) to allow generics and annotations.
- Modify the skipped JRuby JSON tests so that the exit code is 0 (skip()
  results in a failing exit code from `rake test`). An upcoming PR
  should fix JSON under JRuby in general soon.
2015-05-13 14:58:48 -07:00
Adam Greene
d1b52a00e0 adding and simplifying encoders/decoders
* make consistent between mri and jruby
* create a #to_h and have it use symbols for keys
* add #to_json and #to_proto helpers on the Google::Protobuf message classes
2015-05-13 10:03:56 -07:00
Chris Fallin
16a283f794 Merge pull request #334 from skippy/allow-msg-to-accept-nil
ruby: allow a message field to be unset
2015-05-02 19:02:08 -07:00
Adam Greene
64678265c5 allow a message field to be unset 2015-05-02 13:48:23 -07:00
Adam Greene
d55733c76e return nil if array index indicie is out of bounds
ruby arrays don't throw an exception; they return nil.  Lets do the
same!

this fix also includes the ability to use negative array indicies
2015-05-01 22:50:57 -07:00
Adam Greene
c70b6058ea add size alias for length
starting to make `RepeatedField` quack like an array

additional changes:
* make sure gemspec gets all ruby code files
* add homepage in gem spec removes one of the warnings, and the gem spec authors are pushing
everyone to include a homepage in the gem
* remove excess whitespace in test suite to bring formatting inline with the rest of the file
2015-05-01 11:48:04 -07:00
Chris Fallin
e9abbd23fb Fixed issue #283: crash in JSON handler cleanup.
Includes repro test case from @wfarr.
2015-04-13 14:02:43 -07:00
Isaiah Peng
27e2b57830 add jruby support by protobuf-java reflection API 2015-03-10 23:14:08 +01:00
Chris Fallin
db87a9c07a Merge pull request #211 from isaiah/map_inspect
Ruby implementation Map#inspect should be consistent with Hash#inspect
2015-02-17 13:02:32 -06:00
Isaiah Peng
4502626fa7 Google::Protobuf::Map#inspect should be consistent with Hash#inspect 2015-02-14 22:15:12 +01:00
Chris Fallin
a2bea0a001 Properly support maps in Ruby protoc and another bugfix.
Previously, we supported map fields in the Ruby DSL. However, we never
connected the final link in the chain and generated `map` DSL commands
for map fields in `.proto` files. My apologies -- I had been testing
with the DSL directly so I missed this.

Also fixed a handlerdata-setup-infinite-loop when a map value field's
type is its containing message.
2015-02-12 16:08:01 -08:00
Joshua Haberman
20490e33ca Merge pull request #189 from cfallin/update-ruby-upb
Updated to latest upb and added test for JSON map operation.
2015-02-05 15:22:17 -08:00
Chris Fallin
e7e79a43ed Merge pull request #190 from isaiah/to_ary
add #to_ary to RepeatedField
2015-02-03 09:57:13 -08:00
Isaiah Peng
ee5f6e9a35 add #to_ary to RepeatedField 2015-02-03 16:45:12 +01:00
Chris Fallin
a50759254f Updated to latest upb and added test for JSON map operation. 2015-02-02 15:07:34 -08:00
Chris Fallin
e2debef5d8 Ruby extension: added oneof accessor. 2015-01-14 18:02:27 -08:00
Chris Fallin
e1b7d38d9a Addressed code-review comments. 2015-01-14 17:14:05 -08:00
Chris Fallin
3f3820d8f8 Two tests for Ruby code generator:
- A golden-file test that ensures protoc produces known-valid output.
- A Ruby test that loads that golden file and ensures it actually works
  with the extension.

This split strategy allows us to test end-to-end without needing to
integrate the Ruby gem build system and the protoc build system. This is
desirable because we do not want a gem build/install to depend on
building protoc, and we do not want building protoc to depend on
building and testing the gem.
2015-01-14 15:44:46 -08:00
Chris Fallin
fcd8889d5b Support oneofs in MRI Ruby C extension. 2015-01-14 14:35:57 -08:00
Chris Fallin
ace4212e60 Line-wraps at 80 chars. 2015-01-13 13:47:58 -08:00
Chris Fallin
fd1a3ff11d Support for maps in the MRI C Ruby extension.
This adds the Map container and support for parsing and serializing maps
in the protobuf wire format (as defined by the C++ implementation, with
MapEntry submessages in a repeated field). JSON map
serialization/parsing are not yet supported as these will require some
changes to upb as well.
2015-01-06 15:44:09 -08:00
Chris Fallin
91473dcebf Rename protobuf Ruby module to google/protobuf and rework its build
system. The Ruby module build now uses an amalgamated distribution of
upb, and successfully builds a Ruby gem called 'google-protobuf' with
module 'google/protobuf'.
2014-12-12 15:58:26 -08:00
Chris Fallin
973f425725 Provide a Ruby extension.
This adds a Ruby extension in ruby/ that is based on the 'upb' library
(now included as a submodule), and adds support for Ruby code generation
to the protoc compiler.
2014-12-09 16:55:59 -08:00