activestorage-delayed 0.2.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +6 -38
- data/.github/workflows/ruby.yml +8 -23
- data/.idea/activestorage-delayed.iml +56 -33
- data/README.md +11 -4
- data/lib/activestorage-delayed/delayed_concern.rb +8 -3
- data/lib/activestorage-delayed/delayed_uploader.rb +11 -10
- data/lib/activestorage-delayed/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28e99a88c820e43d1a17fb11ebdd37a116cb27bdccc1337c09854962b27d3a7b
|
4
|
+
data.tar.gz: 99a2174762bd1f6aab22b204ed321a46f7f2b01478c07f22a48ff1e68ceba9f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 035413b7b1412f8ff6d230c96147e56d450c5c32c5ab1d69556a1b8bbbd095ba208eea0430bca146cb41ae831552cf0f6c6c6e848da85ba0e0059c5499b96b5b
|
7
|
+
data.tar.gz: e9ab0587c96b020947e0224ae4fee5fac96ecca1fb99acaa417b476ad2ad91e09bb44a1d2b8cfaefbd2f12a87c148e22a4f509f8a3c45346fb65800d5b0b00b7
|
@@ -1,43 +1,11 @@
|
|
1
|
+
name: Create release from tag
|
1
2
|
on:
|
2
3
|
push:
|
3
|
-
tags: #
|
4
|
+
tags: # Create a release once a git tag is published
|
4
5
|
- '*'
|
5
6
|
|
6
|
-
name: Create Release
|
7
|
-
|
8
7
|
jobs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
- name: Checkout code
|
14
|
-
uses: actions/checkout@v2
|
15
|
-
with:
|
16
|
-
fetch-depth: 0
|
17
|
-
|
18
|
-
# Changelog action adaptations
|
19
|
-
- name: Create required package.json
|
20
|
-
run: test -f package.json || echo '{}' >package.json
|
21
|
-
- name: Detect Previous Tag (action not detecting very well)
|
22
|
-
run: echo "::set-output name=previous_tag::$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)"
|
23
|
-
id: tag_checker
|
24
|
-
|
25
|
-
- name: Generate Changelog
|
26
|
-
uses: scottbrenner/generate-changelog-action@master
|
27
|
-
id: Changelog
|
28
|
-
with:
|
29
|
-
from-tag: ${{steps.tag_checker.outputs.previous_tag}}
|
30
|
-
to-tag: HEAD
|
31
|
-
|
32
|
-
- name: Create Release
|
33
|
-
id: create_release
|
34
|
-
uses: actions/create-release@latest
|
35
|
-
env:
|
36
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
37
|
-
with:
|
38
|
-
tag_name: ${{ github.ref }}
|
39
|
-
release_name: Release ${{ github.ref }}
|
40
|
-
body: |
|
41
|
-
${{ steps.Changelog.outputs.changelog }}
|
42
|
-
draft: false
|
43
|
-
prerelease: false
|
8
|
+
release-builder:
|
9
|
+
uses: owen2345/reusable-ci-cd-actions/.github/workflows/release_builder_from_tag.yml@main
|
10
|
+
with:
|
11
|
+
commit_mode: true
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,31 +1,16 @@
|
|
1
1
|
name: App tests
|
2
|
-
|
3
2
|
on:
|
4
3
|
push:
|
5
4
|
branches:
|
6
5
|
- main
|
7
|
-
-
|
6
|
+
- master
|
8
7
|
pull_request:
|
9
8
|
|
10
9
|
jobs:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
uses: styfle/cancel-workflow-action@0.6.0
|
19
|
-
with:
|
20
|
-
access_token: ${{ github.token }}
|
21
|
-
- name: download docker-compose cache
|
22
|
-
run: docker-compose pull
|
23
|
-
- uses: satackey/action-docker-layer-caching@v0.0.11 # Cache or restore docker cache
|
24
|
-
continue-on-error: true # Ignore the failure of a step and avoid terminating the job.
|
25
|
-
with:
|
26
|
-
key: app-cache-${{ hashFiles('Dockerfile') }}
|
27
|
-
|
28
|
-
- name: Run rspec test
|
29
|
-
run: docker-compose run test /bin/sh -c "bundle install && rspec"
|
30
|
-
- name: Check codestyle
|
31
|
-
run: docker-compose run test /bin/sh -c "rubocop"
|
10
|
+
app-tests:
|
11
|
+
uses: owen2345/reusable-ci-cd-actions/.github/workflows/tests.yml@main
|
12
|
+
with:
|
13
|
+
prepare_db_cmd: null
|
14
|
+
copy_env: false
|
15
|
+
run_rubocop: true
|
16
|
+
rspec_cmd: 'bundle install && bundle exec rspec'
|
@@ -10,40 +10,63 @@
|
|
10
10
|
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
11
|
<excludeFolder url="file://$MODULE_DIR$/spec/dummy/tmp/cache" />
|
12
12
|
</content>
|
13
|
-
<orderEntry type="jdk" jdkName="Remote: ruby-
|
13
|
+
<orderEntry type="jdk" jdkName="Remote: ruby-3.1.1-p18" jdkType="RUBY_SDK" />
|
14
14
|
<orderEntry type="sourceFolder" forTests="false" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
29
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
30
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
34
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
35
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
36
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
37
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
38
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
39
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
40
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
41
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
42
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
43
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
44
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
45
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
46
|
-
<orderEntry type="library" scope="PROVIDED" name="
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="actioncable (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="actionmailbox (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="actionpack (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="actiontext (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="actionview (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="activejob (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="activemodel (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="activerecord (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="activestorage (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="byebug (v11.1.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="capybara (v3.36.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="database_cleaner-active_record (v2.0.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="database_cleaner-core (v2.0.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="digest (v3.1.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="erubi (v1.10.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="factory_bot_rails (v6.2.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
39
|
+
<orderEntry type="library" scope="PROVIDED" name="globalid (v1.0.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
40
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
41
|
+
<orderEntry type="library" scope="PROVIDED" name="mail (v2.7.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="marcel (v1.0.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="matrix (v0.4.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
44
|
+
<orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
45
|
+
<orderEntry type="library" scope="PROVIDED" name="mini_mime (v1.1.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
46
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
47
|
+
<orderEntry type="library" scope="PROVIDED" name="net-imap (v0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
48
|
+
<orderEntry type="library" scope="PROVIDED" name="net-pop (v0.1.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
49
|
+
<orderEntry type="library" scope="PROVIDED" name="net-smtp (v0.3.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
50
|
+
<orderEntry type="library" scope="PROVIDED" name="nio4r (v2.5.8, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
51
|
+
<orderEntry type="library" scope="PROVIDED" name="racc (v1.6.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
52
|
+
<orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
53
|
+
<orderEntry type="library" scope="PROVIDED" name="rack-test (v1.1.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
54
|
+
<orderEntry type="library" scope="PROVIDED" name="rails (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
55
|
+
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
56
|
+
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.4.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
57
|
+
<orderEntry type="library" scope="PROVIDED" name="railties (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
58
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
59
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
60
|
+
<orderEntry type="library" scope="PROVIDED" name="rbs (v2.1.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
61
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
62
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
63
|
+
<orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
64
|
+
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
65
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
66
|
+
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.7.5, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
67
|
+
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
68
|
+
<orderEntry type="library" scope="PROVIDED" name="xpath (v3.2.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
69
|
+
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.4, Remote: ruby-3.1.1-p18) [gem]" level="application" />
|
47
70
|
</component>
|
48
71
|
<component name="RakeTasksCache">
|
49
72
|
<option name="myRootTask">
|
data/README.md
CHANGED
@@ -105,8 +105,10 @@ end
|
|
105
105
|
- Capture event when file upload has failed: `<attr_name>_error_upload`
|
106
106
|
```ruby
|
107
107
|
class User < ApplicationRecord
|
108
|
-
|
109
|
-
|
108
|
+
# @param error [StandardError]
|
109
|
+
# @param file_data [Hash<'filename'>]
|
110
|
+
def photo_error_upload(error, file_data)
|
111
|
+
puts "Failed uploading photo #{file_data['filename']}: #{error.message}"
|
110
112
|
end
|
111
113
|
end
|
112
114
|
```
|
@@ -114,8 +116,13 @@ end
|
|
114
116
|
- Capture event when file has been uploaded: `<attr_name>_after_upload`
|
115
117
|
```ruby
|
116
118
|
class User < ApplicationRecord
|
117
|
-
|
118
|
-
|
119
|
+
# @param file_data [Hash<'filename'>]
|
120
|
+
def photo_after_upload(file_data)
|
121
|
+
puts "Photo #{file_data['filename']} has been uploaded"
|
122
|
+
end
|
123
|
+
|
124
|
+
def photo_after_upload_all
|
125
|
+
puts "All photos have been uploaded"
|
119
126
|
end
|
120
127
|
end
|
121
128
|
```
|
@@ -37,14 +37,19 @@ module ActivestorageDelayed
|
|
37
37
|
name = File.basename(filename, '.*').parameterize
|
38
38
|
is_multiple = send(attr_name).class.name.include?('Many')
|
39
39
|
name = "#{SecureRandom.uuid}-#{name}" if is_multiple
|
40
|
-
"#{send(:id)}-#{name}#{File.extname(filename)}"
|
40
|
+
"#{send(:id)}-#{name}-#{Time.current.to_i}#{File.extname(filename)}"
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
# @param _file_data [Hash<'filename'>]
|
44
|
+
define_method "#{attr_name}_after_upload" do |_file_data|
|
45
|
+
end
|
46
|
+
|
47
|
+
define_method "#{attr_name}_after_upload_all" do
|
44
48
|
end
|
45
49
|
|
46
50
|
# @param _error (Exception)
|
47
|
-
|
51
|
+
# @param _file_data [Hash<'filename'>]
|
52
|
+
define_method "#{attr_name}_error_upload" do |_error, _file_data|
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
@@ -13,38 +13,39 @@ module ActivestorageDelayed
|
|
13
13
|
return unless delayed_upload
|
14
14
|
|
15
15
|
remove_files
|
16
|
-
|
16
|
+
upload_photos
|
17
|
+
save_changes
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
20
21
|
|
21
22
|
def upload_photos
|
22
23
|
tmp_files_data.each(&method(:upload_photo))
|
23
|
-
model.send("#{attr_name}_after_upload")
|
24
|
-
true
|
25
|
-
rescue => e # rubocop:disable Style/RescueStandardError
|
26
|
-
print_failure(e)
|
27
|
-
false
|
28
24
|
end
|
29
25
|
|
30
26
|
def upload_photo(file_data)
|
31
27
|
parse_file_io(file_data) do |io|
|
32
28
|
file_data['io'] = io
|
33
29
|
model.send(attr_name).attach(file_data.transform_keys(&:to_sym))
|
30
|
+
model.send("#{attr_name}_after_upload", file_data)
|
31
|
+
rescue => e # rubocop:disable Style/RescueStandardError
|
32
|
+
print_failure(e, file_data)
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
|
-
def print_failure(error)
|
38
|
-
|
39
|
-
|
36
|
+
def print_failure(error, file_data = {})
|
37
|
+
details = "#{error.message}. #{error.backtrace[0..20]}"
|
38
|
+
Rails.logger.error("***#{self.class.name} -> Failed uploading file (#{file_data['filename']}): #{details}")
|
39
|
+
model.send("#{attr_name}_error_upload", error, file_data)
|
40
40
|
end
|
41
41
|
|
42
42
|
def save_changes
|
43
43
|
model.save!
|
44
44
|
delayed_upload.destroy!
|
45
|
+
model.send("#{attr_name}_after_upload_all")
|
45
46
|
end
|
46
47
|
|
47
|
-
# @return [Array<Hash<io: StringIO, filename: String, content_type: String
|
48
|
+
# @return [Array<Hash<io: StringIO, filename: String, content_type: String>>]
|
48
49
|
def tmp_files_data
|
49
50
|
@tmp_files_data ||= begin
|
50
51
|
files = JSON.parse(delayed_upload.files || '[]')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage-delayed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Peredo Diaz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage
|