Thank you for your interest in contributing to the Replicate Ruby client! We welcome contributions from the community and are grateful for your help in making this project better.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Development Guidelines
- Testing
- Submitting Changes
- Community
This project follows a code of conduct to ensure a welcoming environment for all contributors. By participating, you agree to:
- Be respectful and inclusive
- Focus on constructive feedback
- Accept responsibility for mistakes
- Show empathy towards other contributors
- Help create a positive community
- Fork the repository on GitHub
- Clone your fork locally
- Set up your development environment (see below)
- Create a feature branch for your changes
- Make your changes following our guidelines
- Write tests for your changes
- Submit a pull request
- Ruby 2.6.0 or higher
- Bundler
-
Clone your fork:
git clone https://github.com/yourusername/replicate-ruby.git cd replicate-ruby -
Install dependencies:
bundle install
-
Run the tests to ensure everything works:
bundle exec rake test
-
Start a console session for experimentation:
bin/console
- Bug fixes: Fix issues in the codebase
- Features: Add new functionality
- Documentation: Improve documentation, examples, or guides
- Tests: Add or improve test coverage
- Code quality: Refactor code, improve performance, or enhance maintainability
- Check the GitHub Issues for open issues
- Look for issues labeled
good first issueorhelp wanted - Comment on an issue to indicate you're working on it
We use RuboCop for code style enforcement. The rules are defined in .rubocop.yml.
-
Run RuboCop before submitting:
bundle exec rubocop -
Auto-fix issues where possible:
bundle exec rubocop -a
- Modules/Classes: PascalCase (e.g.,
Replicate::Client) - Methods: snake_case (e.g.,
retrieve_model) - Constants: SCREAMING_SNAKE_CASE (e.g.,
VERSION) - Files: snake_case matching class/module names
- Use YARD format for all public methods
- Include parameter types, return values, and examples
- Document exceptions that may be raised
Example:
# Creates a prediction using this model version
#
# @param input [Hash] The input parameters for the model
# @param webhook [String, nil] Optional webhook URL
# @return [Replicate::Record::Prediction] The created prediction
# @raise [Replicate::Error] If prediction creation fails
def predict(input, webhook = nil)
# implementation
endFollow conventional commit format:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changesstyle:- Code style changesrefactor:- Code refactoringtest:- Test additions/changeschore:- Maintenance tasks
Examples:
feat: add support for model collectionsfix: handle timeout errors in predictionsdocs: update README with webhook examples
# Run all tests
bundle exec rake test
# Run specific test file
bundle exec ruby test/replicate/client_test.rb- Use Minitest framework
- Test files should be in
test/directory - Mirror the lib structure (e.g.,
test/replicate/client_test.rb) - Use descriptive test names
- Test both success and failure cases
- Use WebMock for HTTP request mocking
Example test structure:
class ClientTest < Minitest::Test
def test_retrieve_model_success
# Test successful model retrieval
end
def test_retrieve_model_not_found
# Test error handling for non-existent models
end
endMaintain high test coverage (>90%). Run coverage reports with:
# If using simplecov
bundle exec rake test
# Check coverage/index.html-
Create a feature branch from
master:git checkout -b feature/your-feature-name
-
Make your changes following the guidelines above
-
Run the full test suite:
bundle exec rake test bundle exec rubocop
-
Update documentation if needed
-
Commit your changes with clear messages
-
Push to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub:
- Use a clear title describing the change
- Provide a detailed description of what was changed and why
- Reference any related issues
- Ensure CI checks pass
- Tests pass
- Code style checks pass
- Documentation updated
- CHANGELOG.md updated (if applicable)
- Commit messages follow conventional format
- A maintainer will review your PR
- They may request changes or ask questions
- Once approved, your PR will be merged
- You may be asked to squash commits for cleaner history
By contributing to this project, you agree to the Developer Certificate of Origin (DCO):
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, or not, under the license indicated in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
To sign your commits, use git commit -s or add the following to your commit message:
Signed-off-by: Your Name <your.email@example.com>
- Discussions: Use GitHub Discussions for questions and general discussion
- Issues: Report bugs and request features via GitHub Issues
- Code Reviews: All changes require review before merging
- Recognition: Contributors are acknowledged in release notes
Thank you for contributing to the Replicate Ruby client! 🎉 </xai:function_call">