Class: Gapic::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/gapic/runner.rb

Overview

TODO: Enter docs Dooooooooocs!!!

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Runner

Initializes the runner.



29
30
31
# File 'lib/gapic/runner.rb', line 29

def initialize request
  @request = request
end

Instance Attribute Details

#request ⇒ Object (readonly)

Returns the value of attribute request.



25
26
27
# File 'lib/gapic/runner.rb', line 25

def request
  @request
end

Class Method Details

.run(request, generator: nil) ⇒ Google::Protobuf::Compiler::CodeGeneratorResponse

Run protoc generation.

Parameters:

Returns:



59
60
61
# File 'lib/gapic/runner.rb', line 59

def self.run request, generator: nil
  new(request).run generator_type: generator
end

Instance Method Details

#run(generator_type: nil) ⇒ Google::Protobuf::Compiler::CodeGeneratorResponse

Run protoc generation.

Parameters:

  • generator_type (String) (defaults to: nil)

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gapic/runner.rb', line 36

def run generator_type: nil
  # Create an API Schema from the FileDescriptorProtos
  api = Gapic::Schema::Api.new request

  write_binary_file! api

  # Retrieve generator type from protoc_options if not already provided.
  generator_type ||= api.protoc_options["generator"]
  # Find the generator for the generator type.
  generator = Gapic::Generator.find generator_type

  # Create and run the generator from the API.
  output_files = generator.new(api).generate

  # Create and write the response
  Google::Protobuf::Compiler::CodeGeneratorResponse.new \
    file: output_files
end