mini_paperclip 0.2.0 → 0.3.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
2
  SHA256:
3
- metadata.gz: cda880f15d0e468fe2e0468658dbd11bf52a933e79f936fdc1a16ade88536e79
4
- data.tar.gz: 9bf633f6dd48be4fc3f41b4539568039ab710a0a61e43e47ea297221599588af
3
+ metadata.gz: 909b57103a53df47bb30daf06f36b572d9dfe274cba465e9a21ba9fae57d7e2b
4
+ data.tar.gz: d1420ac6ca79918f0f424aa9f3216e92876e5109e8116c3221995cd903d49b1a
5
5
  SHA512:
6
- metadata.gz: e0fd8c9651b0bfbb7e9c79faf6476644983a56256ebe856fdb0e379e97b6f35e5b30ec64ab2d8dc474f3f5617965b0bf598d48d712bf211d9d8c30d3162d4697
7
- data.tar.gz: 35aeb9655dc45afd56b72ad0e98659218035a26494a345af6352a505d123945c113f1947946341c526e8a2314b6ea2974dd6c2678142105dd4f6e6a459d31d3e
6
+ metadata.gz: dc30ba93963b6380a814552dcbfe556122fb6315ec7a3825aed595ac04c77838f38aeb65852fb922db6ff8fbed699243c1006d23316881622d989402d6487fbd
7
+ data.tar.gz: 5f764c680865d71fa9c211566e2354d00a0ba2cf712292ff02ef69da1c39b7a7888ed25186f2e0f00d211eb245eaf3cb3875d6cd4c79ac2ac2f8cac9c9152b5b
@@ -37,5 +37,8 @@ jobs:
37
37
  ruby-version: ${{ matrix.ruby }}
38
38
  - name: Install dependencies
39
39
  run: bundle install --gemfile=${{ matrix.gemfile }}
40
- - name: Run tests
40
+ - name: Run tests and Print coverage
41
+ env:
42
+ COVERAGE: 1
43
+ LOGLEVEL: info
41
44
  run: bundle exec --gemfile=${{ matrix.gemfile }} rake
data/README.md CHANGED
@@ -71,6 +71,7 @@ MiniPaperclip.config.tap do |config|
71
71
  config.s3_acl # s3 object acl
72
72
  config.s3_cache_control # Set this value to Cache-Control header when put-object
73
73
  config.interpolates # minimum templates using by `String#gsub!`
74
+ config.keep_old_files # Delete old attached file if it's false (default false)
74
75
  config.read_timeout # timeout when attachment set url
75
76
  config.logger # You can set logger object.
76
77
  end
@@ -34,6 +34,7 @@ module MiniPaperclip
34
34
  },
35
35
  hash_data: ":class/:attachment/:id/:style/:updated_at",
36
36
  url_missing_path: ":attachment/:style/missing.png",
37
+ keep_old_files: false,
37
38
  read_timeout: 60,
38
39
  logger: Logger.new($stdout),
39
40
  )
@@ -61,6 +61,10 @@ module MiniPaperclip
61
61
  @waiting_write_file = nil
62
62
  @meta_content_type = nil
63
63
 
64
+ if present?
65
+ push_delete_files
66
+ end
67
+
64
68
  if file.nil?
65
69
  assign_nil
66
70
  elsif file.instance_of?(Attachment)
@@ -116,6 +120,12 @@ module MiniPaperclip
116
120
  @storage.write(style, temp)
117
121
  end
118
122
  end
123
+
124
+ # should delete after write for copy
125
+ if !@config.keep_old_files
126
+ do_delete_files
127
+ end
128
+
119
129
  ensure
120
130
  if @waiting_write_file.respond_to?(:close!)
121
131
  @waiting_write_file.close!
@@ -8,7 +8,7 @@ module MiniPaperclip
8
8
  instance_variable_set("@#{attachment_name}", Attachment.new(self, attachment_name, option_config))
9
9
  end
10
10
  define_method("#{attachment_name}=") do |file|
11
- a = Attachment.new(self, attachment_name, option_config)
11
+ a = public_send(attachment_name)
12
12
  a.assign(file)
13
13
  instance_variable_set("@#{attachment_name}", a)
14
14
  end
@@ -16,6 +16,7 @@ module MiniPaperclip
16
16
  :s3_acl,
17
17
  :s3_cache_control,
18
18
  :interpolates,
19
+ :keep_old_files,
19
20
  :read_timeout,
20
21
  :logger,
21
22
  keyword_init: true,
@@ -27,6 +27,7 @@ module MiniPaperclip
27
27
  end
28
28
 
29
29
  def do_delete_files
30
+ return if @deletes.empty?
30
31
  debug("deleting by filesystem #{@deletes}")
31
32
  FileUtils.rm_f(@deletes)
32
33
  end
@@ -39,6 +39,7 @@ module MiniPaperclip
39
39
  end
40
40
 
41
41
  def do_delete_files
42
+ return if @deletes.empty?
42
43
  debug("deleting by S3 to bucket:#{@config.s3_bucket_name},objects:#{@deletes}")
43
44
  Aws::S3::Client.new.delete_objects(
44
45
  bucket: @config.s3_bucket_name,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniPaperclip
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-11 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -101,7 +101,7 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".github/workflows/ruby.yml"
104
+ - ".github/workflows/ci.yml"
105
105
  - ".gitignore"
106
106
  - ".rspec"
107
107
  - CODE_OF_CONDUCT.md
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.0.3
162
+ rubygems_version: 3.1.4
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: MiniPaperclip is a mini paperclip