uploadcare-rails 5.0.0.rc1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -1
- data/Gemfile +2 -3
- data/MIGRATING_V5.md +9 -1
- data/README.md +5 -3
- data/docs/release-notes-5.0.0.md +128 -0
- data/lib/uploadcare/rails/attached_file.rb +9 -0
- data/lib/uploadcare/rails/attached_files.rb +7 -1
- data/lib/uploadcare/rails/internal/active_storage_service_helpers.rb +12 -1
- data/lib/uploadcare/rails/internal/client_resolver.rb +4 -1
- data/lib/uploadcare/rails/internal/id_extractor.rb +1 -1
- data/lib/uploadcare/rails/internal/uploader_field_helpers.rb +21 -3
- data/lib/uploadcare/rails/version.rb +1 -1
- data/uploadcare-rails.gemspec +7 -6
- metadata +8 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6236e99b256e9622e9e4a806dc2e909fe43a6ef59b25ae013ce5e2b7826fff1b
|
|
4
|
+
data.tar.gz: de2380e25b4493e825359eb162e85fc38ccdbc32f8aeed38d31add0ec0a2a329
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eced3cce170c1e69bc1616617cf66357c0d37e96f75e0e27b905a45d791cd8d058ceebf02e0c8300e8cc27e562664f135719311743c3c6c141d8c29157207fd3
|
|
7
|
+
data.tar.gz: 627150f81723e25667c88cd250b43f677048431e0da359f4cfdc0b187f2d62ddab0c209b245548baf0444f703b62a9140b70b65ada26cb846014cbb0faab3217
|
data/CHANGELOG.md
CHANGED
|
@@ -6,11 +6,76 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 5.0.0 - 2026-05-17
|
|
10
|
+
|
|
11
|
+
This is the stable release of the v5 rewrite.
|
|
12
|
+
|
|
13
|
+
There are no breaking API changes from `5.0.0.rc1`. This release promotes the
|
|
14
|
+
rewrite to the stable line, removes prerelease dependency pins, and hardens the
|
|
15
|
+
release workflow for tag-based RubyGems publishing.
|
|
16
|
+
|
|
17
|
+
See [MIGRATING_V5.md](MIGRATING_V5.md)
|
|
18
|
+
for the migration guide and [docs/release-notes-5.0.0.md](docs/release-notes-5.0.0.md)
|
|
19
|
+
for release notes and examples.
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
* Active Storage service integration through `ActiveStorage::Service::UploadcareService`
|
|
24
|
+
* Uploadcare-backed Active Storage preview and remote variant processing support
|
|
25
|
+
* `Uploadcare::Rails.client` as the default Rails client entry point
|
|
26
|
+
* explicit multi-account usage through `Uploadcare::Client`
|
|
27
|
+
* `has_uploadcare_file` and `has_uploadcare_files` model macros
|
|
28
|
+
* `uploadcare_file_field`, `uploadcare_files_field`, and matching FormBuilder helpers
|
|
29
|
+
* `Uploadcare::Rails::AttachedFile` and `Uploadcare::Rails::AttachedFiles` wrappers
|
|
30
|
+
* `rails g uploadcare_config` support for `config/uploadcare.yml`
|
|
31
|
+
* Rails 7.2, 8.0, and 8.1 test matrix coverage
|
|
32
|
+
* Ruby 3.3, 3.4, and experimental Ruby 4.0 CI coverage
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
* Re-centered the gem around `uploadcare-ruby` 5.x instead of maintaining a
|
|
37
|
+
second API wrapper layer in `uploadcare-rails`
|
|
38
|
+
* Simplified the documented public API to the Rails integration surface
|
|
39
|
+
* Configuration now loads from `config/uploadcare.yml` when present and still
|
|
40
|
+
supports `Uploadcare::Rails.configure`
|
|
41
|
+
* Active Storage service defaults to public URL mode and supports configurable
|
|
42
|
+
HTTP timeouts (`open_timeout`, `read_timeout`, `write_timeout`)
|
|
43
|
+
* Mongoid hooks prefer `after_commit` callbacks when available, with fallback
|
|
44
|
+
to `after_save`/`after_destroy`
|
|
45
|
+
* README and migration docs now describe the v5 client-first API and upgrade path
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
* Edit-form uploader prefill now binds `value` to `<uc-form-input>` instead of
|
|
50
|
+
leaking into `<uc-config>`
|
|
51
|
+
* Active Storage blob-key to UUID cache writes are synchronized for thread safety
|
|
52
|
+
* Variant and preview remote-processing paths avoid redundant API roundtrips for
|
|
53
|
+
CDN URL resolution
|
|
54
|
+
* `AttachedFile#store` avoids a redundant file pre-fetch before storing
|
|
55
|
+
* Uploadcare uploader helper options now warn on unknown keys and support
|
|
56
|
+
Rails-style `data: { ... }` passthrough attributes
|
|
57
|
+
* SQL wildcard escaping in `delete_prefixed`
|
|
58
|
+
* nil-key SDK configuration synchronization
|
|
59
|
+
* tag-based gem publishing now validates the release tag against the gem version
|
|
60
|
+
before pushing to RubyGems
|
|
61
|
+
|
|
62
|
+
### Removed
|
|
63
|
+
|
|
64
|
+
* `mount_uploadcare_file`
|
|
65
|
+
* `mount_uploadcare_file_group`
|
|
66
|
+
* `uploadcare_uploader_field`
|
|
67
|
+
* `uploadcare_uploader_field_tag`
|
|
68
|
+
* `f.uploadcare_file`
|
|
69
|
+
* `Uploadcare::Rails::File`
|
|
70
|
+
* `Uploadcare::Rails::Group`
|
|
71
|
+
* low-level uploader composition helpers from the documented public API
|
|
72
|
+
* stale migration guides that described the pre-rewrite compatibility surface
|
|
73
|
+
|
|
9
74
|
## 5.0.0.rc1 - 2026-03-24
|
|
10
75
|
|
|
11
76
|
This is the first release candidate for the 5.0 rewrite.
|
|
12
77
|
|
|
13
|
-
See [MIGRATING_V5.md](
|
|
78
|
+
See [MIGRATING_V5.md](MIGRATING_V5.md) for the migration guide.
|
|
14
79
|
|
|
15
80
|
### Changed
|
|
16
81
|
|
data/Gemfile
CHANGED
|
@@ -5,13 +5,13 @@ source "https://rubygems.org"
|
|
|
5
5
|
# Specify your gem's dependencies in uploadcare-rails.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# Pin the released SDK for local and CI release validation.
|
|
9
|
+
gem "uploadcare-ruby", "5.0.0"
|
|
9
10
|
|
|
10
11
|
gem "http-parser", "~> 1.2", ">= 1.2.3"
|
|
11
12
|
gem "rake", "~> 13.0.6"
|
|
12
13
|
|
|
13
14
|
group :test do
|
|
14
|
-
gem "benchmark", "~> 0.4"
|
|
15
15
|
gem "mongoid", "~> 9", require: false
|
|
16
16
|
gem "ostruct"
|
|
17
17
|
gem "rspec", "~> 3.12"
|
|
@@ -19,5 +19,4 @@ group :test do
|
|
|
19
19
|
gem "rubocop-rails-omakase", require: false
|
|
20
20
|
gem "vcr", "~> 6.1"
|
|
21
21
|
gem "webmock", "~> 3.18"
|
|
22
|
-
gem "yard", "~> 0.9"
|
|
23
22
|
end
|
data/MIGRATING_V5.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Migrating to uploadcare-rails 5.0
|
|
2
2
|
|
|
3
|
-
This guide covers migration from the older `uploadcare-rails` surface to the rewritten, client-first API released in `5.0.0
|
|
3
|
+
This guide covers migration from the older `uploadcare-rails` surface to the rewritten, client-first API released in `5.0.0`.
|
|
4
|
+
|
|
5
|
+
## Compatibility summary
|
|
6
|
+
|
|
7
|
+
- Runtime minimums are Ruby 3.3+ and Rails 7.2+.
|
|
8
|
+
- This is a breaking major upgrade from the pre-v5 API.
|
|
9
|
+
- API usage now goes through `Uploadcare::Rails.client` or explicit `Uploadcare::Client` instances.
|
|
10
|
+
- Active Storage direct uploads are not supported by `ActiveStorage::Service::UploadcareService`; use the Uploadcare uploader field helpers for browser direct uploads.
|
|
11
|
+
- Custom per-tenant clients work with mounted objects and synchronous callbacks. Async callbacks use the default `Uploadcare::Rails.client`.
|
|
4
12
|
|
|
5
13
|
The short version:
|
|
6
14
|
|
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
`uploadcare-rails` is a Rails integration for Uploadcare built on top of the rewritten `uploadcare-ruby` client API.
|
|
10
10
|
|
|
11
|
-
The current stable branch is
|
|
11
|
+
The current stable branch is the `5.0` release line.
|
|
12
12
|
|
|
13
13
|
The gem is centered on:
|
|
14
14
|
|
|
@@ -45,7 +45,7 @@ This version uses the new [Uploadcare File Uploader](https://uploadcare.com/docs
|
|
|
45
45
|
Add the gem to your Gemfile:
|
|
46
46
|
|
|
47
47
|
```ruby
|
|
48
|
-
gem "uploadcare-rails", "5.0
|
|
48
|
+
gem "uploadcare-rails", "~> 5.0"
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
Then install:
|
|
@@ -63,7 +63,7 @@ gem "uploadcare-api_struct"
|
|
|
63
63
|
You can also install the gem directly:
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
gem install uploadcare-rails
|
|
66
|
+
gem install uploadcare-rails -v 5.0.0
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
## Configuration
|
|
@@ -535,6 +535,8 @@ Public utility constants:
|
|
|
535
535
|
|
|
536
536
|
## Useful links
|
|
537
537
|
|
|
538
|
+
- [Release notes for 5.0.0](docs/release-notes-5.0.0.md)
|
|
539
|
+
- [Migration guide for 5.0](MIGRATING_V5.md)
|
|
538
540
|
- [Uploadcare File Uploader docs](https://uploadcare.com/docs/file-uploader/)
|
|
539
541
|
- [Uploadcare Ruby SDK](https://github.com/uploadcare/uploadcare-ruby)
|
|
540
542
|
- [Uploadcare API docs](https://uploadcare.com/docs/start/api/)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# uploadcare-rails 5.0.0 release notes
|
|
2
|
+
|
|
3
|
+
Release v5.0.0: stable rewrite on `uploadcare-ruby` 5.x.
|
|
4
|
+
|
|
5
|
+
Must: publish `uploadcare-ruby` 5.0.0 first. CI/install will fail otherwise.
|
|
6
|
+
|
|
7
|
+
Before tagging:
|
|
8
|
+
|
|
9
|
+
- Verify CI: Rails 7.2, 8.0, 8.1 plus Active Storage.
|
|
10
|
+
- Smoke-test one 4.x to 5.0 migration using [MIGRATING_V5.md](../MIGRATING_V5.md).
|
|
11
|
+
- Tag and publish `uploadcare-rails` 5.0.0.
|
|
12
|
+
|
|
13
|
+
Migration priority: test in this order.
|
|
14
|
+
|
|
15
|
+
- Manual API wrappers: `Uploadcare::FileApi`, `Uploadcare::GroupApi`, `Uploadcare::UploadApi`
|
|
16
|
+
- `mount_uploadcare_file` or `mount_uploadcare_file_group`
|
|
17
|
+
- Removed uploader helper aliases
|
|
18
|
+
- Active Storage
|
|
19
|
+
|
|
20
|
+
Quick scan:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
git grep -n "mount_uploadcare_file\|Uploadcare::FileApi\|Uploadcare::GroupApi\|Uploadcare::UploadApi\|uploadcare_uploader_field"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
No API changes since `5.0.0.rc1`. Applications moving from 4.x or older should
|
|
27
|
+
follow [MIGRATING_V5.md](../MIGRATING_V5.md).
|
|
28
|
+
|
|
29
|
+
## Highlights
|
|
30
|
+
|
|
31
|
+
- Client-first API: `Uploadcare::Rails.client` and `Uploadcare::Client`
|
|
32
|
+
- Model macros: `has_uploadcare_file` and `has_uploadcare_files`
|
|
33
|
+
- Uploader helpers: `uploadcare_file_field`, `uploadcare_files_field`, and FormBuilder equivalents
|
|
34
|
+
- Wrapper objects: `Uploadcare::Rails::AttachedFile` and `Uploadcare::Rails::AttachedFiles`
|
|
35
|
+
- Active Storage service: `ActiveStorage::Service::UploadcareService`
|
|
36
|
+
- Active Storage preview and remote variant processing for Uploadcare-backed blobs
|
|
37
|
+
- Rails 7.2+ and Ruby 3.3+ runtime baseline
|
|
38
|
+
|
|
39
|
+
## Breaking changes
|
|
40
|
+
|
|
41
|
+
- `mount_uploadcare_file` and `mount_uploadcare_file_group` are removed. Use `has_uploadcare_file` and `has_uploadcare_files`.
|
|
42
|
+
- `uploadcare_uploader_field`, `uploadcare_uploader_field_tag`, and `f.uploadcare_file` are removed. Use `uploadcare_file_field`, `uploadcare_files_field`, `f.uploadcare_file_field`, and `f.uploadcare_files_field`.
|
|
43
|
+
- `Uploadcare::Rails::File` and `Uploadcare::Rails::Group` are replaced by `Uploadcare::Rails::AttachedFile` and `Uploadcare::Rails::AttachedFiles`.
|
|
44
|
+
- Manual API wrappers such as `Uploadcare::FileApi`, `Uploadcare::GroupApi`, and `Uploadcare::UploadApi` are no longer the public path. Use `Uploadcare::Rails.client` or explicit `Uploadcare::Client` instances.
|
|
45
|
+
- `do_not_store:` is replaced by the positive `store_files_after_save` configuration.
|
|
46
|
+
|
|
47
|
+
## Upgrade examples
|
|
48
|
+
|
|
49
|
+
Model macros:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
class Post < ApplicationRecord
|
|
53
|
+
has_uploadcare_file :picture
|
|
54
|
+
has_uploadcare_files :attachments
|
|
55
|
+
end
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Uploader fields:
|
|
59
|
+
|
|
60
|
+
```erb
|
|
61
|
+
<%= form_with model: @post do |f| %>
|
|
62
|
+
<%= f.uploadcare_file_field :picture %>
|
|
63
|
+
<%= f.uploadcare_files_field :attachments, solution: "inline" %>
|
|
64
|
+
<%= f.submit %>
|
|
65
|
+
<% end %>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Manual API usage:
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
client = Uploadcare::Rails.client
|
|
72
|
+
|
|
73
|
+
file = client.files.find(uuid: "2d33999d-c74a-4ff9-99ea-abc23496b052")
|
|
74
|
+
group = client.groups.find(group_id: "dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~2")
|
|
75
|
+
project = client.project.current
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Multi-account usage:
|
|
79
|
+
|
|
80
|
+
```ruby
|
|
81
|
+
client = Uploadcare::Client.new(
|
|
82
|
+
public_key: account.uploadcare_public_key,
|
|
83
|
+
secret_key: account.uploadcare_secret_key
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
client.files.find(uuid: "2d33999d-c74a-4ff9-99ea-abc23496b052")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Active Storage:
|
|
90
|
+
|
|
91
|
+
```yml
|
|
92
|
+
uploadcare:
|
|
93
|
+
service: Uploadcare
|
|
94
|
+
public_key: <%= ENV.fetch("UPLOADCARE_PUBLIC_KEY") %>
|
|
95
|
+
secret_key: <%= ENV.fetch("UPLOADCARE_SECRET_KEY") %>
|
|
96
|
+
public: true
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
config.active_storage.service = :uploadcare
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Operator notes
|
|
104
|
+
|
|
105
|
+
- Must: publish `uploadcare-ruby` 5.0.0 first. CI/install will fail otherwise.
|
|
106
|
+
- Verify: Rails 7.2, 8.0, 8.1 plus Active Storage specs are green before tagging.
|
|
107
|
+
- Risk: `UploadcareService` does not support direct uploads or signed private URLs. Private blobs and direct client uploads will break.
|
|
108
|
+
- Mitigation before tagging:
|
|
109
|
+
- Set service `public: true` for affected apps.
|
|
110
|
+
- Prefer uploader field helpers, not direct service calls.
|
|
111
|
+
- Smoke-test previews and remote variants end-to-end.
|
|
112
|
+
- Per-tenant clients: use `uploadcare_client:` for mounted objects and synchronous callbacks. Async callbacks use `Uploadcare::Rails.client`.
|
|
113
|
+
- Migration priority: test apps that use manual API wrappers, `mount_*` macros, uploader helper aliases, or Active Storage first.
|
|
114
|
+
|
|
115
|
+
## Release checklist
|
|
116
|
+
|
|
117
|
+
Do not skip:
|
|
118
|
+
|
|
119
|
+
1. `bundle install` resolves `uploadcare-ruby (= 5.0.0)`.
|
|
120
|
+
2. CI green: Rails 7.2, 8.0, 8.1 plus Active Storage specs.
|
|
121
|
+
3. Tag: `git tag -a v5.0.0 -m "uploadcare-rails v5.0.0" && git push origin v5.0.0`.
|
|
122
|
+
4. Publish: confirm the `Publish Gem` workflow uploads `uploadcare-rails-5.0.0.gem`.
|
|
123
|
+
5. Post-release: smoke test a migrated app and verify Active Storage blobs, previews, and variants.
|
|
124
|
+
|
|
125
|
+
Rollback policy:
|
|
126
|
+
|
|
127
|
+
- If RubyGems rejects the gem before publish, delete the failed tag, fix, and retag.
|
|
128
|
+
- If the gem is published, do not reuse the tag. Ship a patch release.
|
|
@@ -34,6 +34,7 @@ module Uploadcare
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def store
|
|
37
|
+
ensure_uuid!("store file")
|
|
37
38
|
resource = Uploadcare::Resources::File.new({ "uuid" => uuid }, resolve_client)
|
|
38
39
|
resource.store
|
|
39
40
|
file_info = file_info_from_resource(resource)
|
|
@@ -42,10 +43,12 @@ module Uploadcare
|
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def delete
|
|
46
|
+
ensure_uuid!("delete file")
|
|
45
47
|
resolve_client.files.batch_delete(uuids: [ uuid ])
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
def load(force: false)
|
|
51
|
+
ensure_uuid!("load file")
|
|
49
52
|
::Rails.cache.delete(cache_key) if force && caching_enabled?
|
|
50
53
|
|
|
51
54
|
file_info = if caching_enabled?
|
|
@@ -86,6 +89,12 @@ module Uploadcare
|
|
|
86
89
|
resolved_cdn_url = cdn_url.presence || resource_hash["cdn_url"].presence || resource_hash["url"]
|
|
87
90
|
resource_hash.merge("cdn_url" => resolved_cdn_url)
|
|
88
91
|
end
|
|
92
|
+
|
|
93
|
+
def ensure_uuid!(action)
|
|
94
|
+
return if uuid.present?
|
|
95
|
+
|
|
96
|
+
raise ArgumentError, "uuid is required to #{action}"
|
|
97
|
+
end
|
|
89
98
|
end
|
|
90
99
|
end
|
|
91
100
|
end
|
|
@@ -42,6 +42,8 @@ module Uploadcare
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def file_urls
|
|
45
|
+
return [] if cdn_url.blank?
|
|
46
|
+
|
|
45
47
|
map_file_urls do |index|
|
|
46
48
|
group_file_url(index)
|
|
47
49
|
end
|
|
@@ -96,7 +98,11 @@ module Uploadcare
|
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
def group_file_url(index)
|
|
99
|
-
"#{
|
|
101
|
+
"#{normalized_cdn_url}nth/#{index}/"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def normalized_cdn_url
|
|
105
|
+
cdn_url.end_with?("/") ? cdn_url : "#{cdn_url}/"
|
|
100
106
|
end
|
|
101
107
|
|
|
102
108
|
def map_file_urls(&block)
|
|
@@ -57,10 +57,21 @@ module Uploadcare
|
|
|
57
57
|
|
|
58
58
|
def build_request(uri, range)
|
|
59
59
|
request = Net::HTTP::Get.new(uri)
|
|
60
|
-
request["Range"] =
|
|
60
|
+
request["Range"] = range_header(range) if range
|
|
61
61
|
request
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
+
def range_header(range)
|
|
65
|
+
range_end = range.end
|
|
66
|
+
range_end -= 1 if range_end && range.exclude_end?
|
|
67
|
+
|
|
68
|
+
if range_end && range.begin && range_end < range.begin
|
|
69
|
+
raise ArgumentError, "range end must be greater than or equal to range begin"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
range_end ? "bytes=#{range.begin}-#{range_end}" : "bytes=#{range.begin}-"
|
|
73
|
+
end
|
|
74
|
+
|
|
64
75
|
def request_streaming(http, request, &block)
|
|
65
76
|
result = nil
|
|
66
77
|
|
|
@@ -6,12 +6,15 @@ module Uploadcare
|
|
|
6
6
|
module ClientResolver
|
|
7
7
|
def resolve_client(client_or_options = nil)
|
|
8
8
|
case client_or_options
|
|
9
|
+
when nil
|
|
10
|
+
client
|
|
9
11
|
when Uploadcare::Client
|
|
10
12
|
client_or_options
|
|
11
13
|
when Hash
|
|
12
14
|
client(**client_or_options.symbolize_keys)
|
|
13
15
|
else
|
|
14
|
-
|
|
16
|
+
raise ArgumentError,
|
|
17
|
+
"uploadcare_client must be an Uploadcare::Client, Hash, or nil; got #{client_or_options.class}"
|
|
15
18
|
end
|
|
16
19
|
end
|
|
17
20
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "action_view"
|
|
4
|
+
require "json"
|
|
4
5
|
require "set"
|
|
5
6
|
|
|
6
7
|
module Uploadcare
|
|
@@ -70,7 +71,10 @@ module Uploadcare
|
|
|
70
71
|
def uploadcare_config_tag(ctx_name:, **options)
|
|
71
72
|
default_options = Uploadcare::Rails.configuration.uploader_config_attributes
|
|
72
73
|
|
|
73
|
-
normalize_key =
|
|
74
|
+
normalize_key = lambda do |key|
|
|
75
|
+
attr_name = key.to_s.tr("_", "-")
|
|
76
|
+
attr_name == "public-key" ? :pubkey : attr_name.to_sym
|
|
77
|
+
end
|
|
74
78
|
normalized_options = options.transform_keys(&normalize_key)
|
|
75
79
|
filtered_options = filter_uploader_config_options(normalized_options)
|
|
76
80
|
|
|
@@ -94,7 +98,21 @@ module Uploadcare
|
|
|
94
98
|
unknown_keys = options.keys - allowed.to_a - data_attributes[:consumed_keys]
|
|
95
99
|
warn_unknown_uploader_options(unknown_keys) if unknown_keys.any?
|
|
96
100
|
|
|
97
|
-
options
|
|
101
|
+
options
|
|
102
|
+
.slice(*allowed.to_a)
|
|
103
|
+
.transform_values { |value| format_uploader_config_value(value) }
|
|
104
|
+
.merge(data_attributes[:attributes])
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def format_uploader_config_value(value)
|
|
108
|
+
case value
|
|
109
|
+
when Hash
|
|
110
|
+
JSON.generate(value)
|
|
111
|
+
when Array
|
|
112
|
+
value.join(",")
|
|
113
|
+
else
|
|
114
|
+
value
|
|
115
|
+
end
|
|
98
116
|
end
|
|
99
117
|
|
|
100
118
|
def extract_data_attributes(options)
|
|
@@ -143,7 +161,7 @@ module Uploadcare
|
|
|
143
161
|
end
|
|
144
162
|
|
|
145
163
|
def uploadcare_file_group_attribute?(object_name, method_name, object: nil)
|
|
146
|
-
model = object_name.to_s.camelize.safe_constantize
|
|
164
|
+
model = object&.class || object_name.to_s.camelize.safe_constantize
|
|
147
165
|
return false unless model
|
|
148
166
|
|
|
149
167
|
checker = "has_uploadcare_files_for_#{method_name}?"
|
data/uploadcare-rails.gemspec
CHANGED
|
@@ -15,13 +15,13 @@ Gem::Specification.new do |gem|
|
|
|
15
15
|
gem.email = [ 'hello@uploadcare.com' ]
|
|
16
16
|
gem.summary = 'Rails gem for Uploadcare'
|
|
17
17
|
gem.description = <<~DESCRIPTION
|
|
18
|
-
Rails
|
|
19
|
-
|
|
18
|
+
Rails integration for Uploadcare built on uploadcare-ruby, with uploader
|
|
19
|
+
helpers, model macros, and Active Storage support.
|
|
20
20
|
DESCRIPTION
|
|
21
21
|
gem.metadata = {
|
|
22
22
|
'source_code_uri' => 'https://github.com/uploadcare/uploadcare-rails',
|
|
23
23
|
'bug_tracker_uri' => 'https://github.com/uploadcare/uploadcare-rails/issues',
|
|
24
|
-
'changelog_uri' => 'https://github.com/uploadcare/uploadcare-rails/blob/
|
|
24
|
+
'changelog_uri' => 'https://github.com/uploadcare/uploadcare-rails/blob/main/CHANGELOG.md',
|
|
25
25
|
'documentation_uri' => 'https://www.rubydoc.info/gems/uploadcare-rails/',
|
|
26
26
|
'homepage_uri' => 'https://uploadcare.com/',
|
|
27
27
|
'rubygems_mfa_required' => 'true'
|
|
@@ -37,13 +37,14 @@ Gem::Specification.new do |gem|
|
|
|
37
37
|
'LICENSE.txt',
|
|
38
38
|
'README.md',
|
|
39
39
|
'CHANGELOG.md',
|
|
40
|
-
'MIGRATING_V5.md'
|
|
40
|
+
'MIGRATING_V5.md',
|
|
41
|
+
'docs/**/*.md'
|
|
41
42
|
]
|
|
42
43
|
|
|
43
44
|
gem.extra_rdoc_files = %w[README.md MIGRATING_V5.md LICENSE.txt]
|
|
44
|
-
gem.rdoc_options = %w[--line-numbers --title Uploadcare --main README.
|
|
45
|
+
gem.rdoc_options = %w[--line-numbers --title Uploadcare --main README.md --encoding=UTF-8]
|
|
45
46
|
|
|
46
47
|
gem.version = Uploadcare::Rails::VERSION
|
|
47
48
|
gem.add_dependency 'rails', '>= 7.2'
|
|
48
|
-
gem.add_dependency 'uploadcare-ruby', '>= 5.0.0
|
|
49
|
+
gem.add_dependency 'uploadcare-ruby', '>= 5.0.0'
|
|
49
50
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uploadcare-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.0.0
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- "@dmitrijivanchenko (Dmitrij Ivanchenko), @T0mbery (Andrey Aksenov)"
|
|
@@ -30,17 +30,17 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 5.0.0
|
|
33
|
+
version: 5.0.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 5.0.0
|
|
40
|
+
version: 5.0.0
|
|
41
41
|
description: |
|
|
42
|
-
Rails
|
|
43
|
-
|
|
42
|
+
Rails integration for Uploadcare built on uploadcare-ruby, with uploader
|
|
43
|
+
helpers, model macros, and Active Storage support.
|
|
44
44
|
email:
|
|
45
45
|
- hello@uploadcare.com
|
|
46
46
|
executables: []
|
|
@@ -56,6 +56,7 @@ files:
|
|
|
56
56
|
- MIGRATING_V5.md
|
|
57
57
|
- README.md
|
|
58
58
|
- Rakefile
|
|
59
|
+
- docs/release-notes-5.0.0.md
|
|
59
60
|
- lib/active_storage/service/uploadcare_service.rb
|
|
60
61
|
- lib/generators/templates/uploadcare_config.yml.erb
|
|
61
62
|
- lib/generators/templates/uploadcare_js_initializer.js
|
|
@@ -97,7 +98,7 @@ licenses:
|
|
|
97
98
|
metadata:
|
|
98
99
|
source_code_uri: https://github.com/uploadcare/uploadcare-rails
|
|
99
100
|
bug_tracker_uri: https://github.com/uploadcare/uploadcare-rails/issues
|
|
100
|
-
changelog_uri: https://github.com/uploadcare/uploadcare-rails/blob/
|
|
101
|
+
changelog_uri: https://github.com/uploadcare/uploadcare-rails/blob/main/CHANGELOG.md
|
|
101
102
|
documentation_uri: https://www.rubydoc.info/gems/uploadcare-rails/
|
|
102
103
|
homepage_uri: https://uploadcare.com/
|
|
103
104
|
rubygems_mfa_required: 'true'
|
|
@@ -106,7 +107,7 @@ rdoc_options:
|
|
|
106
107
|
- "--title"
|
|
107
108
|
- Uploadcare
|
|
108
109
|
- "--main"
|
|
109
|
-
- README.
|
|
110
|
+
- README.md
|
|
110
111
|
- "--encoding=UTF-8"
|
|
111
112
|
require_paths:
|
|
112
113
|
- lib
|