simple-s3 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,19 +8,26 @@ class SimpleS3
8
8
  end
9
9
 
10
10
  def upload!
11
- exclude = @config['exclude_files']
12
- inc = @config['include_files']
13
- bucket = @config['bucket']
14
- metadata = @config['metadata'] || {}
11
+ bucket = @config['bucket'].to_s
12
+ raise 'Simple-S3: Bucket not defined' if bucket.length == 0
15
13
 
14
+ exclude = @config['exclude_files'] || []
15
+ inc = @config['include_files'] || './**/*'
16
+ metadata = @config['metadata'] || {}
16
17
  metadata[:access] ||= 'public-read'
17
18
 
18
19
  files = []
19
20
  Dir[inc].each do |file|
20
21
  name = File.basename(file)
21
- files.push(file) unless exclude.include?(name)
22
+ found = false
23
+ exclude.each do |ex|
24
+ found = true if file.start_with?(ex) || ex == name
25
+ end
26
+ files.push(file) unless found
22
27
  end
23
28
 
29
+ raise 'Simple-S3: No files found' if files.length == 0
30
+
24
31
  AWS::S3::Base.establish_connection!(
25
32
  :access_key_id => @config['access_key'],
26
33
  :secret_access_key => @config['secret_key']
@@ -28,7 +35,7 @@ class SimpleS3
28
35
 
29
36
  files.each do |file|
30
37
  base_name = File.basename(file)
31
- puts "Uploading #{file} as '#{base_name}' to '#{bucket}'"
38
+ puts "Simple-S3: Uploading #{file} as '#{base_name}' to '#{bucket}'"
32
39
  AWS::S3::S3Object.store(
33
40
  base_name,
34
41
  File.open(file),
@@ -37,7 +44,7 @@ class SimpleS3
37
44
  )
38
45
  end
39
46
 
40
- puts "Completed!"
47
+ puts "Simple-S3: Upload Completed!"
41
48
  end
42
49
 
43
50
  end
@@ -1,3 +1,3 @@
1
1
  class SimpleS3
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/simple-s3.gem ADDED
Binary file
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matias Niemela
@@ -45,6 +45,7 @@ files:
45
45
  - lib/simple-s3.rb
46
46
  - lib/simple-s3/simple-s3.rb
47
47
  - lib/simple-s3/version.rb
48
+ - simple-s3.gem
48
49
  - simple-s3.gemspec
49
50
  has_rdoc: true
50
51
  homepage: https://github.com/yearofmoo/simple-s3