active_storage_base64 1.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8467d90fdcbc07a9672049395a208a4a10d32391
4
- data.tar.gz: 961a61666f9a74011ab564875c013ec6461e402e
2
+ SHA256:
3
+ metadata.gz: 2a0d75307a7c96973646ed02733a40ec52456aa67b81d75c24c5be6a1abda375
4
+ data.tar.gz: 64d5fcea8ef73cf23d7182f9ccefea8c70f2629a26b43f0b3eebb35c507cfd14
5
5
  SHA512:
6
- metadata.gz: af92f7ff33c42eba9cc2fdecabd06c36adb967a672df2b77e4bc047ff2dd65d907bd9d6de08f801cb5c84e0f94cbe32fd4bd61b5db8ed9ed3e063ea49ebf7c9e
7
- data.tar.gz: f5638f30bf22ff55b917f2ed816711d3c351c9c5810953b2b1d035486860f075af389ab6f72fcdf2db2bc2ab91bd3ab3308471678ef7b670743dfc3d4a17cd8b
6
+ metadata.gz: 7545063aa84f96ab54044370f0119b698c2c5b54a3951436d81b89352fc1e07fc242288151d2bc05187b7c6bffec287d40bee209f112686e78d9a97004b91aa8
7
+ data.tar.gz: 8b285b0c6d6d5c321b3afd6393f6f67b12167481e565d399a6f610878c8d87ae755284140b2f6119498178754916992069a02222ce2d83c4ff40fcb348b40132
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/rootstrap/active-storage-base64.svg?branch=master)](https://travis-ci.org/rootstrap/active-storage-base64)
1
+ [![CI](https://github.com/rootstrap/active-storage-base64/actions/workflows/ci.yml/badge.svg)](https://github.com/rootstrap/active-storage-base64/actions/workflows/ci.yml)
2
2
  [![Maintainability](https://api.codeclimate.com/v1/badges/0da0a0901cedd72aeb10/maintainability)](https://codeclimate.com/github/rootstrap/active-storage-base64/maintainability)
3
3
  [![Test Coverage](https://api.codeclimate.com/v1/badges/0da0a0901cedd72aeb10/test_coverage)](https://codeclimate.com/github/rootstrap/active-storage-base64/test_coverage)
4
4
 
@@ -13,9 +13,18 @@ In order to get the gem working on your project you just need to add the gem to
13
13
  gem 'active_storage_base64'
14
14
  ```
15
15
 
16
+ ## Compatibility
17
+ Rails Version | ActiveStorageBase64 Version
18
+ --------------|-----------------------------
19
+ 7.1.x | 3.0.x
20
+ 7.0.x | 2.0.x
21
+ 6.1.x | 1.2.x
22
+ 6.0.x | 1.1.x
23
+ 5.2.x | 0.1.x
24
+
16
25
  ## Prerequisites
17
26
 
18
- The only prerequisites for using this gem are having Rails version 5.2.0 or higher installed on your project and having ActiveStorage properly set up (for more information on how to do this, check [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html))
27
+ The only prerequisite for using this gem is having ActiveStorage properly set up in your project. For more information on how to do this, check [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html).
19
28
 
20
29
  ## Usage
21
30
 
@@ -14,6 +14,7 @@ module ActiveStorageSupport
14
14
  attachment
15
15
  end
16
16
 
17
+ # rubocop:disable Metrics/AbcSize
17
18
  def fill_attachment_data(attachment, base64_data)
18
19
  return unless base64_data.try(:is_a?, String) && base64_data.strip.start_with?('data')
19
20
 
@@ -24,6 +25,7 @@ module ActiveStorageSupport
24
25
  attachment[:content_type] ||= content_type(headers)
25
26
  attachment[:filename] ||= Time.current.to_i.to_s
26
27
  end
28
+ # rubocop:enable Metrics/AbcSize
27
29
 
28
30
  def content_type(headers)
29
31
  headers =~ /^data:(.*?)$/
@@ -5,8 +5,8 @@ module ActiveStorageSupport
5
5
  module SupportForBase64
6
6
  extend ActiveSupport::Concern
7
7
  class_methods do
8
- def has_one_base64_attached(name, dependent: :purge_later, service: nil, strict_loading: false)
9
- has_one_attached name, dependent: dependent, service: service, strict_loading: strict_loading
8
+ def has_one_base64_attached(name, dependent: :purge_later, service: nil, strict_loading: false, &block)
9
+ has_one_attached name, dependent: dependent, service: service, strict_loading: strict_loading, &block
10
10
 
11
11
  generated_association_methods.class_eval <<-CODE, __FILE__, __LINE__ + 1
12
12
  # frozen_string_literal: true
@@ -14,9 +14,10 @@ module ActiveStorageSupport
14
14
  @active_storage_attached ||= {}
15
15
  @active_storage_attached[:#{name}] ||= ActiveStorageSupport::Base64One.new("#{name}", self)
16
16
  end
17
+
17
18
  def #{name}=(attachable)
18
19
  attachment_changes["#{name}"] =
19
- if attachable.nil?
20
+ if attachable.nil? || attachable == ""
20
21
  ActiveStorage::Attached::Changes::DeleteOne.new("#{name}", self)
21
22
  else
22
23
  ActiveStorage::Attached::Changes::CreateOne.new(
@@ -27,8 +28,8 @@ module ActiveStorageSupport
27
28
  CODE
28
29
  end
29
30
 
30
- def has_many_base64_attached(name, dependent: :purge_later, service: nil, strict_loading: false)
31
- has_many_attached name, dependent: dependent, service: service, strict_loading: strict_loading
31
+ def has_many_base64_attached(name, dependent: :purge_later, service: nil, strict_loading: false, &block)
32
+ has_many_attached name, dependent: dependent, service: service, strict_loading: strict_loading, &block
32
33
 
33
34
  generated_association_methods.class_eval <<-CODE, __FILE__, __LINE__ + 1
34
35
  # frozen_string_literal: true
@@ -36,23 +37,17 @@ module ActiveStorageSupport
36
37
  @active_storage_attached ||= {}
37
38
  @active_storage_attached[:#{name}] ||= ActiveStorageSupport::Base64Many.new("#{name}", self)
38
39
  end
40
+
39
41
  def #{name}=(attachables)
40
- if ActiveStorage.replace_on_assign_to_many
41
- attachment_changes["#{name}"] =
42
- if Array(attachables).none?
43
- ActiveStorage::Attached::Changes::DeleteMany.new("#{name}", self)
44
- else
45
- ActiveStorage::Attached::Changes::CreateMany.new(
46
- "#{name}", self, ActiveStorageSupport::Base64Many.from_base64(attachables)
47
- )
48
- end
42
+ attachables = Array(attachables).compact_blank
43
+ pending_uploads = attachment_changes["#{name}"].try(:pending_uploads)
44
+
45
+ attachment_changes["#{name}"] = if attachables.none?
46
+ ActiveStorage::Attached::Changes::DeleteMany.new("#{name}", self)
49
47
  else
50
- if Array(attachables).any?
51
- attachment_changes["#{name}"] =
52
- ActiveStorage::Attached::Changes::CreateMany.new(
53
- "#{name}", self, #{name}.blobs + ActiveStorageSupport::Base64Many.from_base64(attachables)
54
- )
55
- end
48
+ ActiveStorage::Attached::Changes::CreateMany.new(
49
+ "#{name}", self, ActiveStorageSupport::Base64Many.from_base64(attachables), pending_uploads: pending_uploads
50
+ )
56
51
  end
57
52
  end
58
53
  CODE
metadata CHANGED
@@ -1,29 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage_base64
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Cortio
8
- autorequire:
8
+ - Santiago Bartesaghi
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-12-14 00:00:00.000000000 Z
12
+ date: 2023-09-19 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: rails
15
+ name: activestorage
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - "~>"
18
+ - - ">"
18
19
  - !ruby/object:Gem::Version
19
- version: '6.1'
20
+ version: '7.0'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - "~>"
25
+ - - ">"
25
26
  - !ruby/object:Gem::Version
26
- version: '6.1'
27
+ version: '7.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">"
33
+ - !ruby/object:Gem::Version
34
+ version: '7.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">"
40
+ - !ruby/object:Gem::Version
41
+ version: '7.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rails
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">"
47
+ - !ruby/object:Gem::Version
48
+ version: '7.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">"
54
+ - !ruby/object:Gem::Version
55
+ version: '7.0'
27
56
  - !ruby/object:Gem::Dependency
28
57
  name: pry-rails
29
58
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +73,14 @@ dependencies:
44
73
  requirements:
45
74
  - - "~>"
46
75
  - !ruby/object:Gem::Version
47
- version: 5.5.0
76
+ version: 6.0.6
48
77
  type: :development
49
78
  prerelease: false
50
79
  version_requirements: !ruby/object:Gem::Requirement
51
80
  requirements:
52
81
  - - "~>"
53
82
  - !ruby/object:Gem::Version
54
- version: 5.5.0
83
+ version: 6.0.6
55
84
  - !ruby/object:Gem::Dependency
56
85
  name: rspec-rails
57
86
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +101,14 @@ dependencies:
72
101
  requirements:
73
102
  - - "~>"
74
103
  - !ruby/object:Gem::Version
75
- version: 0.56.0
104
+ version: 1.22.0
76
105
  type: :development
77
106
  prerelease: false
78
107
  version_requirements: !ruby/object:Gem::Requirement
79
108
  requirements:
80
109
  - - "~>"
81
110
  - !ruby/object:Gem::Version
82
- version: 0.56.0
111
+ version: 1.22.0
83
112
  - !ruby/object:Gem::Dependency
84
113
  name: simplecov
85
114
  requirement: !ruby/object:Gem::Requirement
@@ -100,16 +129,32 @@ dependencies:
100
129
  requirements:
101
130
  - - '='
102
131
  - !ruby/object:Gem::Version
103
- version: 1.4.1
132
+ version: 1.4.2
104
133
  type: :development
105
134
  prerelease: false
106
135
  version_requirements: !ruby/object:Gem::Requirement
107
136
  requirements:
108
137
  - - '='
109
138
  - !ruby/object:Gem::Version
110
- version: 1.4.1
139
+ version: 1.4.2
140
+ - !ruby/object:Gem::Dependency
141
+ name: image_processing
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '1.2'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '1.2'
111
154
  description: Base64 support for ActiveStorage
112
- email: ricardo@rootstrap.com
155
+ email:
156
+ - ricardo@rootstrap.com
157
+ - santiago.bartesaghi@rootstrap.com
113
158
  executables: []
114
159
  extensions: []
115
160
  extra_rdoc_files: []
@@ -125,7 +170,7 @@ homepage: https://github.com/rootstrap/active-storage-base64
125
170
  licenses:
126
171
  - MIT
127
172
  metadata: {}
128
- post_install_message:
173
+ post_install_message:
129
174
  rdoc_options: []
130
175
  require_paths:
131
176
  - lib
@@ -133,16 +178,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
178
  requirements:
134
179
  - - ">="
135
180
  - !ruby/object:Gem::Version
136
- version: 2.5.0
181
+ version: 2.7.0
137
182
  required_rubygems_version: !ruby/object:Gem::Requirement
138
183
  requirements:
139
184
  - - ">="
140
185
  - !ruby/object:Gem::Version
141
186
  version: '0'
142
187
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.5.2.3
145
- signing_key:
188
+ rubygems_version: 3.4.6
189
+ signing_key:
146
190
  specification_version: 4
147
191
  summary: Base64 support for ActiveStorage
148
192
  test_files: []