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.
21 22 23 24 |
# File 'lib/protobuf/code_generator.rb', line 21 def initialize(request_bytes) @request = ::Google::Protobuf::Compiler::CodeGeneratorRequest.decode(request_bytes) @generated_files = [] end |
Class Method Details
.fatal(message) ⇒ Object
8 9 10 |
# File 'lib/protobuf/code_generator.rb', line 8 def self.fatal() raise 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
26 27 28 29 |
# File 'lib/protobuf/code_generator.rb', line 26 def generate_file(file_descriptor) file_generator = ::Protobuf::Generators::FileGenerator.new(file_descriptor) @generated_files << file_generator.generate_output_file end |
#response_bytes ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/protobuf/code_generator.rb', line 31 def response_bytes @request.proto_file.each do |file_descriptor| generate_file(file_descriptor) end return ::Google::Protobuf::Compiler::CodeGeneratorResponse.encode(:file => @generated_files) end |