bizside 2.1.8 → 2.1.10

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
2
  SHA256:
3
- metadata.gz: 20f0b10f92d32ddbec79c248e6c89533070a49087e5e7a5e63eadf66d21dc98d
4
- data.tar.gz: 6776211a6494c3f7ad2baab4e6578189ff0529a4fb9ea5094af8a9cef293ce21
3
+ metadata.gz: db766ed6fdf059cdaa9fd7325c855f84294c988f94559c39597658a674dc6c40
4
+ data.tar.gz: e26eaddb5f279e4d840baae4346d416e6f4467b102dea75a90d301c95a458649
5
5
  SHA512:
6
- metadata.gz: 19aeb39f554f1c783fb2c2138dff4bfbf8865d134c5a8652162c7be999008fece4aaf9a724eb40a23b5028a3c6f3da9702e831930b3397122921feda86b147a4
7
- data.tar.gz: da39892e84bf45a14c913ec6b7b54ec4b61641ea3b1074d7769d1cb029a438af6b6c10e3f42ea44d97bbd8696ec1f188088f28a73a2b068f8fe52115067a7ca0
6
+ metadata.gz: 5635c741923a924331b20dfa0b027e6adfc220a371306f2792f51569e48da21250c6fd0f4dc0d29d7116215edb36e6bcf73a417c1b55d5d19ff6c5317e176c0b
7
+ data.tar.gz: 63c3ba3993e0c9da71c236e9e197be92096330323aa10352f5848478722df2cd5e3ff7f5d716bbc3753fe19bdef56de02ea195591d89ebf73d95e1cd79d33e04
@@ -47,6 +47,66 @@ CarrierWave.configure do |config|
47
47
  config.fog_directory = Bizside.config.storage.fog.container
48
48
  config.fog_public = false
49
49
  config.storage = :fog
50
+
51
+ # Patch to not set ACLs to 'private' if fog_public is false.
52
+ # Requests to set/update ACLs fail if ACL is disabled.
53
+ # Setting 'private' to ACLs also fails when the bucket is not in the same account as IAM user/role.
54
+ # 'private' is applied by default so there's no need to set 'private' explicitly.
55
+ module CarrierWave
56
+ module Storage
57
+ class Fog
58
+ class File
59
+ def acl_header
60
+ if fog_provider == 'AWS'
61
+ @uploader.fog_public ? { 'x-amz-acl' => 'public-read' } : {}
62
+ elsif fog_provider == "Google"
63
+ @uploader.fog_public ? { destination_predefined_acl: "publicRead" } : {}
64
+ else
65
+ {}
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ require 'fog/aws/models/storage/directory'
74
+
75
+ module Fog
76
+ module AWS
77
+ class Storage
78
+ class Directory < Fog::Model
79
+ def public=(new_public)
80
+ if new_public
81
+ @acl = 'public-read'
82
+ else
83
+ @acl = nil
84
+ end
85
+ new_public
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ require 'fog/aws/models/storage/file'
93
+
94
+ module Fog
95
+ module AWS
96
+ class Storage
97
+ class File < Fog::Model
98
+ def public=(new_public)
99
+ if new_public
100
+ @acl = 'public-read'
101
+ else
102
+ @acl = nil
103
+ end
104
+ new_public
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
50
110
  end
51
111
 
52
112
  end
@@ -9,12 +9,7 @@ module Bizside
9
9
 
10
10
  def self.add_job_to(queue, klass, *args)
11
11
  if Bizside.rails_env&.test?
12
- if klass.respond_to?(:before_enqueue)
13
- return unless klass.before_enqueue(*args)
14
- end
15
-
16
- Bizside.logger.info "テスト時にはジョブの登録を行わず、即時実行します。"
17
- klass.perform(*args)
12
+ do_perform_and_hooks_instantly(klass, 'テスト時にはジョブの登録を行わず、即時実行します。', *args)
18
13
  return
19
14
  end
20
15
 
@@ -49,12 +44,7 @@ module Bizside
49
44
 
50
45
  def self.enqueue_at_with_queue(queue, time, klass, *args)
51
46
  if Bizside.rails_env&.test?
52
- if klass.respond_to?(:before_enqueue)
53
- return unless klass.before_enqueue(*args)
54
- end
55
-
56
- Bizside.logger.info "テスト時には遅延ジョブの登録を行わず、即時実行します。"
57
- klass.perform(*args)
47
+ do_perform_and_hooks_instantly(klass, 'テスト時には遅延ジョブの登録を行わず、即時実行します。', *args)
58
48
  return
59
49
  end
60
50
 
@@ -84,12 +74,7 @@ module Bizside
84
74
 
85
75
  def self.set_job_at(time, klass, *args)
86
76
  if Bizside.rails_env&.test?
87
- if klass.respond_to?(:before_enqueue)
88
- return unless klass.before_enqueue(*args)
89
- end
90
-
91
- Bizside.logger.info "テスト時には遅延ジョブの登録を行わず、即時実行します。"
92
- klass.perform(*args)
77
+ do_perform_and_hooks_instantly(klass, 'テスト時には遅延ジョブの登録を行わず、即時実行します。', *args)
93
78
  return
94
79
  end
95
80
 
@@ -214,7 +199,11 @@ module Bizside
214
199
 
215
200
  def self.dequeue(klass, *args)
216
201
  if Bizside.rails_env&.test?
202
+ if klass.respond_to?(:before_dequeue)
203
+ return if klass.before_dequeue(*args) == false
204
+ end
217
205
  Bizside.logger.info 'テスト時にジョブの削除は行いません。'
206
+ klass.after_dequeue(*args) if klass.respond_to?(:after_dequeue)
218
207
  return
219
208
  end
220
209
 
@@ -316,5 +305,65 @@ module Bizside
316
305
  ::Resque::Failure.count(queue, class_name)
317
306
  end
318
307
 
308
+ def self.do_perform_and_hooks_instantly(klass, log_message, *args)
309
+ begin
310
+ if klass.respond_to?(:before_enqueue)
311
+ return if klass.before_enqueue(*args) == false
312
+ end
313
+ rescue
314
+ # should not propagate to on_failure(job code)
315
+ raise
316
+ end
317
+ error_after_queue = nil
318
+ args_to_enqueue = Marshal.load(Marshal.dump(args)) # deep copy
319
+ begin
320
+ klass.after_enqueue(*args) if klass.respond_to?(:after_enqueue)
321
+ rescue => e
322
+ # should propagate only to code that enqueued the job
323
+ error_after_queue = e
324
+ end
325
+
326
+ args = stringify_keys(args_to_enqueue)
327
+
328
+ begin
329
+ begin
330
+ klass.before_perform(*args) if klass.respond_to?(:before_perform)
331
+ rescue ::Resque::Job::DontPerform
332
+ return
333
+ end
334
+
335
+ perform = -> do
336
+ Bizside.logger.info log_message
337
+ klass.perform(*args)
338
+ end
339
+ if klass.respond_to?(:around_perform)
340
+ klass.around_perform(*args, &perform)
341
+ else
342
+ perform.call
343
+ end
344
+
345
+ klass.after_perform(*args) if klass.respond_to?(:after_perform)
346
+ rescue => e
347
+ klass.on_failure(e, *args) if klass.respond_to?(:on_failure)
348
+ raise
349
+ ensure
350
+ raise error_after_queue if error_after_queue
351
+ end
352
+ end
353
+ private_class_method :do_perform_and_hooks_instantly
354
+
355
+ def self.stringify_keys(object)
356
+ case object
357
+ when Hash
358
+ object.map {|k, v| [stringify_keys(k), stringify_keys(v)]}.to_h
359
+ when Array
360
+ object.map {|v| stringify_keys(v)}
361
+ when Symbol
362
+ object.to_s
363
+ else
364
+ object
365
+ end
366
+ end
367
+ private_class_method :stringify_keys
319
368
  end
320
369
  end
@@ -1,3 +1,3 @@
1
1
  module Bizside
2
- VERSION = '2.1.8'
2
+ VERSION = '2.1.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bizside
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.8
4
+ version: 2.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - bizside-developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-04 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -471,8 +471,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
471
471
  - !ruby/object:Gem::Version
472
472
  version: '0'
473
473
  requirements: []
474
- rubyforge_project:
475
- rubygems_version: 2.7.6.2
474
+ rubygems_version: 3.3.16
476
475
  signing_key:
477
476
  specification_version: 4
478
477
  summary: Bizside is an utilities for web application.