Sha256: 29a2f17dacf055007166888080db7b2c3b4d14b876ec46c2a84f7c7a3dcf5448

Contents?: true

Size: 1.02 KB

Versions: 26

Compression:

Stored size: 1.02 KB

Contents

require 'protobuf/generators/file_generator'

module Protobuf
  class CodeGenerator

    CodeGeneratorFatalError = Class.new(RuntimeError)

    def self.fatal(message)
      fail 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

    private

    attr_accessor :request

    public

    def initialize(request_bytes)
      self.request = ::Google::Protobuf::Compiler::CodeGeneratorRequest.decode(request_bytes)
    end

    def generate_file(file_descriptor)
      ::Protobuf::Generators::FileGenerator.new(file_descriptor).generate_output_file
    end

    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

  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
protobuf-core-3.5.0 lib/protobuf/code_generator.rb
protobuf-3.6.12 lib/protobuf/code_generator.rb
protobuf-3.6.11 lib/protobuf/code_generator.rb
protobuf-3.6.10 lib/protobuf/code_generator.rb
protobuf-3.7.0.pre2 lib/protobuf/code_generator.rb
protobuf-3.6.9 lib/protobuf/code_generator.rb
protobuf-3.7.0.pre1 lib/protobuf/code_generator.rb
protobuf-3.7.0.pre0 lib/protobuf/code_generator.rb
protobuf-3.6.7 lib/protobuf/code_generator.rb
protobuf-3.6.6 lib/protobuf/code_generator.rb
protobuf-3.6.2 lib/protobuf/code_generator.rb
protobuf-3.6.1 lib/protobuf/code_generator.rb
protobuf-3.6.0 lib/protobuf/code_generator.rb
protobuf-3.5.5 lib/protobuf/code_generator.rb
protobuf-3.5.4 lib/protobuf/code_generator.rb
protobuf-3.5.3 lib/protobuf/code_generator.rb
protobuf-3.5.2 lib/protobuf/code_generator.rb
protobuf-3.5.1 lib/protobuf/code_generator.rb
prepor-protobuf-3.5.1 lib/protobuf/code_generator.rb
prepor-protobuf-3.5.0 lib/protobuf/code_generator.rb