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

Converting snake_case_modules into CamelCaseModules #405

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace :compile do
task :spec do
proto_path = ::File.expand_path('../spec/support/', __FILE__)
proto_files = Dir[File.join(proto_path, '**', '*.proto')]
cmd = %(protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{proto_path} -I #{proto_path} #{proto_files.join(' ')})
cmd = %(protoc --plugin=protoc-gen-ruby-protobuf=./bin/protoc-gen-ruby --ruby-protobuf_out=#{proto_path} -I #{proto_path} #{proto_files.join(' ')})

puts cmd
system(cmd)
Expand All @@ -35,7 +35,7 @@ namespace :compile do
output_dir = ::File.expand_path('../tmp/rpc', __FILE__)
::FileUtils.mkdir_p(output_dir)

cmd = %(protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{output_dir} -I #{proto_path} #{proto_files.join(' ')})
cmd = %(protoc --plugin=protoc-gen-ruby-protobuf=./bin/protoc-gen-ruby --ruby-protobuf_out=#{output_dir} -I #{proto_path} #{proto_files.join(' ')})

puts cmd
system(cmd)
Expand Down
11 changes: 5 additions & 6 deletions lib/protobuf/generators/printable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ def indent
# as a constant. Otherwise we do not attempt to change the
# token's definition.
#
# modulize("foo.bar.Baz") -> "::Foo::Bar::Baz"
# modulize("foo.bar.baz") -> "::Foo::Bar::Baz"
# modulize("foo.bar.BAZ") -> "::Foo::Bar::BAZ"
# modulize("foo.bar.Baz") -> "::Foo::Bar::Baz"
# modulize("foo.bar.baz") -> "::Foo::Bar::Baz"
# modulize("foo.bar.baz_boy") -> "::Foo::Bar::BazBoy"
# modulize("foo.bar.BAZ") -> "::Foo::Bar::BAZ"
#
def modulize(name)
name = name.gsub(/\./, '::')
name = name.gsub(/(^(?:::)?[a-z]|::[a-z])/, &:upcase)
name
name.split('.').map(&:camelize).join('::')
end

# Decrease the indent level. Cannot be negative.
Expand Down
52 changes: 26 additions & 26 deletions spec/encoding/all_types_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

RSpec.describe ::Protobuf do
it "correctly encodes all types" do
message = Protobuf_unittest::TestAllTypes.new(
message = ProtobufUnittest::TestAllTypes.new(
:optional_int32 => 101,
:optional_int64 => 102,
:optional_uint32 => 103,
Expand All @@ -19,16 +19,16 @@
:optional_bool => true,
:optional_string => "115",
:optional_bytes => "116",
:optional_nested_message => Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 118),
:optional_foreign_message => Protobuf_unittest::ForeignMessage.new(:c => 119),
:optional_import_message => Protobuf_unittest_import::ImportMessage.new(:d => 120),
:optional_nested_enum => Protobuf_unittest::TestAllTypes::NestedEnum::BAZ,
:optional_foreign_enum => Protobuf_unittest::ForeignEnum::FOREIGN_BAZ,
:optional_import_enum => Protobuf_unittest_import::ImportEnum::IMPORT_BAZ,
:optional_nested_message => ProtobufUnittest::TestAllTypes::NestedMessage.new(:bb => 118),
:optional_foreign_message => ProtobufUnittest::ForeignMessage.new(:c => 119),
:optional_import_message => ProtobufUnittestImport::ImportMessage.new(:d => 120),
:optional_nested_enum => ProtobufUnittest::TestAllTypes::NestedEnum::BAZ,
:optional_foreign_enum => ProtobufUnittest::ForeignEnum::FOREIGN_BAZ,
:optional_import_enum => ProtobufUnittestImport::ImportEnum::IMPORT_BAZ,
:optional_string_piece => "124",
:optional_cord => "125",
:optional_public_import_message => Protobuf_unittest_import::PublicImportMessage.new(:e => 126),
:optional_lazy_message => Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 127),
:optional_public_import_message => ProtobufUnittestImport::PublicImportMessage.new(:e => 126),
:optional_lazy_message => ProtobufUnittest::TestAllTypes::NestedMessage.new(:bb => 127),
:repeated_int32 => [201, 301],
:repeated_int64 => [202, 302],
:repeated_uint32 => [203, 303],
Expand All @@ -45,34 +45,34 @@
:repeated_string => ["215", "315"],
:repeated_bytes => ["216", "316"],
:repeated_nested_message => [
::Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 218),
::Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 318),
::ProtobufUnittest::TestAllTypes::NestedMessage.new(:bb => 218),
::ProtobufUnittest::TestAllTypes::NestedMessage.new(:bb => 318),
],
:repeated_foreign_message => [
::Protobuf_unittest::ForeignMessage.new(:c => 219),
::Protobuf_unittest::ForeignMessage.new(:c => 319),
::ProtobufUnittest::ForeignMessage.new(:c => 219),
::ProtobufUnittest::ForeignMessage.new(:c => 319),
],
:repeated_import_message => [
::Protobuf_unittest_import::ImportMessage.new(:d => 220),
::Protobuf_unittest_import::ImportMessage.new(:d => 320),
::ProtobufUnittestImport::ImportMessage.new(:d => 220),
::ProtobufUnittestImport::ImportMessage.new(:d => 320),
],
:repeated_nested_enum => [
::Protobuf_unittest::TestAllTypes::NestedEnum::BAR,
::Protobuf_unittest::TestAllTypes::NestedEnum::BAZ,
::ProtobufUnittest::TestAllTypes::NestedEnum::BAR,
::ProtobufUnittest::TestAllTypes::NestedEnum::BAZ,
],
:repeated_foreign_enum => [
::Protobuf_unittest::ForeignEnum::FOREIGN_BAR,
::Protobuf_unittest::ForeignEnum::FOREIGN_BAZ,
::ProtobufUnittest::ForeignEnum::FOREIGN_BAR,
::ProtobufUnittest::ForeignEnum::FOREIGN_BAZ,
],
:repeated_import_enum => [
::Protobuf_unittest_import::ImportEnum::IMPORT_BAR,
::Protobuf_unittest_import::ImportEnum::IMPORT_BAZ,
::ProtobufUnittestImport::ImportEnum::IMPORT_BAR,
::ProtobufUnittestImport::ImportEnum::IMPORT_BAZ,
],
:repeated_string_piece => ["224", "324"],
:repeated_cord => ["225", "325"],
:repeated_lazy_message => [
::Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 227),
::Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 327),
::ProtobufUnittest::TestAllTypes::NestedMessage.new(:bb => 227),
::ProtobufUnittest::TestAllTypes::NestedMessage.new(:bb => 327),
],
:default_int32 => 401,
:default_int64 => 402,
Expand All @@ -89,9 +89,9 @@
:default_bool => false,
:default_string => "415",
:default_bytes => "416",
:default_nested_enum => ::Protobuf_unittest::TestAllTypes::NestedEnum::FOO,
:default_foreign_enum => ::Protobuf_unittest::ForeignEnum::FOREIGN_FOO,
:default_import_enum => ::Protobuf_unittest_import::ImportEnum::IMPORT_FOO,
:default_nested_enum => ::ProtobufUnittest::TestAllTypes::NestedEnum::FOO,
:default_foreign_enum => ::ProtobufUnittest::ForeignEnum::FOREIGN_FOO,
:default_import_enum => ::ProtobufUnittestImport::ImportEnum::IMPORT_FOO,
:default_string_piece => "424",
:default_cord => "425",
)
Expand Down
Binary file modified spec/encoding/extreme_values_spec.rb
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/lib/protobuf/generators/file_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module Foo

module Test
module Pkg
module File_generator_spec
module FileGeneratorSpec
::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }

##
Expand Down
Loading