carrierwave-aws 0.3.1 → 0.3.2
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 +4 -4
- data/.travis.yml +17 -2
- data/HISTORY.md +5 -0
- data/README.md +4 -2
- data/carrierwave-aws.gemspec +2 -2
- data/lib/carrierwave/aws/version.rb +1 -1
- data/lib/carrierwave/storage/aws.rb +6 -2
- data/spec/carrierwave/storage/aws_spec.rb +13 -6
- data/spec/features/storing_files_spec.rb +9 -5
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a92faaa25331fa4e10ea844d8fe5b90519c4ae87
|
4
|
+
data.tar.gz: 68352ca1f0ee3f20985a3c0063b360698d56566c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9fddccad1b717d22910f426930192bbad53b65e1fc88d979d912893f68e1ee2e088e39c9c4e3209d3a6eafcc6a948fd53764e9f563c64f7ffd7d5adc826aadc
|
7
|
+
data.tar.gz: 07b0a3b8e7c45b095842d15238f660accd2893c75a6ced507809d5049a00668dcf0257b8ada8c6d580f627114862c018778a3f53364744001a2300857ebe01d8
|
data/.travis.yml
CHANGED
@@ -1,5 +1,20 @@
|
|
1
|
+
---
|
1
2
|
language: ruby
|
2
3
|
rvm:
|
3
|
-
|
4
|
-
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0.0
|
5
6
|
script: bundle exec rspec spec
|
7
|
+
env:
|
8
|
+
global:
|
9
|
+
- secure: |-
|
10
|
+
A6i5I0Y+ifiJr2yotcjMBOZxRnhaPbuDTuMW3PMMUaqHsCc2A5Tqemenb7WG
|
11
|
+
awCHOE6i9fuO/qAOPR3iKVdkR7Qv//CDtFZ9pZ7uiqVxfz1kYbv4aoPm1IvJ
|
12
|
+
Kd6Nons/AjkD+yhobP8WgiIZI/QcSylDZYNCasTwQlfOCdYLnag=
|
13
|
+
- secure: |-
|
14
|
+
IE4oVY30L0OH10J/poiEZ1PyFZgPY7dH1FneJI5OeYJJ8GfEHoLuMJXgBmyX
|
15
|
+
mC2v2PGK0pQTKGKFVV1mLhKdCzeLRCSMFqNvVo6blSoMLZoM1kj3sbU0kiIW
|
16
|
+
qAgafLka3iyxQnPsvfmjLVei3h+HOUIUV6QmagjcMfZREHfTDZk=
|
17
|
+
- secure: |-
|
18
|
+
B75vnSCFTnQgCP4dmz78VN/WWj88Tpnh4cjUCU0cQjQ5M7oQ0KTbM0d7WDyf
|
19
|
+
rf0F+B9OihBtLNQWqjocRvNH0dU5OzBLCC9DVolUgNwOdNTHW2I7CwlxJ5t7
|
20
|
+
ljQTxzPP+tFASwzBHjywbo7n0EX3efT5UOZhbD9LZL93X4SOlyU=
|
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[](https://travis-ci.org/sorentwo/carrierwave-aws)
|
4
4
|
[](https://codeclimate.com/github/sorentwo/carrierwave-aws)
|
5
5
|
[](http://badge.fury.io/rb/carrierwave-aws)
|
6
|
+
[](https://gemnasium.com/sorentwo/carrierwave-aws)
|
6
7
|
|
7
8
|
Use the officially supported AWS-SDK library for S3 storage rather than relying
|
8
9
|
on fog. There are several things going for it:
|
@@ -12,12 +13,12 @@ on fog. There are several things going for it:
|
|
12
13
|
* Fewer dependencies
|
13
14
|
* Clear documentation
|
14
15
|
|
15
|
-
Here is a simple comparison table [
|
16
|
+
Here is a simple comparison table [07/17/2013]
|
16
17
|
|
17
18
|
| Library | Disk Space | Lines of Code | Boot Time | Runtime Deps | Develop Deps |
|
18
19
|
| ------- | ---------- | ------------- | --------- | ------------ | ------------ |
|
19
20
|
| fog | 28.0M | 133469 | 0.693 | 9 | 11 |
|
20
|
-
| aws-sdk |
|
21
|
+
| aws-sdk | 5.4M | 90290 | 0.098 | 3 | 8 |
|
21
22
|
|
22
23
|
## Installation
|
23
24
|
|
@@ -38,6 +39,7 @@ CarrierWave.configure do |config|
|
|
38
39
|
config.storage = :aws
|
39
40
|
config.aws_bucket = ENV['S3_BUCKET_NAME']
|
40
41
|
config.aws_acl = :public_read
|
42
|
+
config.asset_host = 'http://example.com'
|
41
43
|
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 365
|
42
44
|
|
43
45
|
config.aws_credentials = {
|
data/carrierwave-aws.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
|
19
19
|
gem.add_dependency 'carrierwave', '>= 0.7.0'
|
20
|
-
gem.add_dependency 'aws-sdk', '
|
20
|
+
gem.add_dependency 'aws-sdk', '>= 1.8.0'
|
21
21
|
|
22
|
-
gem.add_development_dependency 'rspec', '~> 2.
|
22
|
+
gem.add_development_dependency 'rspec', '~> 2.14.0'
|
23
23
|
end
|
@@ -76,7 +76,7 @@ module CarrierWave
|
|
76
76
|
@file = bucket.objects[path].write({
|
77
77
|
acl: uploader.aws_acl,
|
78
78
|
content_type: new_file.content_type,
|
79
|
-
file: new_file.
|
79
|
+
file: new_file.path
|
80
80
|
}.merge(uploader.aws_attributes || {}))
|
81
81
|
|
82
82
|
true
|
@@ -99,7 +99,11 @@ module CarrierWave
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def public_url
|
102
|
-
|
102
|
+
if uploader.asset_host
|
103
|
+
"#{uploader.asset_host}/#{path}"
|
104
|
+
else
|
105
|
+
file.public_url.to_s
|
106
|
+
end
|
103
107
|
end
|
104
108
|
|
105
109
|
private
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe CarrierWave::Storage::AWS do
|
4
4
|
let(:credentials) { { access_key_id: 'abc', secret_access_key: '123' } }
|
5
|
-
let(:uploader) {
|
5
|
+
let(:uploader) { double(:uploader, aws_credentials: credentials) }
|
6
6
|
|
7
7
|
subject(:storage) do
|
8
8
|
CarrierWave::Storage::AWS.new(uploader)
|
@@ -20,7 +20,7 @@ describe CarrierWave::Storage::AWS do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'caches connections by credentials' do
|
23
|
-
AWS::S3.should_receive(:new).with(credentials).and_return(
|
23
|
+
AWS::S3.should_receive(:new).with(credentials).and_return(double)
|
24
24
|
|
25
25
|
storage.connection.should === storage.connection
|
26
26
|
end
|
@@ -29,10 +29,10 @@ end
|
|
29
29
|
|
30
30
|
describe CarrierWave::Storage::AWS::File do
|
31
31
|
let(:objects) { { 'files/1/file.txt' => file } }
|
32
|
-
let(:bucket) {
|
33
|
-
let(:connection) {
|
34
|
-
let(:file) {
|
35
|
-
let(:uploader) {
|
32
|
+
let(:bucket) { double(:bucket, objects: objects) }
|
33
|
+
let(:connection) { double(:connection, buckets: { 'example-com' => bucket }) }
|
34
|
+
let(:file) { double(:file, read: '0101010') }
|
35
|
+
let(:uploader) { double(:uploader, aws_bucket: 'example-com', asset_host: nil) }
|
36
36
|
let(:path) { 'files/1/file.txt' }
|
37
37
|
|
38
38
|
subject(:aws_file) do
|
@@ -76,5 +76,12 @@ describe CarrierWave::Storage::AWS::File do
|
|
76
76
|
|
77
77
|
aws_file.url
|
78
78
|
end
|
79
|
+
|
80
|
+
it 'uses the asset_host and file path if asset_host is set' do
|
81
|
+
uploader.stub(aws_acl: :public_read)
|
82
|
+
uploader.stub(asset_host: 'http://example.com')
|
83
|
+
|
84
|
+
aws_file.url.should eql 'http://example.com/files/1/file.txt'
|
85
|
+
end
|
79
86
|
end
|
80
87
|
end
|
@@ -16,14 +16,18 @@ if ENV['S3_BUCKET_NAME']
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'uploads the file to the configured bucket' do
|
19
|
+
uploader = Class.new(CarrierWave::Uploader::Base) do
|
20
|
+
def filename; 'image.png'; end
|
21
|
+
end
|
22
|
+
|
19
23
|
image = File.open('spec/fixtures/image.png', 'r')
|
20
|
-
uploader = Class.new(CarrierWave::Uploader::Base)
|
21
24
|
instance = uploader.new
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
instance.store!(image)
|
27
|
+
instance.retrieve_from_store!('image.png')
|
28
|
+
|
29
|
+
expect(instance.file.size).to be_nonzero
|
30
|
+
expect(image.size).to eq(instance.file.size)
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Selbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: aws-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.
|
33
|
+
version: 1.8.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.8.
|
40
|
+
version: 1.8.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.14.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.14.0
|
55
55
|
description: Use aws-sdk for S3 support in CarrierWave
|
56
56
|
email:
|
57
57
|
- parker@sorentwo.com
|