carrierwave_backgrounder 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
data/lib/backgrounder/version.rb
CHANGED
data/lib/backgrounder/workers.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module CarrierWave
|
2
|
+
module Workers
|
3
|
+
class Base < Struct.new(:klass, :id, :column)
|
4
|
+
|
5
|
+
def self.perform(*args)
|
6
|
+
new(*args).perform
|
7
|
+
end
|
8
|
+
|
9
|
+
def perform(*args)
|
10
|
+
set_args(*args) if args.present?
|
11
|
+
constantized_resource.find id
|
12
|
+
rescue *not_found_errors
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def not_found_errors
|
18
|
+
[].tap do |errors|
|
19
|
+
errors << ::ActiveRecord::RecordNotFound if defined?(::ActiveRecord)
|
20
|
+
errors << ::Mongoid::Errors::DocumentNotFound if defined?(::Mongoid)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_args(klass, id, column)
|
25
|
+
self.klass, self.id, self.column = klass, id, column
|
26
|
+
end
|
27
|
+
|
28
|
+
def constantized_resource
|
29
|
+
klass.is_a?(String) ? klass.constantize : klass
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -2,14 +2,10 @@
|
|
2
2
|
module CarrierWave
|
3
3
|
module Workers
|
4
4
|
|
5
|
-
class ProcessAsset <
|
6
|
-
def self.perform(*args)
|
7
|
-
new(*args).perform
|
8
|
-
end
|
5
|
+
class ProcessAsset < Base
|
9
6
|
|
10
7
|
def perform(*args)
|
11
|
-
|
12
|
-
record = constantized_resource.find id
|
8
|
+
record = super(*args)
|
13
9
|
|
14
10
|
if record
|
15
11
|
record.send(:"process_#{column}_upload=", true)
|
@@ -19,16 +15,6 @@ module CarrierWave
|
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
|
-
private
|
23
|
-
|
24
|
-
def set_args(klass, id, column)
|
25
|
-
self.klass, self.id, self.column = klass, id, column
|
26
|
-
end
|
27
|
-
|
28
|
-
def constantized_resource
|
29
|
-
klass.is_a?(String) ? klass.constantize : klass
|
30
|
-
end
|
31
|
-
|
32
18
|
end # ProcessAsset
|
33
19
|
|
34
20
|
end # Workers
|
@@ -2,16 +2,11 @@
|
|
2
2
|
module CarrierWave
|
3
3
|
module Workers
|
4
4
|
|
5
|
-
class StoreAsset <
|
5
|
+
class StoreAsset < Base
|
6
6
|
attr_reader :cache_path, :tmp_directory
|
7
7
|
|
8
|
-
def self.perform(*args)
|
9
|
-
new(*args).perform
|
10
|
-
end
|
11
|
-
|
12
8
|
def perform(*args)
|
13
|
-
|
14
|
-
record = constantized_resource.find id
|
9
|
+
record = super(*args)
|
15
10
|
|
16
11
|
if record.send(:"#{column}_tmp")
|
17
12
|
store_directories(record)
|
@@ -27,14 +22,6 @@ module CarrierWave
|
|
27
22
|
|
28
23
|
private
|
29
24
|
|
30
|
-
def set_args(klass, id, column)
|
31
|
-
self.klass, self.id, self.column = klass, id, column
|
32
|
-
end
|
33
|
-
|
34
|
-
def constantized_resource
|
35
|
-
klass.is_a?(String) ? klass.constantize : klass
|
36
|
-
end
|
37
|
-
|
38
25
|
def store_directories(record)
|
39
26
|
asset, asset_tmp = record.send(:"#{column}"), record.send(:"#{column}_tmp")
|
40
27
|
cache_directory = File.expand_path(asset.cache_dir, asset.root)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave_backgrounder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carrierwave
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/backgrounder/support/backends.rb
|
99
99
|
- lib/backgrounder/version.rb
|
100
100
|
- lib/backgrounder/workers.rb
|
101
|
+
- lib/backgrounder/workers/base.rb
|
101
102
|
- lib/backgrounder/workers/process_asset.rb
|
102
103
|
- lib/backgrounder/workers/store_asset.rb
|
103
104
|
- lib/carrierwave_backgrounder.rb
|
@@ -128,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
129
|
version: '0'
|
129
130
|
segments:
|
130
131
|
- 0
|
131
|
-
hash:
|
132
|
+
hash: 2570599687914796693
|
132
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
134
|
none: false
|
134
135
|
requirements:
|
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
138
|
version: '0'
|
138
139
|
segments:
|
139
140
|
- 0
|
140
|
-
hash:
|
141
|
+
hash: 2570599687914796693
|
141
142
|
requirements: []
|
142
143
|
rubyforge_project:
|
143
144
|
rubygems_version: 1.8.25
|