s3_uploader 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/s3_uploader/s3_uploader.rb +4 -2
- data/lib/s3_uploader/version.rb +1 -1
- data/spec/s3uploader_spec.rb +23 -2
- metadata +8 -8
@@ -5,7 +5,8 @@ module S3Uploader
|
|
5
5
|
:threads => 5,
|
6
6
|
:s3_key => ENV['S3_KEY'],
|
7
7
|
:s3_secret => ENV['S3_SECRET'],
|
8
|
-
:public => false
|
8
|
+
:public => false,
|
9
|
+
:region => 'us-east-1'
|
9
10
|
}.merge(options)
|
10
11
|
|
11
12
|
raise 'Source must be a directory' unless File.directory?(source)
|
@@ -23,7 +24,8 @@ module S3Uploader
|
|
23
24
|
connection = Fog::Storage.new({
|
24
25
|
:provider => 'AWS',
|
25
26
|
:aws_access_key_id => options[:s3_key],
|
26
|
-
:aws_secret_access_key => options[:s3_secret]
|
27
|
+
:aws_secret_access_key => options[:s3_secret],
|
28
|
+
:region => options[:region]
|
27
29
|
})
|
28
30
|
|
29
31
|
directory = connection.directories.new(:key => bucket)
|
data/lib/s3_uploader/version.rb
CHANGED
data/spec/s3uploader_spec.rb
CHANGED
@@ -1,9 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe S3Uploader do
|
4
|
+
before :all do
|
5
|
+
Fog.mock!
|
6
|
+
@base_test_directory = '/tmp/test_s3_uploader'
|
7
|
+
create_test_files(@base_test_directory, 10)
|
8
|
+
create_test_files(File.join(@base_test_directory, 'subdir1'), 5)
|
9
|
+
end
|
4
10
|
|
5
11
|
it "should upload all files in a directory" do
|
6
|
-
|
7
|
-
|
12
|
+
S3Uploader.upload_directory(@base_test_directory, 'mybucket', { :destination_dir => 'test1/' })
|
13
|
+
end
|
14
|
+
|
15
|
+
after :all do
|
16
|
+
FileUtils.rm @base_test_directory
|
8
17
|
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_test_files(directory, number_of_files)
|
21
|
+
FileUtils.mkdir_p directory
|
22
|
+
|
23
|
+
$stdout = File.new( '/dev/null', 'w' )
|
24
|
+
|
25
|
+
number_of_files.times do |i|
|
26
|
+
`dd if=/dev/zero of=#{directory}/file#{i}.txt count=1024 bs=1024`
|
27
|
+
end
|
28
|
+
|
29
|
+
$stdout = STDOUT
|
9
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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: 2012-09-
|
12
|
+
date: 2012-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153066020 !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: *2153066020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153065540 !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: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153065540
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153065100 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153065100
|
47
47
|
description: S3 multithreaded directory uploader
|
48
48
|
email:
|
49
49
|
- chrishein@gmail.com
|