Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ruby module name generation when the ruby_package option is used #5735

Merged
merged 3 commits into from
Feb 28, 2019

Conversation

jbolinger
Copy link
Contributor

Resolves #5584 by ensure that the Ruby module name is always generated in the following format:

module A
  module B
    # ....

instead of:

module A::B

I also added some tests for the ruby_package option.

@TeBoring TeBoring self-requested a review February 16, 2019 02:06
@TeBoring TeBoring self-assigned this Feb 16, 2019
@@ -2,6 +2,6 @@ syntax = "proto3";

package foo_bar;

option ruby_package = "A.B";
option ruby_package = "A::B";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change the existing API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort of, but I think the original implementation was incorrect.

In all other languages, the package options follow the same format as the language and :: is the correct delimiter in Ruby.

For example, this proto has a bunch of language package options defined: https://github.com/googleapis/googleapis/blob/1a4f0f12777dc2f8bf2c2ce84438329639c75e29/google/pubsub/v1/pubsub.proto#L33

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this break existing users?
If so, can we support both for now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in protoc, we can throw warning if "A.B" is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supporting both options sounds like a good solution. I've updated it to work with both and issue a warning if the A.B form is used instead of A::B.

@TeBoring TeBoring added the ruby label Feb 16, 2019
@TeBoring TeBoring merged commit 9638dcc into protocolbuffers:master Feb 28, 2019
TeBoring added a commit that referenced this pull request Feb 28, 2019
jbolinger added a commit to jbolinger/protobuf that referenced this pull request Feb 28, 2019
@jbolinger jbolinger deleted the ruby-pkg-namespace branch February 28, 2019 21:32
TeBoring pushed a commit that referenced this pull request Mar 2, 2019
…(again) (#5794)

* Revert "Revert "Fix Ruby module name generation when the ruby_package option is used (#5735)""

This reverts commit bb211e8.

* add new files to Makefile.am
bithium pushed a commit to bithium/protobuf that referenced this pull request Sep 4, 2023
…rotocolbuffers#5735)

* fix module name generation and add tests

* fix existing tests

* support both package name styles
bithium pushed a commit to bithium/protobuf that referenced this pull request Sep 4, 2023
bithium pushed a commit to bithium/protobuf that referenced this pull request Sep 4, 2023
…(again) (protocolbuffers#5794)

* Revert "Revert "Fix Ruby module name generation when the ruby_package option is used (protocolbuffers#5735)""

This reverts commit bb211e8.

* add new files to Makefile.am
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants