{"id":20434399,"url":"https://github.com/wantedly/rbs_macros","last_synced_at":"2026-01-07T22:50:16.079Z","repository":{"id":225095717,"uuid":"765066032","full_name":"wantedly/rbs_macros","owner":"wantedly","description":"RBS meets metaprogramming","archived":false,"fork":false,"pushed_at":"2024-08-02T01:50:16.000Z","size":61,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T03:48:19.727Z","etag":null,"topics":["ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wantedly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-29T08:10:29.000Z","updated_at":"2024-02-29T08:17:43.000Z","dependencies_parsed_at":"2024-11-15T12:30:35.902Z","dependency_job_id":"c19ec0e5-be4c-4893-8aa1-d127a81d00f6","html_url":"https://github.com/wantedly/rbs_macros","commit_stats":null,"previous_names":["wantedly/rbs_macros"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Frbs_macros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Frbs_macros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Frbs_macros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wantedly%2Frbs_macros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wantedly","download_url":"https://codeload.github.com/wantedly/rbs_macros/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246274429,"owners_count":20751071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby"],"created_at":"2024-11-15T08:26:28.256Z","updated_at":"2026-01-07T22:50:16.032Z","avatar_url":"https://github.com/wantedly.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rbs-macros\n\nRubyists💎 love metaprogramming.\n\n**rbs-macros** bridges between [RBS](https://github.com/ruby/rbs) and metaprogramming,\nby allowing you to define a macro,\nwhich is then used to generate RBS definitions\nbased on macro invocations.\n\n## Installation\n\n```sh\nbundle add rbs-macros --group development,test --require false\n```\n\nOr equivalently, add to Gemfile:\n\n```ruby\ngroup :development, :test do\n  gem \"rbs-macros\", \"~\u003e [VERSION]\", require: false\nend\n```\n\nThen run `bundle install`.\n\n## Usage\n\n\u003e [!NOTE]\n\u003e at the time of writing, rbs-macros is still in early development,\n\u003e and the API is subject to change.\n\nAssumes you have already set up `rbs_collection.yaml` via `rbs collection init`.\n\nAdd to Rakefile:\n\n```ruby\ndesc \"Generate RBS files using macros\"\ntask :rbs_gen do\n  require \"rbs_macros\"\n  require \"rbs_macros/macros/forwardable\"\n  RbsMacros.run do |config|\n    lock_path = Pathname(\"rbs_collection.lock.yaml\")\n    config.loader.add_collection(\n      RBS::Collection::Config::Lockfile.from_lockfile(\n        lockfile_path: lock_path,\n        data: YAML.load_file(lock_path.to_s)\n      )\n    )\n    config.macros \u003c\u003c RbsMacros::Macros::ForwardableMacros.new\n    config.macros \u003c\u003c RbsMacros::Macros::SingleForwardableMacros.new\n  end\nend\n```\n\nThen run:\n\n```\nbundle exec rake rbs_gen\n```\n\n## Example\n\nSuppose there are the following files:\n\n```ruby\n# lib/array_wrapper.rb\nclass ArrayWrapper\n  extend Forwardable\n  def_delegators :@storage, :[], :size\nend\n```\n\n```rbs\n# sig/array_wrapper.rbs\nclass ArrayWrapper[T]\n  extend Forwardable\n  @storage: Array[T]\nend\n```\n\nThen the output will be:\n\n```rbs\n# sig/generated/array_wrapper.rbs\nclass ArrayWrapper\n  def []: (::int index) -\u003e T\n        | (::int start, ::int length) -\u003e ::Array[T]?\n        | (::Range[::Integer?] range) -\u003e ::Array[T]?\n\n  def size: () -\u003e ::Integer\nend\n```\n\n## Future plans\n\n- You will be able to define sharable macros and included them in your gem.\n  For example, the `ffi` gem may include its own macros to generate RBS files for FFI definitions.\n- Additionally, you will be able to load all the relevant macros based on the gem list in Gemfile.\n- The behavior is currently largely dependent on the order the source files are processed.\n  I will try to stabilize it to some extent in the future.\n- Possible new builtin macros:\n  - Improved `forwardable` macros\n  - `Struct`/`Data` macros\n  - FFI\n  - ActiveRecord\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wantedly/rbs_macros. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/wantedly/rbs_macros/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the RbsMacros project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/wantedly/rbs_macros/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwantedly%2Frbs_macros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwantedly%2Frbs_macros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwantedly%2Frbs_macros/lists"}