This repository contains a .ruby-version file, which should work with either rbenv or asdf with the ruby plugin.
Please follow the instructions for your preferred version manager to install the Ruby version specified in the .ruby-version file.
To set up the repository, run:
$ ./scripts/bootstrapThis will install all the required dependencies.
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents of lib/moderation_api/helpers/ and examples/ directory.
All files in the examples/ directory are not modified by the generator and can be freely edited or added to.
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative "../lib/moderation_api"
# ...$ chmod +x './examples/<your-example>.rb'
# run the example against your api
$ ruby './examples/<your-example>.rb'If you’d like to use the repository from source, you can either install from git or reference a cloned repository:
To install via git in your Gemfile:
gem "moderation_api", git: "https://github.com/moderation-api/sdk-ruby"Alternatively, reference local copy of the repo:
$ git clone -- 'https://github.com/moderation-api/sdk-ruby' '<path-to-repo>'gem "moderation_api", path: "<path-to-repo>"Running rake by itself will show all runnable commands.
$ bundle exec rake$ bundle exec rake testThis repository uses rubocop for linting and formatting of *.rb files; And syntax_tree is used for formatting of both *.rbi and *.rbs files.
There are two separate type checkers supported by this library: sorbet and steep are used for verifying *.rbi and *.rbs files respectively.
To lint and typecheck:
$ bundle exec rake lintTo format and fix all lint issues automatically:
$ bundle exec rake formatRuby LSP has quite good support for go to definition, but not auto-completion.
This can be installed along side Solargraph.
Solargraph has quite good support for auto-completion, but not go to definition.
This can be installed along side Ruby LSP.
Sorbet should mostly work out of the box when editing this library directly. However, there are a some caveats due to the colocation of *.rb and *.rbi files in the same project. These issues should not otherwise manifest when this library is used as a dependency.
-
For go to definition usages, sorbet might get confused and may not always navigate to the correct location.
-
For each generic type in
*.rbifiles, a spurious "Duplicate type member" error is present.
To preview the documentation, run:
$ bundle exec rake docs:preview [PORT=8808]