-
Notifications
You must be signed in to change notification settings - Fork 28
Add missing APIs from main branch to rewrite architecture #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vipulnsward
wants to merge
17
commits into
main
Choose a base branch
from
feature/add-missing-apis-to-rewrite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fdfa4e4
Init new architecture
vipulnsward ccf41eb
Lots of style fixe for Rubopcop
vipulnsward 39e1114
Add missing APIs from main branch to rewrite architecture
vipulnsward 2beab31
Implement best practices and enhanced API features
vipulnsward f450827
Address CodeRabbit review comments
vipulnsward af441b3
Address additional CodeRabbit review comments
vipulnsward 728f5b5
Add SimpleCov coverage reporting and comprehensive test specs
vipulnsward ba5ab6e
Fix Zeitwerk loading issues for middleware and errors
vipulnsward 56b0014
Remove middleware from collapsed directories in Zeitwerk
vipulnsward 28b8f1f
Fix RuboCop violations and improve code style
vipulnsward 361e5e9
Fix syntax error in retry middleware
vipulnsward 3533b40
Fix SignedUrlGenerators module loading by removing from collapsed dir…
vipulnsward cb1f3da
Add instance update method to Webhook class
vipulnsward 5c91cdf
Fix test failures: middleware order and Group#info method signature
vipulnsward a3f3be9
Fix error handling to use specific error types instead of generic Req…
vipulnsward 6da3958
Fix error message parsing in ErrorHandler
vipulnsward 51592cd
Add comprehensive Rails-style architecture and documentation
vipulnsward File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| Uploadcare Ruby SDK - Ruby client library for Uploadcare's Upload and REST APIs, providing file upload, management, and transformation capabilities. | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ### Environment Setup | ||
| - Ruby 3.0+ required (use mise for version management: `mise use ruby@latest`) | ||
| - Install dependencies: `bundle install` | ||
| - Add `gem 'base64'` to Gemfile if using Ruby 3.4+ to avoid vcr gem warnings | ||
|
|
||
| ### Testing | ||
| - Run all tests: `bundle exec rake spec` or `bundle exec rspec` | ||
| - Run specific test file: `bundle exec rspec spec/uploadcare/resources/file_spec.rb` | ||
| - Run with documentation format: `bundle exec rspec --format documentation` | ||
| - Run with fail-fast: `bundle exec rspec --fail-fast` | ||
| - Test environment variables required: | ||
| - `UPLOADCARE_PUBLIC_KEY=demopublickey` | ||
| - `UPLOADCARE_SECRET_KEY=demoprivatekey` | ||
|
|
||
| ### Code Quality | ||
| - Run linter: `bundle exec rubocop` | ||
| - Run linter with auto-fix: `bundle exec rubocop -a` | ||
| - Run all checks (tests + linter): `bundle exec rake` | ||
|
|
||
| ## Architecture Overview | ||
|
|
||
| ### Core Module Structure | ||
| The gem uses Zeitwerk autoloading with collapsed directories for resources and clients: | ||
|
|
||
| - **lib/uploadcare.rb** - Main module, configures Zeitwerk autoloading | ||
| - **lib/uploadcare/configuration.rb** - Configuration management | ||
| - **lib/uploadcare/api.rb** - Main API interface (deprecated pattern, use resources directly) | ||
| - **lib/uploadcare/client.rb** - New client pattern for API interactions | ||
|
|
||
| ### Resource Layer (lib/uploadcare/resources/) | ||
| Domain objects representing Uploadcare entities: | ||
| - **file.rb** - File upload/management operations | ||
| - **group.rb** - File group operations | ||
| - **webhook.rb** - Webhook management | ||
| - **uploader.rb** - Upload coordination | ||
| - **paginated_collection.rb** - Pagination support for list operations | ||
| - **batch_file_result.rb** - Batch operation results | ||
| - **add_ons.rb** - Add-on services (AWS Rekognition, ClamAV, Remove.bg) | ||
| - **document_converter.rb** - Document conversion operations | ||
| - **video_converter.rb** - Video conversion operations | ||
|
|
||
| ### Client Layer (lib/uploadcare/clients/) | ||
| HTTP client implementations for API communication: | ||
| - **rest_client.rb** - Base REST API client | ||
| - **upload_client.rb** - Upload API client | ||
| - **multipart_upload_client.rb** - Multipart upload handling | ||
| - **uploader_client.rb** - Upload coordination client | ||
| - **file_client.rb** - File management endpoints | ||
| - **group_client.rb** - Group management endpoints | ||
| - **webhook_client.rb** - Webhook endpoints | ||
| - **project_client.rb** - Project info endpoints | ||
|
|
||
| ### Middleware Layer (lib/uploadcare/middleware/) | ||
| Request/response processing: | ||
| - **base.rb** - Base middleware class | ||
| - **retry.rb** - Retry logic for failed requests | ||
| - **logger.rb** - Request/response logging | ||
|
|
||
| ### Error Handling | ||
| - **lib/uploadcare/error_handler.rb** - Central error parsing and handling | ||
| - **lib/uploadcare/exception/** - Custom exception types | ||
| - **request_error.rb** - Base request errors | ||
| - **auth_error.rb** - Authentication errors | ||
| - **throttle_error.rb** - Rate limiting errors | ||
| - **retry_error.rb** - Retry exhaustion errors | ||
|
|
||
| ### Utilities | ||
| - **lib/uploadcare/authenticator.rb** - Request signing and authentication | ||
| - **lib/uploadcare/url_builder.rb** - CDN URL generation with transformations | ||
| - **lib/uploadcare/signed_url_generators/** - Secure URL generation (Akamai) | ||
| - **lib/uploadcare/throttle_handler.rb** - Rate limit handling | ||
|
|
||
| ## Key Design Patterns | ||
|
|
||
| 1. **Resource-Client Separation**: Resources handle business logic, clients handle HTTP communication | ||
| 2. **Zeitwerk Autoloading**: Uses collapsed directories for cleaner require structure | ||
| 3. **Middleware Pattern**: Extensible request/response processing pipeline | ||
| 4. **Result Objects**: Many operations return Success/Failure result objects | ||
| 5. **Lazy Loading**: Paginated collections fetch data on demand | ||
|
|
||
| ## API Configuration | ||
|
|
||
| Configuration can be set via: | ||
| - Environment variables: `UPLOADCARE_PUBLIC_KEY`, `UPLOADCARE_SECRET_KEY` | ||
| - Code: `Uploadcare.config.public_key = "key"` | ||
| - Per-request: Pass config to individual resource methods | ||
|
|
||
| ## Testing Approach | ||
|
|
||
| - Uses RSpec for testing | ||
| - VCR for recording/replaying HTTP interactions | ||
| - SimpleCov for code coverage reporting | ||
| - Tests are in `spec/uploadcare/` mirroring lib structure | ||
| - Fixtures and cassettes in `spec/fixtures/` | ||
|
|
||
| ## Common Development Tasks | ||
|
|
||
| ### Adding New API Endpoints | ||
| 1. Create/update client in `lib/uploadcare/clients/` | ||
| 2. Create/update resource in `lib/uploadcare/resources/` | ||
| 3. Add corresponding specs in `spec/uploadcare/` | ||
| 4. Update README.md with usage examples | ||
|
|
||
| ### Handling API Responses | ||
| - Use `Uploadcare::ErrorHandler` for error parsing | ||
| - Return result objects for operations that can fail | ||
| - Parse JSON responses into Ruby objects/hashes | ||
|
|
||
| ### Working with Batch Operations | ||
| - Use `BatchFileResult` for batch store/delete results | ||
| - Handle both successful results and problem items | ||
| - Follow pattern in `File.batch_store` and `File.batch_delete` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Update to a newer version of codecov/codecov-action
The static analysis tool indicates that
codecov/codecov-action@v3is too old to run on GitHub Actions. Consider updating to@v4which is the current stable version.📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.7)
38-38: the runner of "codecov/codecov-action@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents