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 ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.9.2
3
+
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, nil, nil).public_url
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],
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module CarrierwaveDirect
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
 
@@ -72,7 +72,7 @@ module ModelHelpers
72
72
  end
73
73
  end
74
74
 
75
- it_should_be_accessible(name, sample_data, options)
75
+ it_should_be_accessible(name, sample_data, options) if options[:accessible].present?
76
76
  end
77
77
  end
78
78
  end
@@ -1,3 +1,5 @@
1
+ require File.dirname(__FILE__) << "/direct_uploader"
2
+
1
3
  class MountedClass
2
4
  extend CarrierWave::Mount
3
5
  extend CarrierWaveDirect::Mount
@@ -1,3 +1,5 @@
1
+ require File.dirname(__FILE__) << "/mounted_class"
2
+
1
3
  module UploaderHelpers
2
4
  include CarrierWaveDirect::Test::Helpers
3
5
 
@@ -48,7 +48,7 @@ describe CarrierWaveDirect::Test::Helpers do
48
48
  context "with no options" do
49
49
  it "should return '*/guid/filename.extension'" do
50
50
  sample_key(
51
- direct_uploader,
51
+ direct_uploader
52
52
  ).should =~ /#{GUID_REGEXP}\/filename\.extension$/
53
53
  end
54
54
  end
@@ -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
- string_to_time(
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
- string_to_time(expiration).should have_expiration
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
- string_to_time(expiration(:expiration => sample(:expiration))).should have_expiration(sample(:expiration))
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.1
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-08 00:00:00.000000000Z
12
+ date: 2011-09-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: carrierwave
16
- requirement: &69135650 !ruby/object:Gem::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: *69135650
24
+ version_requirements: *74846810
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: uuid
27
- requirement: &69457720 !ruby/object:Gem::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: *69457720
35
+ version_requirements: *74846570
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fog
38
- requirement: &70220670 !ruby/object:Gem::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: *70220670
46
+ version_requirements: *74846360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70418510 !ruby/object:Gem::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: *70418510
57
+ version_requirements: *74846140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: timecop
60
- requirement: &70422900 !ruby/object:Gem::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: *70422900
68
+ version_requirements: *74845930
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rails
71
- requirement: &70478930 !ruby/object:Gem::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: *70478930
79
+ version_requirements: *74845710
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sqlite3
82
- requirement: &70568450 !ruby/object:Gem::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: *70568450
90
+ version_requirements: *74845480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: capybara
93
- requirement: &70742260 !ruby/object:Gem::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: *70742260
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