carrierwave_direct 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/README.md +2 -0
- data/lib/carrierwave_direct/uploader.rb +2 -2
- data/lib/carrierwave_direct/version.rb +1 -1
- data/spec/support/model_helpers.rb +1 -1
- data/spec/support/mounted_class.rb +2 -0
- data/spec/support/uploader_helpers.rb +2 -0
- data/spec/test/helpers_spec.rb +1 -1
- data/spec/uploader_spec.rb +8 -14
- metadata +19 -18
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# CarrierWaveDirect
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/dwilkie/carrierwave_direct.png)](http://travis-ci.org/dwilkie/carrierwave_direct)
|
4
|
+
|
3
5
|
[CarrierWave](https://github.com/jnicklas/carrierwave) is a great way to upload files from Ruby applications, but since processing and saving is done in-process, it doesn't scale well. A better way is to upload your files directly then handle the processing and saving in a background process.
|
4
6
|
|
5
7
|
[CarrierWaveDirect](https://github.com/dwilkie/carrierwave_direct) works on top of [CarrierWave](https://github.com/jnicklas/carrierwave) and provides a simple way to achieve this.
|
@@ -21,7 +21,7 @@ module CarrierWaveDirect
|
|
21
21
|
|
22
22
|
module InstanceMethods
|
23
23
|
def direct_fog_url(options = {})
|
24
|
-
fog_uri = CarrierWave::Storage::Fog::File.new(self,
|
24
|
+
fog_uri = CarrierWave::Storage::Fog::File.new(self, CarrierWave::Storage::Fog.new(self), nil).public_url
|
25
25
|
if options[:with_path]
|
26
26
|
uri = URI.parse(fog_uri)
|
27
27
|
path = "/#{key}"
|
@@ -58,7 +58,7 @@ module CarrierWaveDirect
|
|
58
58
|
|
59
59
|
Base64.encode64(
|
60
60
|
{
|
61
|
-
'expiration' => Time.now + options[:expiration],
|
61
|
+
'expiration' => Time.now.utc + options[:expiration],
|
62
62
|
'conditions' => [
|
63
63
|
["starts-with", "$utf8", ""],
|
64
64
|
["starts-with", "$key", store_dir],
|
data/spec/test/helpers_spec.rb
CHANGED
data/spec/uploader_spec.rb
CHANGED
@@ -313,19 +313,9 @@ describe CarrierWaveDirect::Uploader do
|
|
313
313
|
decoded_policy(options)["expiration"]
|
314
314
|
end
|
315
315
|
|
316
|
-
# Stolen from rails
|
317
|
-
def string_to_time(str)
|
318
|
-
d = ::Date._parse(str, false).values_at(
|
319
|
-
:year, :mon, :mday, :hour, :min, :sec, :sec_fraction, :offset
|
320
|
-
).map { |arg| arg || 0 }
|
321
|
-
d[6] *= 1000000
|
322
|
-
Time.utc(*d[0..6]) - d[7]
|
323
|
-
end
|
324
|
-
|
325
|
-
|
326
316
|
def have_expiration(expires_in = DirectUploader.upload_expiration)
|
327
317
|
eql(
|
328
|
-
|
318
|
+
Time.parse(
|
329
319
|
JSON.parse({
|
330
320
|
"expiry" => Time.now + expires_in
|
331
321
|
}.to_json)["expiry"]
|
@@ -335,13 +325,17 @@ describe CarrierWaveDirect::Uploader do
|
|
335
325
|
|
336
326
|
it "should be #{DirectUploader.upload_expiration / 3600} hours from now" do
|
337
327
|
Timecop.freeze(Time.now) do
|
338
|
-
|
328
|
+
Time.parse(expiration).should have_expiration
|
339
329
|
end
|
340
330
|
end
|
341
331
|
|
332
|
+
it "should be encoded as a utc time" do
|
333
|
+
Time.parse(expiration).should be_utc
|
334
|
+
end
|
335
|
+
|
342
336
|
it "should be #{sample(:expiration) / 60 } minutes from now when passing {:expiration => #{sample(:expiration)}}" do
|
343
337
|
Timecop.freeze(Time.now) do
|
344
|
-
|
338
|
+
Time.parse(expiration(:expiration => sample(:expiration))).should have_expiration(sample(:expiration))
|
345
339
|
end
|
346
340
|
end
|
347
341
|
end
|
@@ -419,7 +413,7 @@ describe CarrierWaveDirect::Uploader do
|
|
419
413
|
# note that 'video' is hardcoded into the MountedClass support file
|
420
414
|
# so changing the sample will cause the tests to fail
|
421
415
|
context "a class has a '#{sample(:mounted_as)}' mounted" do
|
422
|
-
describe "#{sample(:mounted_as).capitalize}Uploader" do
|
416
|
+
describe "#{sample(:mounted_as).to_s.capitalize}Uploader" do
|
423
417
|
describe "##{sample(:mounted_as)}" do
|
424
418
|
it "should be defined" do
|
425
419
|
direct_subject.should be_respond_to(sample(:mounted_as))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave_direct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carrierwave
|
16
|
-
requirement: &
|
16
|
+
requirement: &74846810 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *74846810
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: uuid
|
27
|
-
requirement: &
|
27
|
+
requirement: &74846570 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *74846570
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fog
|
38
|
-
requirement: &
|
38
|
+
requirement: &74846360 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *74846360
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &74846140 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *74846140
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: timecop
|
60
|
-
requirement: &
|
60
|
+
requirement: &74845930 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *74845930
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rails
|
71
|
-
requirement: &
|
71
|
+
requirement: &74845710 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *74845710
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: sqlite3
|
82
|
-
requirement: &
|
82
|
+
requirement: &74845480 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *74845480
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: capybara
|
93
|
-
requirement: &
|
93
|
+
requirement: &74845250 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *74845250
|
102
102
|
description: Process your uploads in the background by uploading directly to S3
|
103
103
|
email:
|
104
104
|
- dwilkie@gmail.com
|
@@ -107,6 +107,7 @@ extensions: []
|
|
107
107
|
extra_rdoc_files: []
|
108
108
|
files:
|
109
109
|
- .gitignore
|
110
|
+
- .travis.yml
|
110
111
|
- Gemfile
|
111
112
|
- LICENSE
|
112
113
|
- README.md
|