carrierwave-processor 0.0.1.pre → 1.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8888e33817df6e28e43e63a5d26aadff0ef72df2
|
4
|
+
data.tar.gz: 69fd491bd8ffdf034c9ad4561a2600e8422b73f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cd9c75be3ed190a8e7e2879940bff4898d85c7bd327c15eeb7a27a9ab2e31e38c14230fb13c9b72cdc52407ec2b5484492cf6146a0173d3b036d50f436e626a
|
7
|
+
data.tar.gz: 068140e6335488f2a67ea7be347987e85dd7934f777cf9e0ce3d2ccfb4c626e0e4861acb526a907166be0643a5aac53e6e3533e01ae9be6f02e11e3908f9a11a
|
@@ -32,25 +32,25 @@ module CarrierWave
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def load_cw_versions processor, options = {}
|
35
|
-
conditions = options
|
36
|
-
processor.processors.each do |name,
|
37
|
-
new_conditions = (conditions + [
|
35
|
+
conditions = options.delete(:conditions) || []
|
36
|
+
processor.processors.each do |name, v|
|
37
|
+
new_conditions = (conditions + [v.options[:if]]).compact
|
38
38
|
condition = ::CarrierWave::Processor.conditions_merge(*new_conditions) unless new_conditions.empty?
|
39
|
-
version_options =
|
39
|
+
version_options = v.options
|
40
40
|
version_options.merge! options if options
|
41
41
|
version_options.merge!(:if => condition) if condition
|
42
42
|
if version_options.empty?
|
43
43
|
version name do
|
44
|
-
load_cw_processors
|
44
|
+
load_cw_processors v
|
45
45
|
end
|
46
46
|
else
|
47
47
|
version name, version_options do
|
48
|
-
load_cw_processors
|
48
|
+
load_cw_processors v
|
49
49
|
end
|
50
50
|
end
|
51
|
-
next_level_options = {:from_version =>
|
51
|
+
next_level_options = {:from_version => name}
|
52
52
|
next_level_options.merge!(:conditions => new_conditions) unless conditions.empty?
|
53
|
-
load_cw_versions
|
53
|
+
load_cw_versions v, next_level_options
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/spec/uploader_dsl_spec.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CarrierWave::Processor::UploaderDsl do
|
4
|
+
before :each do
|
5
|
+
CarrierWave::Processor.stub(:conditions_merge) do |*args|
|
6
|
+
if args.empty?
|
7
|
+
nil
|
8
|
+
elsif (args.length == 1)
|
9
|
+
args.first
|
10
|
+
else
|
11
|
+
args
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
4
15
|
before :each do
|
5
16
|
if Object.constants.include?(:FooUploader)
|
6
17
|
Object.send(:remove_const, :FooUploader)
|
@@ -68,11 +79,61 @@ describe CarrierWave::Processor::UploaderDsl do
|
|
68
79
|
|
69
80
|
it "calls inner version processors without if option merge" do
|
70
81
|
carrierwave_processor :some_processor do
|
71
|
-
version :some_version do
|
72
|
-
process :
|
82
|
+
version :some_version, :if => :nyasha do
|
83
|
+
process :processing, :if => :abrakadabra
|
73
84
|
end
|
74
85
|
end
|
75
|
-
FooUploader.should_receive(:
|
86
|
+
FooUploader.should_receive(:process).with(:processing => [], :if => :abrakadabra)
|
87
|
+
FooUploader.send(:use_processor, :some_processor, :if => :kuku)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'multiple versions merges correctly' do
|
91
|
+
|
92
|
+
carrierwave_processor :some_processor do
|
93
|
+
process :root_process, :if => :e
|
94
|
+
process :root2_process
|
95
|
+
version :a2_version do
|
96
|
+
process :a3_process
|
97
|
+
process :a4_process, :if => :a4
|
98
|
+
end
|
99
|
+
version :a_version, :if => :b do
|
100
|
+
process :a_process, :if => :f
|
101
|
+
process :a2_process
|
102
|
+
version :b_version do
|
103
|
+
process :b_process, :if => :e
|
104
|
+
process :b2_process
|
105
|
+
version :c_version, :if => :c do
|
106
|
+
process :c_process, :if => :d
|
107
|
+
process :c2_process
|
108
|
+
version :d_version do
|
109
|
+
process :d_process, :if => :e
|
110
|
+
process :d2_process
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
FooUploader.should_receive(:version).with(:a2_version, :if => :root).and_call_original
|
118
|
+
FooUploader.should_receive(:version).with(:a_version, :if => [:root, :b]).and_call_original
|
119
|
+
FooUploader.should_receive(:version).with(:b_version, :from_version => :a_version, :if => [:root, :b]).and_call_original
|
120
|
+
FooUploader.should_receive(:version).with(:c_version, :from_version => :b_version, :if => [:root, :b, :c]).and_call_original
|
121
|
+
FooUploader.should_receive(:version).with(:d_version, :from_version => :c_version, :if => [:root, :b, :c]).and_call_original
|
122
|
+
|
123
|
+
FooUploader.should_receive(:process).with(:root_process => [], :if => [:root, :e])
|
124
|
+
FooUploader.should_receive(:process).with(:root2_process => [], :if => :root)
|
125
|
+
FooUploader.should_receive(:process).with(:a3_process => [])
|
126
|
+
FooUploader.should_receive(:process).with(:a4_process => [], :if => :a4)
|
127
|
+
FooUploader.should_receive(:process).with(:a_process => [], :if => :f)
|
128
|
+
FooUploader.should_receive(:process).with(:a2_process => [])
|
129
|
+
FooUploader.should_receive(:process).with(:b_process => [], :if => :e)
|
130
|
+
FooUploader.should_receive(:process).with(:b2_process => [])
|
131
|
+
FooUploader.should_receive(:process).with(:c_process => [], :if => :d)
|
132
|
+
FooUploader.should_receive(:process).with(:c2_process => [])
|
133
|
+
FooUploader.should_receive(:process).with(:d_process => [], :if => :e)
|
134
|
+
FooUploader.should_receive(:process).with(:d2_process => [])
|
135
|
+
|
136
|
+
FooUploader.send(:use_processor, :some_processor, :if => :root)
|
76
137
|
end
|
77
138
|
|
78
139
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kostrov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -119,9 +119,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
127
|
rubygems_version: 2.1.11
|