Thank you for your interest in contributing to the Z.ai Ruby SDK! This document provides guidelines and instructions for contributing.
- Ruby >= 3.2.8
- JRuby >= 10.0.4.0 (optional, for JRuby testing)
- Bundler
-
Fork and Clone
git clone https://github.com/your-username/z-ai-sdk-ruby.git cd z-ai-sdk-ruby -
Install Dependencies
bundle install
-
Run Tests
bundle exec rspec -
Run Smoke Test
ruby smoke_test.rb
-
Run Verification
ruby verify_sdk.rb
-
Create a feature branch from
develop:git checkout -b feature/your-feature-name
-
Make your changes following our code style guidelines
-
Write tests for your changes
-
Run the test suite:
bundle exec rspec -
Run RuboCop:
bundle exec rubocop -
Commit your changes with a clear message
-
Push to your fork and create a pull request
- Follow Ruby community conventions
- Use frozen string literals (
# frozen_string_literal: true) - Write YARD documentation for public methods
- Keep methods small and focused (max 20 lines)
- Use meaningful variable and method names
- Write tests for all new functionality
- Use RSpec for all tests
- Write unit tests for individual methods
- Write integration tests for API interactions
- Use FactoryBot for test data
- Use VCR for recording HTTP interactions
- Aim for >90% code coverage
- Update README.md for user-facing changes
- Update CHANGELOG.md for all changes
- Write YARD documentation for public APIs
- Include usage examples in documentation
- Update example scripts when adding new features
z-ai-sdk-ruby/
├── lib/z/ai/ # Main library code
│ ├── core/ # HTTP client and base classes
│ ├── auth/ # Authentication modules
│ ├── resources/ # API resource classes
│ └── models/ # Data models
├── spec/ # Test files
│ ├── core/ # Core tests
│ ├── auth/ # Auth tests
│ ├── resources/ # API tests
│ ├── models/ # Model tests
│ └── integration/ # Integration tests
├── examples/ # Usage examples
├── docs/ # Documentation
└── openspec/ # OpenSpec specifications
- Create model in
lib/z/ai/models/ - Create resource in
lib/z/ai/resources/ - Add to client in
lib/z/ai/client.rb - Create tests in
spec/resources/ - Create example in
examples/ - Update README.md
- Update CHANGELOG.md
# All tests
bundle exec rspec
# Specific test file
bundle exec rspec spec/resources/chat/completions_spec.rb
# With coverage
COVERAGE=true bundle exec rspec
# Unit tests only
bundle exec rake spec_unit
# Integration tests only
bundle exec rake spec_integrationUse pry for debugging:
require 'pry'
binding.pryFor HTTP debugging, enable logging:
Z::AI.configure do |config|
config.logger = Logger.new(STDOUT)
config.log_level = :debug
end- Update VERSION in
lib/z/ai/version.rb - Update CHANGELOG.md
- Run full test suite
- Build the gem:
gem build zai-ruby-sdk.gemspec - Push to RubyGems:
gem push zai-ruby-sdk-VERSION.gem - Create GitHub release
- Open a GitHub issue for bugs
- Use GitHub discussions for questions
- Email: sjedt@3ddaily.com
Please read and follow our Code of Conduct.
By contributing, you agree that your contributions will be licensed under the MIT License.