Skip to content

Commit

Permalink
remove debug lines, change ruby version
Browse files Browse the repository at this point in the history
  • Loading branch information
vaidehi-figma committed Sep 10, 2024
1 parent 513fa81 commit 99af6c2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.2
3.2.4
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'

gem 'grpc-tools'
gem 'google-protobuf', require: 'google/protobuf'
gem "google-protobuf", "~> 3.25.3", require: 'google/protobuf'
8 changes: 2 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
GEM
remote: https://rubygems.org/
specs:
bigdecimal (3.1.8)
google-protobuf (4.27.3-arm64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (3.25.4-arm64-darwin)
grpc-tools (1.54.0)
rake (13.2.1)

PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23

DEPENDENCIES
google-protobuf
google-protobuf (~> 3.25.3)
grpc-tools

BUNDLED WITH
Expand Down
5 changes: 0 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package main

import (
"fmt"
"log"
"os"
"regexp"
"strings"
"text/template"
Expand Down Expand Up @@ -111,7 +109,6 @@ func (m *rbiModule) Execute(targets map[string]pgs.File, pkgs map[string]pgs.Pac
func (m *rbiModule) generate(f pgs.File) {
op := strings.TrimSuffix(f.InputPath().String(), ".proto") + "_pb.rbi"
m.hasEditions2023 = f.Descriptor().GetEdition() == descriptorpb.Edition_EDITION_2023
fmt.Fprintf(os.Stderr, "editions2023?: ", m.hasEditions2023)
m.AddGeneratorTemplateFile(op, m.tpl, f)
}

Expand Down Expand Up @@ -214,9 +211,7 @@ class {{ rubyMessageType . }}{{ if useAbstractMessage }} < ::Google::Protobuf::A
sig { void }
def clear_{{ .Name }}
end
# after clear
{{ if or (edition2023) (optional .) }}
# check did I get here
sig { returns(T::Boolean) }
def has_{{ .Name }}?
end
Expand Down
21 changes: 11 additions & 10 deletions testdata/required_field_test.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
require_relative "required_field_pb"
require_relative 'required_field_pb'

t = Thing.decode_json('{"foo": "foo", "bar": {}}')

puts "t.has_foo? #{!!t.has_foo?}"
puts "t.foo? #{t.foo}"
puts "t.has_bar? #{!!t.has_bar?}"
puts "t.bar #{t.bar}"
puts "t.has_optional_value? #{!!t.has_optional_value?}"
puts "t.class: #{t.class}"
puts "t.has_foo?: #{!!t.has_foo?}"
puts "t.foo?: #{t.foo}"
puts "t.has_bar?: #{!!t.has_bar?}"
puts "t.bar: #{t.bar}"
puts "t.has_optional_value?: #{!!t.has_optional_value?}"
puts "t.optional_value: #{t.optional_value}"
puts "t.bar.has_another_optional_value?: #{!!t.bar.has_another_optional_value?}"
puts "t.bar.another_optional_value: #{t.bar.another_optional_value}"

Google::Protobuf::DescriptorPool.generated_pool.lookup("required_field").get(Thing.descriptor.lookup("foo").options) == true
puts "foo, required_field?: #{Google::Protobuf::DescriptorPool.generated_pool.lookup('required_field').get(Thing.descriptor.lookup('foo').options) == true}"

Google::Protobuf::DescriptorPool.generated_pool.lookup("required_field").get(Thing.descriptor.lookup("bar").options) == true
puts "bar, required_field?: #{Google::Protobuf::DescriptorPool.generated_pool.lookup('required_field').get(Thing.descriptor.lookup('bar').options) == true}"

Google::Protobuf::DescriptorPool.generated_pool.lookup("required_field").get(Thing.descriptor.lookup("optional_value").options) == false
puts "optional_value, required_field?: #{Google::Protobuf::DescriptorPool.generated_pool.lookup('required_field').get(Thing.descriptor.lookup('optional_value').options) == true}"

Google::Protobuf::DescriptorPool.generated_pool.lookup("required_field").get(Thing::InnerThing.descriptor.lookup("another_optional_value").options) == false
puts "another_optional_value, required_field?: #{Google::Protobuf::DescriptorPool.generated_pool.lookup('required_field').get(Thing::InnerThing.descriptor.lookup('another_optional_value').options) == true}"

0 comments on commit 99af6c2

Please sign in to comment.