active_storage_base64 1.2.0 → 2.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: 7f6c1d529089b0f279a3772aa6dd1aa44dce8bc5b0eca8cbca52433a786bbc98
4
+ data.tar.gz: fd92fb0cae792e16221301f59d346a73df4d60579f1f4dbb36235f29f6f242ae
5
5
  SHA512:
6
- metadata.gz: af92f7ff33c42eba9cc2fdecabd06c36adb967a672df2b77e4bc047ff2dd65d907bd9d6de08f801cb5c84e0f94cbe32fd4bd61b5db8ed9ed3e063ea49ebf7c9e
7
- data.tar.gz: f5638f30bf22ff55b917f2ed816711d3c351c9c5810953b2b1d035486860f075af389ab6f72fcdf2db2bc2ab91bd3ab3308471678ef7b670743dfc3d4a17cd8b
6
+ metadata.gz: c1def5ffac22e0f855862672df7f629d5bf0cbe77b1c5ceec49dc08aad849d9957a84f82357e664fb2d2d2feb2f7750416a340f4b0bcd5f90e4eb5fc8667d583
7
+ data.tar.gz: bbf89ca79423cb55dca6ac6f8dbe4a4769725fcfa5d42dc85c842eb86e965336ef7a57d85bfaf296fd75959d6f79e3f0c1c2784b61d3dd425b8ef7dab735d270
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
 
@@ -15,7 +15,7 @@ gem 'active_storage_base64'
15
15
 
16
16
  ## Prerequisites
17
17
 
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))
18
+ The only prerequisites for using this gem are having Rails version 6.1 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))
19
19
 
20
20
  ## Usage
21
21
 
@@ -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,6 +14,7 @@ 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
20
  if attachable.nil?
@@ -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,6 +37,7 @@ 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
42
  if ActiveStorage.replace_on_assign_to_many
41
43
  attachment_changes["#{name}"] =
@@ -47,6 +49,12 @@ module ActiveStorageSupport
47
49
  )
48
50
  end
49
51
  else
52
+ ActiveSupport::Deprecation.warn \
53
+ "config.active_storage.replace_on_assign_to_many is deprecated and will be removed in Rails 7.1. " \
54
+ "Make sure that your code works well with config.active_storage.replace_on_assign_to_many set to true before upgrading. " \
55
+ "To append new attachables to the Active Storage association, prefer using `attach`. " \
56
+ "Using association setter would result in purging the existing attached attachments and replacing them with new ones."
57
+
50
58
  if Array(attachables).any?
51
59
  attachment_changes["#{name}"] =
52
60
  ActiveStorage::Attached::Changes::CreateMany.new(
metadata CHANGED
@@ -1,29 +1,30 @@
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: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Cortio
8
+ - Santiago Bartesaghi
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-12-14 00:00:00.000000000 Z
12
+ date: 2021-12-23 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
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'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: pry-rails
29
30
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +45,14 @@ dependencies:
44
45
  requirements:
45
46
  - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: 5.5.0
48
+ version: 6.0.6
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
- version: 5.5.0
55
+ version: 6.0.6
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: rspec-rails
57
58
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +73,14 @@ dependencies:
72
73
  requirements:
73
74
  - - "~>"
74
75
  - !ruby/object:Gem::Version
75
- version: 0.56.0
76
+ version: 1.22.0
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
81
  - - "~>"
81
82
  - !ruby/object:Gem::Version
82
- version: 0.56.0
83
+ version: 1.22.0
83
84
  - !ruby/object:Gem::Dependency
84
85
  name: simplecov
85
86
  requirement: !ruby/object:Gem::Requirement
@@ -100,16 +101,32 @@ dependencies:
100
101
  requirements:
101
102
  - - '='
102
103
  - !ruby/object:Gem::Version
103
- version: 1.4.1
104
+ version: 1.4.2
104
105
  type: :development
105
106
  prerelease: false
106
107
  version_requirements: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - '='
109
110
  - !ruby/object:Gem::Version
110
- version: 1.4.1
111
+ version: 1.4.2
112
+ - !ruby/object:Gem::Dependency
113
+ name: image_processing
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '1.2'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '1.2'
111
126
  description: Base64 support for ActiveStorage
112
- email: ricardo@rootstrap.com
127
+ email:
128
+ - ricardo@rootstrap.com
129
+ - santiago.bartesaghi@rootstrap.com
113
130
  executables: []
114
131
  extensions: []
115
132
  extra_rdoc_files: []
@@ -133,15 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
150
  requirements:
134
151
  - - ">="
135
152
  - !ruby/object:Gem::Version
136
- version: 2.5.0
153
+ version: 2.7.0
137
154
  required_rubygems_version: !ruby/object:Gem::Requirement
138
155
  requirements:
139
156
  - - ">="
140
157
  - !ruby/object:Gem::Version
141
158
  version: '0'
142
159
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.5.2.3
160
+ rubygems_version: 3.0.3
145
161
  signing_key:
146
162
  specification_version: 4
147
163
  summary: Base64 support for ActiveStorage