s3-batch 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  require 'thor'
2
2
  require 'aws'
3
+ require 'progressbar'
3
4
 
4
5
  module S3
5
6
  end
@@ -20,13 +21,21 @@ class S3::Batch < Thor
20
21
  def upload(dir=nil)
21
22
  @root = dir
22
23
  bucket
24
+ acl
25
+
26
+ total = 0
27
+ files_to_upload.each do |file|
28
+ total += File.size(File.join(@root, file))
29
+ end
30
+
31
+ progress = ProgressBar.new('Upload', total)
23
32
 
24
33
  files_to_upload.each do |file|
25
- puts "Uploading: #{file}"
26
34
  object = bucket.objects[file]
27
35
 
36
+ progress.inc File.size(File.join(@root, file))
37
+
28
38
  if object.exists?
29
- puts "[SKIP] File exists."
30
39
  next
31
40
  end
32
41
 
@@ -35,9 +44,9 @@ class S3::Batch < Thor
35
44
  :acl => acl,
36
45
  :storage_class => :standard,
37
46
  :cache_control => 'max-age=315360000')
38
-
39
- puts "[DONE] File uploaded."
40
47
  end
48
+
49
+ progress.finish
41
50
  end
42
51
 
43
52
  private
@@ -60,7 +69,8 @@ private
60
69
  @s3 ||= AWS::S3.new(
61
70
  :access_key_id => access_key_id,
62
71
  :secret_access_key => secret_access_key,
63
- :s3_endpoint => s3_endpoint
72
+ :s3_endpoint => s3_endpoint,
73
+ :ssl_verify_peer => false
64
74
  )
65
75
  end
66
76
 
@@ -1,5 +1,5 @@
1
1
  module S3
2
2
  class Batch
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_runtime_dependency "aws-sdk"
22
22
  s.add_runtime_dependency "thor"
23
+ s.add_runtime_dependency "ruby-progressbar"
23
24
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3-batch
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Simon Menke
@@ -45,6 +45,20 @@ dependencies:
45
45
  version: "0"
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: ruby-progressbar
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :runtime
61
+ version_requirements: *id003
48
62
  description: Upload a batch of files to S3.
49
63
  email:
50
64
  - simon.menke@gmail.com