Commit Graph

46 Commits

Author SHA1 Message Date
Joe Bolinger
180d3e3287 fix null terminated string (#6370) 2019-07-22 17:11:58 -07:00
Mike Moore
565154af78
Remove Ruby to_hash methods 2019-05-22 13:21:51 -06:00
Joshua Haberman
d57581348d
Revert "Convert Google::Protobuf.deep_copy to pure Ruby" 2019-05-14 14:25:11 -07:00
Aaron Patterson
3b67455319
Convert Google::Protobuf.deep_copy to pure Ruby
In general, I think it will help us to debug issues if we have less C
code and more Ruby code.  This method can be implemented in pure Ruby,
so this commit converts it to pure Ruby.
2019-05-13 15:37:13 -07:00
Joe Bolinger
e4bbca1fc5 Add wrapper type helpers for Ruby (#5739)
* add wrapper type helpers

* add check for _as_value suffix
2019-03-27 09:44:43 -07:00
Joshua Haberman
1568deab40
Revert "Updated upb from defcleanup branch and modified Ruby to use it (#5539)" (#5848)
This reverts commit 37581380fb.
2019-03-06 15:44:38 -08:00
Joshua Haberman
37581380fb
Updated upb from defcleanup branch and modified Ruby to use it (#5539) 2019-03-06 10:20:18 -08:00
Joe Bolinger
76685c6fae Add frozen checks in Ruby (#5726)
* add frozen checks

* Use rb_check_frozen

* Correct assertion on frozen error message

The second argument for the method assert_raise is the message
to show when the assertion fails. It does not check the error
object's message.
Add an additional assertion that does check the error's message.

* do frozen check first
2019-03-02 10:37:37 -08:00
Joe Bolinger
a6e3ac0db1 Generate extra enum method helpers for Ruby (#5670)
* example with extra enum method

* update expected test output

* slight simplification

* add test for generated enum helpers

* move const helpers to c extension

* more explicit test

* more explicit test

* indent

* add foo test

* add check for _const suffix
2019-03-02 10:36:28 -08:00
Joe Bolinger
bc929a3e82 add eql? method (#5730) 2019-02-24 09:53:24 -08:00
Joe Bolinger
39c0947893 implement to_s for message types (#5710) 2019-02-12 09:50:57 -08:00
Joe Bolinger
64eb9b6e85 Add more descriptive error messages to init methods in Ruby (#5659)
* add more descriptive error messages to init methods

* add type errors test to Makefile.am
2019-02-06 07:57:13 -08:00
Paul Yang
aa5c12e882
Revert "Revert "Enable the ignore_unknown_field option in the Ruby unmarshal options" (#5511)" (#5533)
* Revert "Revert "Enable the ignore_unknown_field option in the Ruby unmarshal options" (#5511)"

This reverts commit be1716a6d0.

* Separate ruby conformance test on Mac

* Fix shell syntax

* Fix test
2019-01-08 10:53:34 -08:00
Paul Yang
be1716a6d0
Revert "Enable the ignore_unknown_field option in the Ruby unmarshal options" (#5511) 2018-12-26 12:26:24 -08:00
Joshua Haberman
21940734be
Merge pull request #5373 from ebenoist/erik/unknown-fields
Enable the ignore_unknown_field option in the Ruby unmarshal options
2018-12-22 10:10:40 -08:00
Erik Benoist
9ac11326df Adds the ability to ignore unknown fields on parse
This adds the ability for the MRI Ruby library to optionally pass in a
ignore_unknown_fields option when decoding JSON. The functionality was
added upstream in upb, this change exposes that option.
2018-12-21 16:06:21 -06:00
Hao Nguyen
3c547fcdf3 Lower the severity of lower-case ruby enum to warning. Add conformance test for allow_alias with lower_case enums 2018-12-19 11:25:53 -08:00
Hao Nguyen
c11096c10d Do not require Ruby enum to be upper case 2018-12-14 17:06:36 -08:00
Hao Nguyen
37dbfd6c46 Do not require ruby enum to be uppercase 2018-12-14 17:06:11 -08:00
Harshit Chopra
d0535cc09e Adds support for proto2 syntax for Ruby gem.
This change only adds basic proto2 support without advanced features
like extensions, custom options, maps, etc.

The protoc binary now generates ruby code for proto2 syntax.
However, for now, it is restricted to proto2 files without advanced features
like extensions, in which case it still errors out.

This change also modifies the DSL to add proto messages to the DescriptorPool.
There is a new DSL Builder#add_file to create a new FileDescriptor. With this,
the generated ruby DSL looks something like:

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file "test.proto" do
    add_message "foo" do
      optional :val, :int32, 1
    end
  end
end
2018-09-27 14:21:16 -04:00
Zachary Anker
70544627cb When initializing a message, skip a field if value is nil (#3693) 2018-06-26 20:27:24 -07:00
Erik Benoist
74f8e24232 Adds a base class for all explicitly raised TypeErrors (#4255)
* This allows for ruby code to catch and handle Protobuf
    TypeErrors separately from the standard Ruby TypeError

  * Maintains backwards compatibility by having the new
    Google::Protobuf::TypeError inherit from the base
    TypeError. Any code that was catching TypeError should
    continue to work.
2018-06-26 20:24:24 -07:00
Michael Collis
2a6eaeb86e
Fix scope resolution for MessageExts in Ruby 2018-01-12 15:16:16 -05:00
Paul Yang
23adfeb003 Reserve unknown in Ruby (#3763)
* Reserve unknown in ruby

* Revert ruby tests. Wait for cpp impl for conformance test

* Add conformance test for preserving unknown

* Add unknown field conformance test to csharp failure list.

* Fix comments

* Fix comment

* Fix comments

* Fix typo

* Use stringsink_string directly

* Mark hd unused

* Remove unused encodeunknown_handlerfunc
2017-10-26 14:41:43 -07:00
Joshua Haberman
4fc75296c7 Merge pull request #3627 from zanker/zanker/add-submsg-hash-init
Allow initializing a chain of protos using only a hash in Ruby
2017-09-21 15:08:45 -07:00
Zachary Anker
633ef8bde9 Update message.c 2017-09-21 09:26:54 -07:00
Zachary Anker
8eae3fe6e9 Update message.c 2017-09-20 12:45:42 -07:00
Zachary Anker
87714836e3 Allow initializing a chain of protos using only a hash 2017-09-20 11:39:46 -07:00
Zachary Anker
83264bd160 Fixed to_h with repeated messages to return hashes in Ruby 2017-09-20 11:38:05 -07:00
Josh Haberman
9c6b8cb9bf Ruby: fixed Message#to_h for map fields. 2017-03-14 14:27:16 -07:00
Marcin Wyszynski
74a636a7a2 Move variable declarations before actual code 2016-11-14 21:45:37 +01:00
Marcin Wyszynski
3bdaaa5dda More Ruby-eqsue interface 2016-11-03 14:19:10 +01:00
Josh Haberman
d419ca10b4 Updated upb and simplified ruby code a bit with new upb method. 2016-04-22 14:12:10 -07:00
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
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
Josh Haberman
a1daeaba80 Conform to C89/C90 variable declaration rules.
While we are C99 in general, the Ruby build system
for building C extensions enables several flags that
throw warnings for C89/C90 variable ordering rules.
To avoid spewing a million warnings (or trying to
specifically override these warnings with command-line
flags, which would be tricky and possibly fragile)
we conform to Ruby's world of C89/C90.

Change-Id: I0e03e62d95068dfdfde112df0fb16a248a2f32a0
2015-07-10 12:05:14 -07:00
Chris Fallin
231886f632 Ruby C extension speedup: don't re-intern constant string needlessly.
Also fixed lines with > 80 char length.
2015-05-19 16:19:00 -07:00
Joshua Haberman
202f87f8de Merge pull request #387 from cfallin/ruby-upb-update
Update MRI C Ruby extension to use new version of upb (with upb_env).
2015-05-18 14:07:21 -07:00
Chris Fallin
d326277397 Update MRI C Ruby extension to use new version of upb.
- Alter encode/decode paths to use the `upb_env` (environment)
  abstraction.
- Update upb amalgamation to upstream `93791bfe`.
- Fix a compilation warning (void*->char* cast).
- Modify build flags so that upb doesn't produce warnings -- the Travis
  build logs were pretty cluttered previously.
2015-05-15 11:36:12 -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
a3953da536 Updated based on code-review comments. 2015-02-02 13:16:57 -08:00
Chris Fallin
e2debef5d8 Ruby extension: added oneof accessor. 2015-01-14 18:02:27 -08:00
Chris Fallin
80276ac021 Addressed code-review comments. 2015-01-06 18:01:32 -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