simple_active_storage 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ea0f48286ef738d92dd4ba0c4d1311a382b0cd66
4
- data.tar.gz: 662fbbc5aff26193ab6f886fb58e277f0aa63363
2
+ SHA256:
3
+ metadata.gz: c09916e7b604311ed141ed9384280a19c03e74bcec6740aee56b18afaaa517f9
4
+ data.tar.gz: eba0289e76f641dd870c7ebf6959be60cc5273b446e3db12e4a550942f7701a1
5
5
  SHA512:
6
- metadata.gz: 239eb1a13b25ac140b29165a815cff53d5a38b6475323389d5ca181741faec2559550f1b8e5e44e5c5885497c51f098a14fd1cd5889874b00f708b7ab723fba3
7
- data.tar.gz: 73674b4e1682dd479b5f6013f5b75bc7b200380aebd6d7d3d8cb2c8b3ce23cbd15ac2ece4b455b3e3ca7fbbb411f578d8187b8c65f09a4315188a7cca1e288e1
6
+ metadata.gz: a769fae12817704e8fdafd027ba382e0e031ad90fd0d9d4de9b6a8a1e1fe3f20db27b1467632565f460ceb2515f8731f32cc8d65c3e01f8d6cb39df63d80d2dc
7
+ data.tar.gz: cb7b838f2f74c0937eeac3f3e04b1403493878693bc438b96708973bec2704ca7bf23ca2bdd786a9a462f46b4fe587265f15b2533882fbca367d2967b531b2a3
data/README.md CHANGED
@@ -95,7 +95,7 @@ originally there is no transformations field in json data.
95
95
  the transformations field data is provide by SimpleActiveStorage.
96
96
 
97
97
  ### short cut url
98
- the representation url is very long
98
+ the representation url is very long
99
99
  because rails encrypted transformation information to a very long string
100
100
  ```
101
101
  http://www.example.com/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--578572a7c2d5925ac32622a7d7b832f68c536f51/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9VWTI5dFltbHVaVjl2Y0hScGIyNXpld1k2QzNKbGMybDZaVWtpRERRd01IZzBNREFHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--b87eb27c4abc3f9bd937642f2e5809bfd553edf8/avatar.jpg
@@ -105,7 +105,7 @@ eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9VWTI5dFltbHVaVjl2Y0hScGIyNXpld1k2QzNKbGMy
105
105
  ```
106
106
  this is part of the representation url
107
107
  included transformation information , can be decrypted by rails
108
- if you turned on by set
108
+ if you turned on by set
109
109
  ``` ruby
110
110
  SimpleActiveStorage.config.enable_shortcut_url = true
111
111
  ```
@@ -116,6 +116,14 @@ http://www.example.com/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVz
116
116
  the difference between two urls is that transofrmation(variantation_key) part.
117
117
 
118
118
 
119
+ ### auto remove duplicate blobs
120
+ user = User.first
121
+ avatar = user.avatar
122
+ user.photos.attach avatar.blob
123
+ user.photos.attach avatar.blob # raise error without simple active storage
124
+ user.photos.attachments.size # 1
125
+
126
+
119
127
  ## Installation
120
128
  Add this line to your application's Gemfile:
121
129
 
@@ -3,9 +3,18 @@
3
3
  module SimpleActiveStorage
4
4
  module Attached
5
5
  module Many
6
+ # 检查过滤掉已经存在的
6
7
  def attach(*attachables)
7
8
  record.try(:before_active_storage_attach,attachables)
8
- result = super(*attachables)
9
+
10
+ # remove duplicate attachments
11
+ signed_ids = attachments.map(&:signed_id)
12
+ blobs = attachables.map{|attachable| create_blob_from attachable}.compact
13
+ filtered_blobs = blobs.find_all{|blob|
14
+ !signed_ids.include?(blob.signed_id)
15
+ }
16
+
17
+ result = super(*filtered_blobs)
9
18
  record.try(:after_active_storage_attach,{name: name, attachments: attachments})
10
19
  result
11
20
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleActiveStorage
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_active_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - aotianlong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-09 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.6.12
82
+ rubygems_version: 2.7.8
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: add shortcut variant support for active storage