Commit Graph

350 Commits

Author SHA1 Message Date
Joe Bolinger
41e12344a1 Support hashes for struct initializers (#5716)
* support hashes for struct initalizers

* convert hash keys to string

* update tests

* add extra asserts
2019-07-25 11:17:51 -07:00
Joe Bolinger
180d3e3287 fix null terminated string (#6370) 2019-07-22 17:11:58 -07:00
Chris Gaffney
7da7bec441 ruby: Improve performance of Google::Protobuf::Timestamp#to_time (#6360)
This changes to_time to use Ruby's built in Time.at with nanos support
rather than calculating a float and passing it to Time.at. The new
version runs about 3 times faster than the original version and
allocates fewer objects.

Warming up --------------------------------------
    protobuf#to_time    57.296k i/100ms
      faster#to_time   133.229k i/100ms
Calculating -------------------------------------
    protobuf#to_time    635.361k (± 2.1%) i/s -      3.209M in   5.052169s
      faster#to_time      1.873M (± 3.3%) i/s -      9.459M in   5.055169s

Comparison:
      faster#to_time:  1873368.8 i/s
    protobuf#to_time:   635361.4 i/s - 2.95x  slower

Calculating -------------------------------------
    protobuf#to_time   326.000  memsize (   126.000  retained)
                         7.000  objects (     2.000  retained)
                         0.000  strings (     0.000  retained)
      faster#to_time    86.000  memsize (     0.000  retained)
                         1.000  objects (     0.000  retained)
                         0.000  strings (     0.000  retained)

Comparison:
      faster#to_time:         86 allocated
    protobuf#to_time:        326 allocated - 3.79x more
2019-07-10 09:41:11 -07:00
Bo Yang
d581c76063 Merge branch 'master' into 3.9.x
Conflicts:
	java/lite/pom.xml
	java/util/pom.xml
2019-06-21 20:31:00 +00:00
Bo Yang
bc742640ef Merge remote-tracking branch 'origin/3.8.x' 2019-06-21 04:01:45 +00:00
Paul Yang
640423f157
Change int64 json encoding to be string for php and ruby (#6251)
* Change int64 json encoding to be string for php and ruby

* Fix ruby test

* Sync upb change
2019-06-17 13:14:27 -07:00
Hao Nguyen
638720274b Update version to 3.9.0 2019-06-17 09:34:50 -07:00
Sorah Fukumori
997bd354d5 Fix TypeError on decoding enum map values in Ruby (#6262)
value_field_typeclass should be a enum module, not EnumDescriptor
object.

Also expanding tests for enum valued maps.

Fixes #4580

Signed-off-by: Sorah Fukumori <her@sorah.jp>
2019-06-16 15:20:18 -07:00
Joshua Haberman
8041dd4034
Merge pull request #6166 from blowmage/ruby-remove-to_hash
[Ruby] Remove to_hash methods
2019-06-10 16:02:19 -07:00
Mike Moore
565154af78
Remove Ruby to_hash methods 2019-05-22 13:21:51 -06:00
Hao Nguyen
b0d648664d Update protobuf version 2019-05-21 14:07:13 -07:00
Hao Nguyen
2352a30e66 Revert "Update protobuf version"
This reverts commit 6d96493b31.
2019-05-21 13:49:06 -07:00
Hao Nguyen
6d96493b31 Update protobuf version 2019-05-21 13:31:01 -07: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
Adam Cozzette
531505ca13 Updated gemspec to require Ruby 2.3 or higher 2019-05-10 11:36:35 -07:00
Paul Yang
7597f8ad24
Custom mktime to fix issue on mac (#6118)
* Custom mktime to fix issue on mac

* Remove succeeded tests from failure list
2019-05-09 20:51:35 -07:00
Hao Nguyen
37a89f8e1a Update version to 3.8.0 2019-04-23 16:14:52 -07:00
Paul Yang
f425b9f059
Merge pull request #5953 from acozzette/merge-3-7-x
Merge 3.7.x into master
2019-03-28 17:28:22 -07:00
Bo Yang
33dd96c23f Use mktime 2019-03-28 06:38:20 +00:00
Bo Yang
262cc06075 Fix ruby conformance test on mac 2019-03-28 06:35:07 +00:00
Bo Yang
2d9507ec74 Update upb for ruby 2019-03-28 02:17:39 +00:00
Bo Yang
a268b63284 Update upb for ruby 2019-03-27 21:19:01 +00: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
Joe Bolinger
d2daa38986 Add native type setters for Timestamp and Duration in Ruby (#5751)
* add implicit time conversion

* add duration

* add init test

* more tests

* add type check and alternative c type check

* add rational and bigdecimal

* use rb_obj_is_kind_of

* use native time check

* chain implicit conversions

* remove unused variable
2019-03-26 16:48:24 -07:00
Adam Cozzette
8645d893ab Merge branch '3.7.x' into merge-3-7-x 2019-03-26 14:32:20 -07:00
Paul Yang
6973c3a504
Update version number to 3.7.1 (#5947)
* Update version number to 3.7.1

* Update version number in port_def.inc
2019-03-26 09:30:12 -07:00
Adam Cozzette
077079573f Fixed CI failures with Ruby 2.3 on OSX (#5948)
OSX has deprecated OpenSSL, so we need to install it via Homebrew and
build against that version when we build Ruby.
2019-03-25 17:19:48 -07:00
Benjamin Peterson
5939bc3619 Fix "the the". 2019-03-25 13:38:06 -07:00
Paul Yang
ba42cb53d9
Allow bytes field to be longer than 16000 bytes (#5924)
* Allow bytes field to be longer than 16000 bytes

* Remove empty line
2019-03-25 10:51:18 -07:00
Paul Yang
57b6597f46
Replace strptime with custom implementation (#5906)
* Replace strptime with custom implementation

* Fix ruby strptime

* Fix test

* Fix ruby conformance test

* Use mktime

* Remove EmptyFieldMask from failed conformance test list
2019-03-19 22:27:13 -07:00
Joe Bolinger
580826cd97 cherry-pick test fix from #5853 2019-03-14 16:32:01 -07:00
Joe Bolinger
604121aaa4 fix tests for older rubies 2019-03-14 11:42:22 -07:00
Joe Bolinger
0114727cc6 add more descriptive error messages to init methods 2019-03-14 11:37:39 -07:00
Paul Yang
4b145b1c7f
Parse nested listvalue in json for ruby (#5867)
* Add conformance test for nested listvalue

* Fix upb for parsing repeated Value/ListValue

* Add failed repeated ListValue conformance test into php failure list
2019-03-12 10:56:58 -07:00
Paul Yang
a18680890b
Encode empty ListValue (#5857)
* Encode empty ListValue

* Update mac ruby conformance failure list
2019-03-10 17:33:46 -07:00
bmoyles0117
0b5111dbab Raise error for JSON overflow encoding in Ruby (#5752) (#5861)
* add check for overflow

* de-nestify

* break long lines
2019-03-08 12:50:33 -08:00
Paul Yang
e75a689f7c
Fix ruby continuous tests (#5853)
* Fix ruby continuous tests

* Fix compatibility test
2019-03-07 17:16:31 -08:00
Joe Bolinger
f4f32a5b68 make tests work on older rubies (#5823) 2019-03-06 18:58:58 -08: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
8bdecd7430 remove return 0 (#5840) 2019-03-05 23:01:49 -08:00
Bo Yang
cb6fa92ee8 Merge branch '3.7.x' 2019-03-04 10:18:18 -08:00
Joe Bolinger
ae85b457d2 Fix Ruby module name generation when the ruby_package option is used (again) (#5794)
* Revert "Revert "Fix Ruby module name generation when the ruby_package option is used (#5735)""

This reverts commit bb211e851e.

* add new files to Makefile.am
2019-03-02 10:38:10 -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
Paul Yang
582743bf40
Update version number to 3.7.0 (#5793)
* Update version number to 3.7.0

* Add php/releash.sh to Makefile.am

* Make cpp_distcheck exit on fail
2019-02-28 12:55:14 -08:00
Paul Yang
bb211e851e Revert "Fix Ruby module name generation when the ruby_package option is used (#5735)"
This reverts commit 9638dcc340.
2019-02-27 20:56:03 -08:00
Joe Bolinger
9638dcc340 Fix Ruby module name generation when the ruby_package option is used (#5735)
* fix module name generation and add tests

* fix existing tests

* support both package name styles
2019-02-27 20:26:59 -08:00
Joe Bolinger
7f14ea9f48 Raise error for JSON overflow encoding in Ruby (#5752)
* add check for overflow

* de-nestify

* break long lines
2019-02-27 20:26:14 -08:00
Joe Bolinger
e780681e35 Allow repeated fields in Ruby to accept multiple arguments on push (#5736)
* let repeated fields push arrays

* add varargs push

* better test
2019-02-27 18:05:06 -08:00
Joe Bolinger
bc929a3e82 add eql? method (#5730) 2019-02-24 09:53:24 -08:00
Bo Yang
b52754b719 Update version to 3.7.0rc3 2019-02-22 11:31:48 -08:00
Xiang Dai
e479410564 delete all duplicate empty blanks (#5758)
Signed-off-by: Xiang Dai <764524258@qq.com>
2019-02-20 19:28:50 -08:00
Paul Yang
c7b3392201
Update version to 3.7.0 (#5749)
* Update version to 3.7.0

* Update version number for java bom
2019-02-19 15:54:45 -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
7d9377e7f3
Use gnu for ruby build because strptime is provided by posix (#5660)
* Use gnu for ruby build because strptime is provided by posix

* Move option to extconf.rb

* Remove unused code in Rakefile

* Add config files for kokoro test

* Use gnu 11

* Define _XOPEN_SOURCE

* Add gnu11 option

* Remove XOPEN

* Try base_cc_flags

* Try config_options

* Move time.h to top

* Try -D_XOPEN_SOURCE=700

* Define XOPEN_SOURCE directly

* Try extconf.rb

* Try CFLAGS

* Try ext.cross_config_options

* Make mac ruby release job fail on error

* Try again

* Try define _XOPEN_SOURCE in extconf.rb

* Try again

* Define __USE_XOPEN

* Remove 2.6.0

* No mingw

* Throw error on mingw

* Remove XOPEN_SOURCE in upb

* Add back mingw

* Remove comment
2019-02-01 10:09:34 -08:00
Adam Cozzette
1ee15baefc Updated version to 3.7.0rc2 2019-01-30 21:08:04 -08:00
Hao Nguyen
d5be2baa46 Update version to 3.7.0 2019-01-24 10:23:02 -08:00
Paul Yang
37a0ab7d83
Fix Any json encoding/decoding for ruby. (#5592)
* Fix Any json encoding/decoding for ruby.

* Revert unnecessary changes
2019-01-17 10:24:41 -08:00
toc007
dda7ab0363 Ruby nested msg caps (#5564)
* Ruby nested msg caps

* nested types tests added

* test cases added for RubifyConstant

* extracted NestedMessage to TestNestedMessage

* removed nested tests with leading underscore

* extracted testLowercase to toplevel testLowercaseNested
2019-01-15 20:01:41 -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
c3340b20a8
Add ruby 2.6 gem build for linux (#5537)
* Add ruby 2.6 gem build for linux

* Add docker hub organization

* Add ruby2.6 in cross compile targets

* Fix tests

* Check mac version

* No need to install php in preparation for mac
2019-01-07 19:44:54 -08:00
Paul Yang
de9e1a04a6
Add ruby 2.6 test (#5528)
* Add ruby 2.6 test

* Fix broken tests

* Fix compatibility test

* Fix bundler version

* Use new docker image

* Fix broken test

* Use new docker image in ruby26 test

* Install ruby for mac
2019-01-03 14:25:50 -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
Mikhail Morgunov
cb7678ebb9 Actualizing RubyGems link in README.md (#5378) 2018-11-19 13:38:12 -08:00
Toby Hsieh
59133296a6 Fix most of the unused variable warnings in Ruby tests (#5313)
* Fix most of the unused variable warnings in Ruby tests

* Add encoded_field_b back in tests/common_tests.rb
2018-11-18 00:06:39 -08:00
Toby Hsieh
63d2f3bc80 Fix RepeatedField#first in Ruby gem (#5293)
Given an argument, the previous implementation was off by one
(`.first(2)` would return 3 elements) compared to the `Enumerable#first`
method.
2018-10-29 11:32:50 -07:00
micw523
0038ff49af Remove Debug Statement for Win/MinGW (#5283) 2018-10-23 12:50:57 -07:00
Paul Yang
333b3ceab6
Add ruby 2.3, 2.4 and 2.5 test for linux. (#5256)
* Add ruby 2.3, 2.4 and 2.5 test for linux.

* Update kokoro files

* Add back commented gc test

* Fix gc_test failure

* Remove unused code

* Update ruby 2.5.0 to 2.5.1

* Update ruby 2.3 to 2.3.8

* Remove useless comment
2018-10-18 11:16:55 -07:00
Paul Yang
a0da84bff4
Fix broken ruby test (#5235)
* Replace assert_true/assert_false with assert, because they are not provided in newer version of test/unit

* Use rescue to handle exception subclass

* Commented out the require that caused gc_test failure.

* Commented out test

* Fix typo
2018-10-08 13:16:56 -07:00
Joshua Haberman
19ef4ab1c2
Merge pull request #4816 from hrsht/hrsht/zanker-proto2
Basic Proto2 support for Ruby gem
2018-09-27 15:23:10 -07: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
Feng Xiao
afe98de32a Replace repo links. 2018-08-22 11:55:30 -07:00
Adam Cozzette
94d55e5292 Merge branch '3.6.x' into merge-3-6-x 2018-08-01 13:44:55 -07:00
Adam Cozzette
9e1286b949 Updated version numbers to 3.6.1 2018-07-27 13:30:28 -07:00
Paul Yang
e508fc0c66
Check the message to be encoded is the wrong type. (#4885) (#4949)
* Check the message to be encoded is the wrong type. (#4885)

* Change TypeError to ArgumentError
2018-07-23 11:05:28 -07:00
Paul Yang
8356d270a5 Add continuous test for ruby 2.3, 2.4 and 2.5 (#4829)
* Add continuous test for ruby 2.3, 2.4 and 2.5

* Change ruby 2.5 to 2.5.0

* No need to provide argument to rb_funcall when argc is 0

* Fix tests for ruby 2.5

* Use rescue instead of assert_raise to accept subclass of error
2018-07-17 17:34:25 -07:00
Paul Yang
40f9ef2f56
Check the message to be encoded is the wrong type. (#4885) 2018-07-12 11:04:29 -07:00
Paul Yang
78ba021b84
Add continuous test for ruby 2.3, 2.4 and 2.5 (#4829)
* Add continuous test for ruby 2.3, 2.4 and 2.5

* Change ruby 2.5 to 2.5.0

* No need to provide argument to rb_funcall when argc is 0

* Fix tests for ruby 2.5

* Use rescue instead of assert_raise to accept subclass of error
2018-07-02 15:11:36 -07:00
Joshua Haberman
59e04d80cc
Merge pull request #4321 from devwout/ruby_json_omit_repeated
Ruby JSON encoding omits zero-length repeated fields by default.
2018-07-02 14:00:05 -07:00
Joshua Haberman
e00266a74e
Merge pull request #3847 from FX-HAO/master
Google::Protobuf::Struct can access a missing key (#3846)
2018-07-02 13:56:25 -07: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
Adam Cozzette
82d3d7d250 Merge branch '3.6.x' into merge-3-6-x 2018-06-25 13:22:10 -07:00
Paul Yang
f7ada1280f
Build ruby gem on kokoro (#4819)
* Install rake compiler

* Add kokoro config to build ruby gem on linux

* Rename from linix to linux

* Fix prepare_build.sh name

* Clean up

* Install bundler

* Install bundler

* Use c99 in order to build gem on mingw-32 on ruby 2.0.0

See https://github.com/rake-compiler/rake-compiler-dock/issues/4

* Move c99 config to extcofig.rb
2018-06-25 11:14:49 -07:00
igorpeshansky
944693c44c Add Google::Protobuf::Any.pack convenience class method. (#4719) 2018-06-19 13:26:41 -07:00
Erik Benoist
c19fcee48f Allows the json marshaller to be passed json marshal options (#4252) 2018-05-25 13:03:30 -07:00
Paul Yang
5289ee0c21 Adopt ruby_package in ruby generated code. (#4627)
* Adopt ruby_package in ruby generated code.

* Add test for ruby_package
2018-05-25 13:02:59 -07:00
Erik Benoist
a8e2359329 Allows the json marshaller to be passed json marshal options (#4252) 2018-05-22 08:14:04 -07:00
Paul Yang
9ccc3e536c
Adopt ruby_package in ruby generated code. (#4627)
* Adopt ruby_package in ruby generated code.

* Add test for ruby_package
2018-05-17 17:11:06 -07:00
Jisi Liu
45eb28b588 Update version number to 3.6.0 2018-05-14 16:06:22 -07:00
Stuart Campbell
05c2d01b61 Fix RepeatedField#delete_if (#4292)
Make RepeatedField#delete_if consistent with Array#delete_if.
2018-04-30 16:04:13 -07:00
Jisi Liu
9972e1608e Set ext.no_native = true for non mac platform
From:
https://github.com/rake-compiler/rake-compiler/issues/146#issuecomment-368539245
2018-04-25 09:52:30 -07:00