Sha256: ad99095933fce431e940f03d653bcee5998593b047d0c7f9e7d372dcc5f6619e

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

module Protobuf
  module Descriptor
    class FileDescriptor
      class <<self
        def proto_type
          'Google::Protobuf::FileDescriptorProto'
        end

        def build(proto, opt={})
          mod = Object
          if package = proto.package and not package.empty?
            module_names = package.split '::'
            module_names.each do |module_name|
              mod = mod.const_set module_name, Module.new
            end
          end
          proto.message_type.each do |message_proto|
            Protobuf::Message.descriptor.build message_proto, :module => mod
          end
          proto.enum_type.each do |enum_proto|
            Protobuf::Enum.descriptor.build enum_proto, :module => mod
          end
        end

        def unbuild(messages)
          messages = [messages] unless messages.is_a? Array
          proto = Google::Protobuf::FileDescriptorProto.new
          proto.package = messages.first.to_s.split('::')[0..-2].join('::') if messages.first.to_s =~ /::/
          messages.each do |message|
            message.descriptor.unbuild proto
          end
          proto
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
protobuf-1.1.3 lib/protobuf/descriptor/file_descriptor.rb
protobuf-1.1.2 lib/protobuf/descriptor/file_descriptor.rb
protobuf-1.1.1 lib/protobuf/descriptor/file_descriptor.rb
protobuf-1.1.0.beta2 lib/protobuf/descriptor/file_descriptor.rb
protobuf-1.1.0.beta1 lib/protobuf/descriptor/file_descriptor.rb
protobuf-1.1.0.beta0 lib/protobuf/descriptor/file_descriptor.rb
protobuf-1.0.1 lib/protobuf/descriptor/file_descriptor.rb
protobuf-1.0.0 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.11 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.10 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.9 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.8 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.7 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.6 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.5 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.4 lib/protobuf/descriptor/file_descriptor.rb
ruby_protobuf-0.4.1 lib/protobuf/descriptor/file_descriptor.rb