Class: Protobuf::CodeGenerator
- Inherits:
-
Object
- Object
- Protobuf::CodeGenerator
- Defined in:
- lib/protobuf/code_generator.rb
Constant Summary collapse
- CodeGeneratorFatalError =
Class.new(RuntimeError)
Class Method Summary collapse
Instance Method Summary collapse
- #generate_file(file_descriptor) ⇒ Object
-
#initialize(request_bytes) ⇒ CodeGenerator
constructor
A new instance of CodeGenerator.
- #response_bytes ⇒ Object
Constructor Details
#initialize(request_bytes) ⇒ CodeGenerator
Returns a new instance of CodeGenerator.
27 28 29 |
# File 'lib/protobuf/code_generator.rb', line 27 def initialize(request_bytes) self.request = ::Google::Protobuf::Compiler::CodeGeneratorRequest.decode(request_bytes) end |
Class Method Details
.fatal(message) ⇒ Object
8 9 10 |
# File 'lib/protobuf/code_generator.rb', line 8 def self.fatal() fail CodeGeneratorFatalError, end |
.print_tag_warning_suppress ⇒ Object
12 13 14 15 |
# File 'lib/protobuf/code_generator.rb', line 12 def self.print_tag_warning_suppress STDERR.puts "Suppress tag warning output with PB_NO_TAG_WARNINGS=1." def self.print_tag_warning_suppress; end end |
.warn(message) ⇒ Object
17 18 19 |
# File 'lib/protobuf/code_generator.rb', line 17 def self.warn() STDERR.puts("[WARN] #{}") end |
Instance Method Details
#generate_file(file_descriptor) ⇒ Object
31 32 33 |
# File 'lib/protobuf/code_generator.rb', line 31 def generate_file(file_descriptor) ::Protobuf::Generators::FileGenerator.new(file_descriptor).generate_output_file end |
#response_bytes ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/protobuf/code_generator.rb', line 35 def response_bytes generated_files = request.proto_file.map do |file_descriptor| generate_file(file_descriptor) end ::Google::Protobuf::Compiler::CodeGeneratorResponse.encode(:file => generated_files) end |