s3_uploader 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/README.md +1 -0
- data/lib/s3_uploader/s3_uploader.rb +3 -2
- data/lib/s3_uploader/version.rb +1 -1
- data/s3_uploader.gemspec +2 -1
- data/spec/s3uploader_spec.rb +17 -12
- data/spec/spec_helper.rb +2 -2
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b848eda8fa6b0f9875dfe9c4fab1821a8c1b794
|
4
|
+
data.tar.gz: e71958d6cdc905d5834f4a89e06442a04a3d11c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73573d90c03156f3db0bfb8963990f62e34c517120d98e16d44d8198b7945629f23844f17d2991d8b7072ec85b6d0e5278768d85193a95ce526a03e0e9212eb7
|
7
|
+
data.tar.gz: 872868c71287c74f5e27bf4c61faa597c43b47f7dd44ea58c4d14c8fb27cc89cdea93ab6da74b72bb0877a95d33f0c3f73a2c05475e6de180c922eea7ce57001
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# S3Uploader
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/s3_uploader.png)](http://badge.fury.io/rb/s3_uploader)
|
4
|
+
[![Build Status](https://travis-ci.org/chrishein/s3_uploader.svg?branch=master)](https://travis-ci.org/chrishein/s3_uploader)
|
4
5
|
|
5
6
|
Multithreaded recursive directory uploader to S3 using [fog](https://github.com/fog/fog).
|
6
7
|
|
@@ -60,8 +60,9 @@ module S3Uploader
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
def upload(
|
64
|
-
raise 'Source directory is requiered' if
|
63
|
+
def upload(source_dir, bucket)
|
64
|
+
raise 'Source directory is requiered' if source_dir.to_s.empty?
|
65
|
+
source = source_dir.dup
|
65
66
|
source << '/' unless source.end_with?('/')
|
66
67
|
raise 'Source must be a directory' unless File.directory?(source)
|
67
68
|
|
data/lib/s3_uploader/version.rb
CHANGED
data/s3_uploader.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_dependency 'fog-aws'
|
20
20
|
gem.add_dependency 'mime-types'
|
21
21
|
|
22
|
-
gem.add_development_dependency 'rspec'
|
22
|
+
gem.add_development_dependency 'rspec'
|
23
|
+
gem.add_development_dependency 'rspec-collection_matchers'
|
23
24
|
gem.add_development_dependency 'rake'
|
24
25
|
end
|
data/spec/s3uploader_spec.rb
CHANGED
@@ -45,22 +45,25 @@ describe S3Uploader do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'when called with missing access keys it should raise an exception' do
|
48
|
-
|
48
|
+
expect {
|
49
49
|
S3Uploader.upload('/tmp', 'mybucket',
|
50
50
|
{ destination_dir: 'test1/',
|
51
51
|
s3_key: nil,
|
52
52
|
s3_secret: nil })
|
53
|
-
}.
|
53
|
+
}.to raise_error('Missing access keys')
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'when called with source not directory it should raise an exception' do
|
57
|
-
|
58
|
-
S3Uploader.upload('/xzzaz1232', 'mybucket'
|
59
|
-
|
57
|
+
expect {
|
58
|
+
S3Uploader.upload('/xzzaz1232', 'mybucket', {
|
59
|
+
s3_key: '11111111111',
|
60
|
+
s3_secret: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
61
|
+
})
|
62
|
+
}.to raise_error('Source must be a directory')
|
60
63
|
end
|
61
64
|
|
62
65
|
it 'should upload all files in a directory' do
|
63
|
-
connection.directories.get('mybucket', prefix: 'test1/').files.empty
|
66
|
+
expect(connection.directories.get('mybucket', prefix: 'test1/').files.empty?).to be true
|
64
67
|
|
65
68
|
S3Uploader.upload(tmp_directory, 'mybucket',
|
66
69
|
{ destination_dir: 'test1/',
|
@@ -73,7 +76,7 @@ describe S3Uploader do
|
|
73
76
|
end
|
74
77
|
|
75
78
|
it 'should still support upload_directory static method for backwards compatibility' do
|
76
|
-
connection.directories.get('mybucket', prefix: 'test1/').files.empty
|
79
|
+
expect(connection.directories.get('mybucket', prefix: 'test1/').files.empty?).to be true
|
77
80
|
|
78
81
|
S3Uploader.upload_directory(tmp_directory, 'mybucket',
|
79
82
|
{ destination_dir: 'test1/',
|
@@ -104,12 +107,12 @@ describe S3Uploader do
|
|
104
107
|
describe 'gzip' do
|
105
108
|
|
106
109
|
it "should require a gzip working directory" do
|
107
|
-
|
110
|
+
expect {
|
108
111
|
S3Uploader.upload('/tmp', 'mybucket',
|
109
112
|
{ logger: logger,
|
110
113
|
connection: connection,
|
111
114
|
gzip: true })
|
112
|
-
}.
|
115
|
+
}.to raise_error('gzip_working_dir required when using gzip')
|
113
116
|
end
|
114
117
|
|
115
118
|
it 'should compress files before upload when needed' do
|
@@ -131,9 +134,11 @@ describe S3Uploader do
|
|
131
134
|
|
132
135
|
it 'when called with bad gzip_working_dir it should raise an exception' do
|
133
136
|
expect {
|
134
|
-
S3Uploader.upload(tmp_directory, 'mybucket',
|
135
|
-
|
136
|
-
|
137
|
+
S3Uploader.upload(tmp_directory, 'mybucket', {
|
138
|
+
s3_key: '11111111111',
|
139
|
+
s3_secret: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
|
140
|
+
gzip: true,
|
141
|
+
gzip_working_dir: File.join(tmp_directory, 'working_dir') })
|
137
142
|
}.to raise_error('gzip_working_dir may not be located within source-folder')
|
138
143
|
|
139
144
|
expect {
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require 'rspec/collection_matchers'
|
2
3
|
require 's3_uploader'
|
3
4
|
require 'tmpdir'
|
4
5
|
require 'open3'
|
5
6
|
|
6
7
|
RSpec.configure do |config|
|
7
|
-
config.
|
8
|
+
config.color = true
|
8
9
|
config.formatter = 'documentation'
|
9
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
10
|
end
|
11
11
|
|
12
12
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Hein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-aws
|
@@ -42,16 +42,30 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-collection_matchers
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +90,7 @@ extra_rdoc_files: []
|
|
76
90
|
files:
|
77
91
|
- ".gitignore"
|
78
92
|
- ".rspec"
|
93
|
+
- ".travis.yml"
|
79
94
|
- Gemfile
|
80
95
|
- LICENSE
|
81
96
|
- README.md
|