Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
By participating in this project, you agree to maintain a respectful and inclusive environment for everyone.
- Ruby >= 3.0
- Bundler
- Fork and clone the repository:
git clone https://github.com/YOUR_USERNAME/searchapi-ruby.git
cd searchapi-ruby- Install dependencies:
bundle install- Run the test suite to verify everything works:
bundle exec rspecUse descriptive branch names:
feature/add-new-enginefor new featuresfix/client-timeout-handlingfor bug fixesdocs/update-readmefor documentation changes
- Create a new branch from
main:
git checkout -b feature/your-feature-name-
Make your changes, following the coding conventions below.
-
Add or update tests as needed.
-
Run the full test suite:
bundle exec rspec- Commit your changes with a clear message:
git commit -m "Add support for new_engine API"- Push to your fork and open a Pull Request.
- Use
frozen_string_literal: truein all Ruby files - Follow standard Ruby naming conventions (snake_case for methods, CamelCase for classes)
- Keep methods short and focused
- Use keyword arguments for required non-query parameters
All engines follow the same pattern. To add a new engine:
- Create the resource file in
lib/searchapi/resources/:
# frozen_string_literal: true
module SearchApi
module Resources
class NewEngine < Resource
def search(query, **params)
get(q: query, **params)
end
private
def engine_name
"new_engine"
end
end
end
end-
Register it in
lib/searchapi.rb:- Add the
require_relativestatement - Add the entry to the
RESOURCEShash
- Add the
-
Add tests in
spec/searchapi/resources/new_engine_spec.rb:
# frozen_string_literal: true
require "spec_helper"
RSpec.describe SearchApi::Resources::NewEngine do
let(:client) { instance_double(SearchApi::Client) }
let(:resource) { described_class.new(client) }
describe "#search" do
it "searches with the correct engine" do
expect(client).to receive(:get).with("/search", {
engine: "new_engine",
q: "test query"
})
resource.search("test query")
end
it "passes additional params" do
expect(client).to receive(:get).with("/search", {
engine: "new_engine",
q: "test query",
page: 2
})
resource.search("test query", page: 2)
end
end
end-
Update the README with usage examples.
-
Add an entry to CHANGELOG.md.
- All tests use RSpec with
instance_doublefor mocking the client - Tests should verify the correct engine name and parameter mapping
- Use realistic, descriptive test values
- Run the full suite before submitting:
bundle exec rspec- Keep PRs focused on a single change
- Include tests for any new functionality
- Update documentation if needed
- Reference any related issues in the PR description
- Ensure all tests pass before requesting review
When reporting bugs, please include:
- Ruby version (
ruby -v) - Gem version
- Steps to reproduce
- Expected vs. actual behavior
- Any relevant error messages or stack traces
By contributing, you agree that your contributions will be licensed under the MIT License.