Module: Twirp::ProtocPlugin
- Defined in:
- lib/twirp/protoc_plugin/process.rb,
lib/twirp/protoc_plugin/version.rb,
lib/twirp/protoc_plugin/code_generator.rb
Defined Under Namespace
Classes: CodeGenerator, Error
Constant Summary collapse
- VERSION =
"1.2.0"
Class Method Summary collapse
-
.process(input) ⇒ String
An encoded [Google::Protobuf::Compiler::CodeGeneratorResponse] message.
Class Method Details
.process(input) ⇒ String
Returns an encoded [Google::Protobuf::Compiler::CodeGeneratorResponse] message.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/twirp/protoc_plugin/process.rb', line 18 def process(input) request = Google::Protobuf::Compiler::CodeGeneratorRequest.decode(input) = (request.parameter) response = Google::Protobuf::Compiler::CodeGeneratorResponse.new response.supported_features = Google::Protobuf::Compiler::CodeGeneratorResponse::Feature::FEATURE_PROTO3_OPTIONAL request.proto_file.each do |proto_file| # proto_file: <Google::Protobuf::FileDescriptorProto> next unless request.file_to_generate.include?(proto_file.name) next unless proto_file.has_service? # do not generate when no services defined file = Google::Protobuf::Compiler::CodeGeneratorResponse::File.new file.name = proto_file.twirp_output_filename file.content = CodeGenerator.new(proto_file, proto_file.relative_ruby_protobuf_name, ).generate response.file << file end response.to_proto end |