Class: Gapic::Schema::File

Inherits:
Proto
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gapic/schema/wrappers.rb

Overview

Wrapper for a protobuf file.

Instance Attribute Summary collapse

Attributes inherited from Proto

#address, #descriptor, #docs, #parent

Instance Method Summary collapse

Methods inherited from Proto

#containing_api, #docs_leading_comments, #leading_comments, #leading_detached_comments, #path, #span, #trailing_comments

Constructor Details

#initialize(descriptor, address, docs, messages, enums, services, resources, generate, registry) ⇒ File

Initializes a message object.

Parameters:

  • descriptor (Google::Protobuf::DescriptorProto)

    the protobuf representation of this service.

  • address (Enumerable<String>)

    The address of the proto. See

    address for more info.

  • docs (Google::Protobuf::SourceCodeInfo::Location)

    The docs of the proto. See #docs for more info.

  • messages (Enumerable<Message>)

    The top level messages of this file.

  • enums (Enumerable<Enum>)

    The top level enums of this file.

  • services (Enumerable<Service>)

    The services of this file.

  • resources (Enumerable<Resource>)

    The resources from this file.

  • generate (Boolean)

    Whether this file should be generated.



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/gapic/schema/wrappers.rb', line 450

def initialize descriptor, address, docs, messages, enums, services,
               resources, generate, registry
  super descriptor, address, docs
  @messages = messages || []
  @enums = enums || []
  @services = services || []
  @resources = resources || []
  @generate = generate
  @registry = registry

  # Apply parent
  @messages.each { |m| m.parent = self }
  @enums.each { |m| m.parent = self }
  @services.each { |m| m.parent = self }
  @resources.each { |m| m.parent = self }
end

Instance Attribute Details

#enumsEnumerable<Enum> (readonly)

Returns The top level enums contained in this file.

Returns:

  • (Enumerable<Enum>)

    The top level enums contained in this file.



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/gapic/schema/wrappers.rb', line 428

class File < Proto
  extend Forwardable

  attr_reader :messages
  attr_reader :enums
  attr_reader :services
  attr_reader :resources
  attr_reader :registry

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param messages [Enumerable<Message>] The top level messages of this
  #   file.
  # @param enums [Enumerable<Enum>] The top level enums of this file.
  # @param services [Enumerable<Service>] The services of this file.
  # @param resources [Enumerable<Resource>] The resources from this file.
  # @param generate [Boolean] Whether this file should be generated.
  def initialize descriptor, address, docs, messages, enums, services,
                 resources, generate, registry
    super descriptor, address, docs
    @messages = messages || []
    @enums = enums || []
    @services = services || []
    @resources = resources || []
    @generate = generate
    @registry = registry

    # Apply parent
    @messages.each { |m| m.parent = self }
    @enums.each { |m| m.parent = self }
    @services.each { |m| m.parent = self }
    @resources.each { |m| m.parent = self }
  end

  def containing_file
    self
  end

  def lookup address
    address = address.split(".").reject(&:empty?).join(".")
    @registry[address]
  end

  def generate?
    @generate
  end

  # @return [String] Ruby Package
  def ruby_package
    options[:ruby_package] if options
  end

  # @!method name
  #   @return [String] file name, relative to root of source tree.
  # @!method package
  #   @return [String] package of the file. e.g. "foo", "foo.bar", etc.
  # @!method dependency
  #   @return [Array<String>] Names of files imported by this file.
  # @!method public_dependency
  #   @return [Array<Integer>] Indexes of the public imported files in the
  #     dependency list returned by #dependency.
  # @!method options
  #   @return [Google::Protobuf::FileOptions] the options of this file.
  def_delegators(
    :descriptor,
    :name,
    :package,
    :dependency,
    :public_dependency,
    :options
  )
end

#messagesEnumerable<Message> (readonly)

Returns The top level messages contained in this file.

Returns:

  • (Enumerable<Message>)

    The top level messages contained in this file.



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/gapic/schema/wrappers.rb', line 428

class File < Proto
  extend Forwardable

  attr_reader :messages
  attr_reader :enums
  attr_reader :services
  attr_reader :resources
  attr_reader :registry

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param messages [Enumerable<Message>] The top level messages of this
  #   file.
  # @param enums [Enumerable<Enum>] The top level enums of this file.
  # @param services [Enumerable<Service>] The services of this file.
  # @param resources [Enumerable<Resource>] The resources from this file.
  # @param generate [Boolean] Whether this file should be generated.
  def initialize descriptor, address, docs, messages, enums, services,
                 resources, generate, registry
    super descriptor, address, docs
    @messages = messages || []
    @enums = enums || []
    @services = services || []
    @resources = resources || []
    @generate = generate
    @registry = registry

    # Apply parent
    @messages.each { |m| m.parent = self }
    @enums.each { |m| m.parent = self }
    @services.each { |m| m.parent = self }
    @resources.each { |m| m.parent = self }
  end

  def containing_file
    self
  end

  def lookup address
    address = address.split(".").reject(&:empty?).join(".")
    @registry[address]
  end

  def generate?
    @generate
  end

  # @return [String] Ruby Package
  def ruby_package
    options[:ruby_package] if options
  end

  # @!method name
  #   @return [String] file name, relative to root of source tree.
  # @!method package
  #   @return [String] package of the file. e.g. "foo", "foo.bar", etc.
  # @!method dependency
  #   @return [Array<String>] Names of files imported by this file.
  # @!method public_dependency
  #   @return [Array<Integer>] Indexes of the public imported files in the
  #     dependency list returned by #dependency.
  # @!method options
  #   @return [Google::Protobuf::FileOptions] the options of this file.
  def_delegators(
    :descriptor,
    :name,
    :package,
    :dependency,
    :public_dependency,
    :options
  )
end

#registryObject (readonly)

Returns the value of attribute registry.



435
436
437
# File 'lib/gapic/schema/wrappers.rb', line 435

def registry
  @registry
end

#resourcesEnumerable<Resource> (readonly)

Returns The top level resources contained in this file.

Returns:

  • (Enumerable<Resource>)

    The top level resources contained in this file.



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/gapic/schema/wrappers.rb', line 428

class File < Proto
  extend Forwardable

  attr_reader :messages
  attr_reader :enums
  attr_reader :services
  attr_reader :resources
  attr_reader :registry

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param messages [Enumerable<Message>] The top level messages of this
  #   file.
  # @param enums [Enumerable<Enum>] The top level enums of this file.
  # @param services [Enumerable<Service>] The services of this file.
  # @param resources [Enumerable<Resource>] The resources from this file.
  # @param generate [Boolean] Whether this file should be generated.
  def initialize descriptor, address, docs, messages, enums, services,
                 resources, generate, registry
    super descriptor, address, docs
    @messages = messages || []
    @enums = enums || []
    @services = services || []
    @resources = resources || []
    @generate = generate
    @registry = registry

    # Apply parent
    @messages.each { |m| m.parent = self }
    @enums.each { |m| m.parent = self }
    @services.each { |m| m.parent = self }
    @resources.each { |m| m.parent = self }
  end

  def containing_file
    self
  end

  def lookup address
    address = address.split(".").reject(&:empty?).join(".")
    @registry[address]
  end

  def generate?
    @generate
  end

  # @return [String] Ruby Package
  def ruby_package
    options[:ruby_package] if options
  end

  # @!method name
  #   @return [String] file name, relative to root of source tree.
  # @!method package
  #   @return [String] package of the file. e.g. "foo", "foo.bar", etc.
  # @!method dependency
  #   @return [Array<String>] Names of files imported by this file.
  # @!method public_dependency
  #   @return [Array<Integer>] Indexes of the public imported files in the
  #     dependency list returned by #dependency.
  # @!method options
  #   @return [Google::Protobuf::FileOptions] the options of this file.
  def_delegators(
    :descriptor,
    :name,
    :package,
    :dependency,
    :public_dependency,
    :options
  )
end

#servicesEnumerable<Service> (readonly)

Returns The services contained in this file.

Returns:

  • (Enumerable<Service>)

    The services contained in this file.



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/gapic/schema/wrappers.rb', line 428

class File < Proto
  extend Forwardable

  attr_reader :messages
  attr_reader :enums
  attr_reader :services
  attr_reader :resources
  attr_reader :registry

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param messages [Enumerable<Message>] The top level messages of this
  #   file.
  # @param enums [Enumerable<Enum>] The top level enums of this file.
  # @param services [Enumerable<Service>] The services of this file.
  # @param resources [Enumerable<Resource>] The resources from this file.
  # @param generate [Boolean] Whether this file should be generated.
  def initialize descriptor, address, docs, messages, enums, services,
                 resources, generate, registry
    super descriptor, address, docs
    @messages = messages || []
    @enums = enums || []
    @services = services || []
    @resources = resources || []
    @generate = generate
    @registry = registry

    # Apply parent
    @messages.each { |m| m.parent = self }
    @enums.each { |m| m.parent = self }
    @services.each { |m| m.parent = self }
    @resources.each { |m| m.parent = self }
  end

  def containing_file
    self
  end

  def lookup address
    address = address.split(".").reject(&:empty?).join(".")
    @registry[address]
  end

  def generate?
    @generate
  end

  # @return [String] Ruby Package
  def ruby_package
    options[:ruby_package] if options
  end

  # @!method name
  #   @return [String] file name, relative to root of source tree.
  # @!method package
  #   @return [String] package of the file. e.g. "foo", "foo.bar", etc.
  # @!method dependency
  #   @return [Array<String>] Names of files imported by this file.
  # @!method public_dependency
  #   @return [Array<Integer>] Indexes of the public imported files in the
  #     dependency list returned by #dependency.
  # @!method options
  #   @return [Google::Protobuf::FileOptions] the options of this file.
  def_delegators(
    :descriptor,
    :name,
    :package,
    :dependency,
    :public_dependency,
    :options
  )
end

Instance Method Details

#containing_fileObject



467
468
469
# File 'lib/gapic/schema/wrappers.rb', line 467

def containing_file
  self
end

#dependencyArray<String>

Returns Names of files imported by this file.

Returns:

  • (Array<String>)

    Names of files imported by this file.



496
497
498
499
500
501
502
503
# File 'lib/gapic/schema/wrappers.rb', line 496

def_delegators(
  :descriptor,
  :name,
  :package,
  :dependency,
  :public_dependency,
  :options
)

#generate?Boolean

Returns:

  • (Boolean)


476
477
478
# File 'lib/gapic/schema/wrappers.rb', line 476

def generate?
  @generate
end

#lookup(address) ⇒ Object



471
472
473
474
# File 'lib/gapic/schema/wrappers.rb', line 471

def lookup address
  address = address.split(".").reject(&:empty?).join(".")
  @registry[address]
end

#nameString

Returns file name, relative to root of source tree.

Returns:

  • (String)

    file name, relative to root of source tree.



496
497
498
499
500
501
502
503
# File 'lib/gapic/schema/wrappers.rb', line 496

def_delegators(
  :descriptor,
  :name,
  :package,
  :dependency,
  :public_dependency,
  :options
)

#optionsGoogle::Protobuf::FileOptions

Returns the options of this file.

Returns:



496
497
498
499
500
501
502
503
# File 'lib/gapic/schema/wrappers.rb', line 496

def_delegators(
  :descriptor,
  :name,
  :package,
  :dependency,
  :public_dependency,
  :options
)

#packageString

Returns package of the file. e.g. "foo", "foo.bar", etc.

Returns:

  • (String)

    package of the file. e.g. "foo", "foo.bar", etc.



496
497
498
499
500
501
502
503
# File 'lib/gapic/schema/wrappers.rb', line 496

def_delegators(
  :descriptor,
  :name,
  :package,
  :dependency,
  :public_dependency,
  :options
)

#public_dependencyArray<Integer>

Returns Indexes of the public imported files in the dependency list returned by #dependency.

Returns:

  • (Array<Integer>)

    Indexes of the public imported files in the dependency list returned by #dependency.



496
497
498
499
500
501
502
503
# File 'lib/gapic/schema/wrappers.rb', line 496

def_delegators(
  :descriptor,
  :name,
  :package,
  :dependency,
  :public_dependency,
  :options
)

#ruby_packageString

Returns Ruby Package.

Returns:

  • (String)

    Ruby Package



481
482
483
# File 'lib/gapic/schema/wrappers.rb', line 481

def ruby_package
  options[:ruby_package] if options
end