I'd like to leverage this 
<https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/descriptor.proto#L36-L37>
 
to read a `.proto` file *in Ruby* and get a handle on the underlying 
`FileDescriptorProto` to do some validations. But it's not clear to me how 
to read the proto file into this object. 

I tried to read both the .proto file as well as the output of the 
`--descriptor_set_out`. Any guidance would be appreciated.

In bundle console:

// output of --descriptor_set_out dumped to set.txt
2.6.3 :114 > fl = 
File.open("/Users/shine.garg/1debitCode/plati-bus/prototypes/protobufs/set.txt",
 
"r")
 => 
#<File:/Users/shine.garg/1debitCode/plati-bus/prototypes/protobufs/set.txt>

2.6.3 :115 > Google::Protobuf::FileDescriptor.new(file: fl, package: 
"tutorial")
Traceback (most recent call last):
       16: from /Users/shine.garg/.rvm/gems/ruby-2.6.3/bin/bundle:23:in 
`<main>'
       15: from /Users/shine.garg/.rvm/gems/ruby-2.6.3/bin/bundle:23:in 
`load'
       14: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundle:22:in
 
`<top (required)>'
       13: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/friendly_errors.rb:124:in
 
`with_friendly_errors'
       12: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundle:30:in
 
`block in <top (required)>'
       11: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:18:in
 
`start'
       10: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in
 
`start'
        9: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:27:in
 
`dispatch'
        8: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in
 
`dispatch'
        7: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in
 
`invoke_command'
        6: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in
 
`run'
        5: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/cli.rb:494:in
 
`console'
        4: from 
/Users/shine.garg/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/bundler/cli/console.rb:19:in
 
`run'
        3: from (irb):115
        2: from (irb):115:in `new'
        1: from (irb):115:in `initialize'
ArgumentError (wrong number of arguments (given 1, expected 3))

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/7004c516-c3f2-4862-933d-de69d8b57a3fn%40googlegroups.com.

Reply via email to