Add a sorbet type check step to CI, and distribute rbi files with the gem for downstream users who use sorbet.
I'm not sure if I'll keep this long term, but I'm interested in playing with sorbet and this gem is a good playground.
A few features of this change:
the sorbet/ directory was built with bundle exec srb init, as described in sorbet docs
the rbi/pdf-reader.rbi file was built with bundle exec parlour. I assume I'll need to re-run this command anytime methods or classes are added/removed/changed. Maybe changes will need to be carefully added to git with -p as well? We'll see
the parlour gem raises a NoMethodError when parsing lib/pdf/reader/parser.rb. I haven't worked out why yet, so for now that file is excluded from the auto rbi generation
all types are stored outside the code, to avoid any runtime dependency on sorbet. Most downstream users aren't using sorbet, and should gain a dependency on it when they upgrade pdf-reader
the types are distributed in the gem, which should mean downstream users who run sorbet should see that it knows the types pdf-reader expects
I've got nearly every file in lib/ to types: true, and a handful to typed: strict
Most methods don't have proper signatures yet, they have the not-so-useful sig { params(T.untyped).returns(T.untyped) }
There's some CI environment shenanigans to avoid loading any sorbet on ruby < 2.3, which sorbet refuses to install on
Add a sorbet type check step to CI, and distribute rbi files with the gem for downstream users who use sorbet.
I'm not sure if I'll keep this long term, but I'm interested in playing with sorbet and this gem is a good playground.
A few features of this change:
sorbet/
directory was built withbundle exec srb init
, as described in sorbet docsrbi/pdf-reader.rbi
file was built withbundle exec parlour
. I assume I'll need to re-run this command anytime methods or classes are added/removed/changed. Maybe changes will need to be carefully added to git with-p
as well? We'll seeNoMethodError
when parsinglib/pdf/reader/parser.rb
. I haven't worked out why yet, so for now that file is excluded from the auto rbi generationlib/
totypes: true
, and a handful totyped: strict
sig { params(T.untyped).returns(T.untyped) }