Sha256: 83a253b0c1cdd76056a4af0a183ee0b7cc3ec1e246e94a758894f4d55638a745

Contents?: true

Size: 1.04 KB

Versions: 38

Compression:

Stored size: 1.04 KB

Contents

require 'protobuf/generators/file_generator'

module Protobuf
  class CodeGenerator

    CodeGeneratorFatalError = Class.new(RuntimeError)

    def self.fatal(message)
      raise CodeGeneratorFatalError, message
    end

    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

    def self.warn(message)
      STDERR.puts("[WARN] #{message}")
    end

    def initialize(request_bytes)
      @request = ::Google::Protobuf::Compiler::CodeGeneratorRequest.decode(request_bytes)
      @generated_files = []
    end

    def generate_file(file_descriptor)
      file_generator = ::Protobuf::Generators::FileGenerator.new(file_descriptor)
      @generated_files << file_generator.generate_output_file
    end

    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

  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
protobuffy-3.6.0 lib/protobuf/code_generator.rb
protobuffy-3.5.1 lib/protobuf/code_generator.rb
protobuffy-3.4.0 lib/protobuf/code_generator.rb
protobuffy-3.3.0 lib/protobuf/code_generator.rb
protobuffy-3.2.0 lib/protobuf/code_generator.rb
protobuffy-3.1.0 lib/protobuf/code_generator.rb
protobuf-3.3.6 lib/protobuf/code_generator.rb
protobuf-3.3.5 lib/protobuf/code_generator.rb
protobuf-3.3.4 lib/protobuf/code_generator.rb
protobuf-3.3.3 lib/protobuf/code_generator.rb
protobuf-3.3.2 lib/protobuf/code_generator.rb
protobuf-3.3.1 lib/protobuf/code_generator.rb
protobuf-3.3.0 lib/protobuf/code_generator.rb
protobuf-3.2.1 lib/protobuf/code_generator.rb
protobuf-3.2.0 lib/protobuf/code_generator.rb
protobuf-3.1.0 lib/protobuf/code_generator.rb
protobuf-3.0.5 lib/protobuf/code_generator.rb
protobuf-3.0.4 lib/protobuf/code_generator.rb
protobuf-2.8.13 lib/protobuf/code_generator.rb
protobuf-3.0.3 lib/protobuf/code_generator.rb