aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/ruby/ruby_generator.cc
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2016-07-25 01:47:50 -0700
committerJosh Haberman <jhaberman@gmail.com>2016-07-25 11:09:23 -0700
commit4f19797baf1c874c3aa03202908178ec66d7b45c (patch)
tree7575437da2c68f8b89aa0e47883e5c0674f59b3e /src/google/protobuf/compiler/ruby/ruby_generator.cc
parent06220303323f3cce425706540defcd7a29d42ec2 (diff)
downloadprotobuf-4f19797baf1c874c3aa03202908178ec66d7b45c.tar.gz
protobuf-4f19797baf1c874c3aa03202908178ec66d7b45c.tar.bz2
protobuf-4f19797baf1c874c3aa03202908178ec66d7b45c.zip
Ruby: generated foo.proto -> foo_pb.rb instead of foo.rb.
This brings us more into line with other langauges, and makes it more obvious when we are requiring protobuf generated code.
Diffstat (limited to 'src/google/protobuf/compiler/ruby/ruby_generator.cc')
-rw-r--r--src/google/protobuf/compiler/ruby/ruby_generator.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc
index 92c76fb0..8813aec7 100644
--- a/src/google/protobuf/compiler/ruby/ruby_generator.cc
+++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc
@@ -48,7 +48,7 @@ namespace ruby {
// Forward decls.
std::string IntToString(int32 value);
-std::string StripDotProto(const std::string& proto_file);
+std::string GetRequireName(const std::string& proto_file);
std::string LabelForField(google::protobuf::FieldDescriptor* field);
std::string TypeName(google::protobuf::FieldDescriptor* field);
void GenerateMessage(const google::protobuf::Descriptor* message,
@@ -70,13 +70,13 @@ std::string IntToString(int32 value) {
return os.str();
}
-std::string StripDotProto(const std::string& proto_file) {
+std::string GetRequireName(const std::string& proto_file) {
int lastindex = proto_file.find_last_of(".");
- return proto_file.substr(0, lastindex);
+ return proto_file.substr(0, lastindex) + "_pb";
}
std::string GetOutputFilename(const std::string& proto_file) {
- return StripDotProto(proto_file) + ".rb";
+ return GetRequireName(proto_file) + ".rb";
}
std::string LabelForField(const google::protobuf::FieldDescriptor* field) {
@@ -391,7 +391,7 @@ bool MaybeEmitDependency(const FileDescriptor* import,
return true;
} else {
printer->Print(
- "require '$name$'\n", "name", StripDotProto(import->name()));
+ "require '$name$'\n", "name", GetRequireName(import->name()));
return true;
}
}