Skip to content
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

Add deprecation warning on usage of datetime_stored and clarify README about group delete operation. Closes #131 #160

Merged
merged 3 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ AllCops:

Layout/LineLength:
Max: 120
Exclude:
- 'spec/**/*'

Lint/IneffectiveAccessModifier:
Enabled: false
Expand All @@ -20,6 +22,10 @@ Metrics/BlockLength:
- 'spec/**/*'
- 'uploadcare-ruby.gemspec'

Metrics/ModuleLength:
Exclude:
- 'spec/**/*'

Metrics/MethodLength:
Max: 20

Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Changelog

## Unreleased

### Changed
* File attribute `datetime_stored` is deprecated and will warn on usage from `File` object properties.

## 4.4.0 — 2024-03-09

### Breaking
### Breaking

* Drop support of unmaintainable Ruby versions < 3.x.

Expand Down Expand Up @@ -68,7 +73,7 @@ Add support of new ruby versions
### Breaking Сhanges

- Drop support of unmaintainable Ruby versions (2.4, 2.5, 2.6).
- Replace unmaintainable `api_struct` with `uploadcare-api_struct`
- Replace unmaintainable `api_struct` with `uploadcare-api_struct`

### Added

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ Uploadcare::Group.rest_info(group.id)

# group can be deleted by group ID.
Uploadcare::Group.delete(group.id)
# Note: This operation only removes the group object itself. All the files that were part of the group are left as is.
```

#### GroupList
Expand Down
1 change: 1 addition & 0 deletions lib/uploadcare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ module Uploadcare
setting :upload_threads, default: 2 # used for multiupload only ATM
setting :framework_data, default: ''
setting :file_chunk_size, default: 100
setting :logger, default: Logger.new($stdout)
end
5 changes: 5 additions & 0 deletions lib/uploadcare/entity/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class File < Entity

attr_entity(*RESPONSE_PARAMS)

def datetime_stored
Uploadcare.config.logger&.warn 'datetime_stored property has be deprecated, and will be removed without a replacement in future.' # rubocop:disable Layout/LineLength
@entity.datetime_stored
end

# gets file's uuid - even if it's only initialized with url
# @returns [String]
def uuid
Expand Down
2 changes: 0 additions & 2 deletions spec/uploadcare/entity/addons_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'spec_helper'

# rubocop:disable Metrics/ModuleLength
module Uploadcare
module Entity
RSpec.describe Addons do
Expand Down Expand Up @@ -121,4 +120,3 @@ module Entity
end
end
end
# rubocop:enable Metrics/ModuleLength
15 changes: 15 additions & 0 deletions spec/uploadcare/entity/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ module Entity
end
end

describe 'datetime_stored' do
it 'returns datetime_stored, with deprecated warning' do
VCR.use_cassette('file_info') do
url = 'https://ucarecdn.com/8f64f313-e6b1-4731-96c0-6751f1e7a50a'
file = File.new(url: url)
logger = Uploadcare.config.logger
file.load
allow(logger).to receive(:warn).with('datetime_stored property has be deprecated, and will be removed without a replacement in future.')
datetime_stored = file.datetime_stored
expect(logger).to have_received(:warn).with('datetime_stored property has be deprecated, and will be removed without a replacement in future.')
expect(datetime_stored).not_to be_nil
end
end
end

describe 'load' do
it 'performs load request' do
VCR.use_cassette('file_info') do
Expand Down
2 changes: 1 addition & 1 deletion spec/uploadcare/entity/uploader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
Uploadcare.config.max_request_tries = 1
VCR.use_cassette('upload_upload_from_url') do
url = 'https://placekitten.com/2250/2250'
error_str = 'Upload is taking longer than expected. Try increasing the max_request_tries config if you know your file uploads will take more time.' # rubocop:disable Layout/LineLength
error_str = 'Upload is taking longer than expected. Try increasing the max_request_tries config if you know your file uploads will take more time.'
expect { subject.upload(url) }.to raise_error(RetryError, error_str)
end
end
Expand Down
Loading