3 ms·
I found code generation to be useful in Ruby with protobuf. This: https://github.com/lloeki/ruby-skyjam/blob/master/defs/skyjam/music_manager/export_tracks_req
by lloeki 6y ago
I found code generation to be useful in Ruby with protobuf. This:
https://github.com/lloeki/ruby-skyjam/blob/master/defs/skyjam/music_manager/export_tracks_request.proto https://github.com/lloeki/ruby-skyjam/blob/master/defs/skyja...
gives that:
https://github.com/lloeki/ruby-skyjam/blob/master/lib/skyjam/music_manager/export_tracks_request.pb.rb https://github.com/lloeki/ruby-skyjam/blob/master/lib/skyjam...
I would certainly enjoy having a DSL to write descriptive code to validate using JSON schema, but it would be even better if the Ruby definitions could be generated and persisted in Ruby files using that DSL.
Also, storing things in basic hash/array types works, but having dedicated types is useful, so that one can ensure not shoving one kind of hash in place of another unrelated kind of hash.
As for types themselves in general, there's RBS and Sorbet. One could have type definition generation as well for even deeper static and runtime checks.