s3share 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,7 +1,7 @@
1
1
  S3Share
2
2
  =======
3
3
 
4
- S3Share is a simple script to upload your files to S3 and share them with your friends.
4
+ S3Share is a simple script to upload your files to S3 and share them with your friends and enemies.
5
5
 
6
6
  Requirements
7
7
  ------------
@@ -18,7 +18,9 @@ You can install from Rubygems
18
18
  Or you can download the source and build it manually:
19
19
 
20
20
  $ git clone https://febuiles@github.com/febuiles/s3share.git
21
- $ rake install
21
+ $ cd s3share
22
+ $ gem build
23
+ $ gem install s3share --local
22
24
 
23
25
 
24
26
  Setting ENV variables
@@ -29,7 +31,7 @@ You'll need to set the three following ENV variables:
29
31
  * `AMAZON_SECRET_ACCESS_KEY`: AWS secret access key.
30
32
  * `AMAZON_S3_DEFAULT_BUCKET`: Name of the bucket where the uploads will be held.
31
33
 
32
- The last variable is visible in the URL returned to the user: `http://s3.amazonaws.com/{AMAZON_S3_DEFAULT_BUCKET}/some_photo.png`, so make sure you choose something pretty. This value is global for all the S3 namespace, meaning you need to find something unique between all the S3 users ("some-user-name_uploads" should do the trick).
34
+ The last variable is visible in the URL returned to the user: `http://s3.amazonaws.com/{AMAZON_S3_DEFAULT_BUCKET}/some_photo.png`, so make sure you choose something pretty. This value is global for all the S3 namespace, meaning you need to find something unique between all the S3 users ("some-user-name_uploads" should do the trick). If the specified bucket doesn't exist, it will be automatically created.
33
35
 
34
36
  You can set these variables in a `~/.amazon_keys` file:
35
37
 
data/Rakefile CHANGED
@@ -1 +1,13 @@
1
1
  # Empty Rakefile...
2
+ require 'rspec/core/rake_task'
3
+
4
+ file_list = FileList['spec/*_spec.rb']
5
+
6
+ RSpec::Core::RakeTask.new('spec') do |t|
7
+ t.pattern = file_list
8
+ t.rspec_opts = ["--colour", "--format progress"]
9
+ end
10
+
11
+ desc 'Default: run specs.'
12
+ task :default => 'spec'
13
+
data/lib/s3share/args.rb CHANGED
@@ -1,4 +1,3 @@
1
- # Stolen from the Hub gem: https://github.com/defunkt/hub/
2
1
  module S3Share
3
2
  class Args < Array
4
3
  def initialize(*args)
@@ -3,8 +3,10 @@ module S3Share
3
3
  def initialize(*args)
4
4
  @args = Args.new(args)
5
5
  @filename = args.first
6
+ end
6
7
 
7
- # Print usage instructions if the filename is empty.
8
+ # Starts the execution.
9
+ def run
8
10
  if @filename.nil?
9
11
  puts "usage: s3.rb [filename]"
10
12
  exit(-1)
@@ -58,6 +60,8 @@ module S3Share
58
60
  :access_key_id => access_key,
59
61
  :secret_access_key => secret_key
60
62
  )
63
+
64
+ create_bucket_if_it_does_not_exist(bucket_name)
61
65
 
62
66
  AWS::S3::S3Object.store(@filename, open("#{@path}/#{@filename}"),
63
67
  bucket_name,
@@ -98,5 +102,14 @@ module S3Share
98
102
  }
99
103
  errors[err].each { |msg| puts msg }
100
104
  end
105
+
106
+ private
107
+ # Check if the bucket exists and create it if it doesn't.
108
+ def create_bucket_if_it_does_not_exist(bucket_name)
109
+ AWS::S3::Bucket.find(bucket_name)
110
+ rescue AWS::S3::NoSuchBucket => e
111
+ puts "Bucket '#{bucket_name}' does not exist. Creating it..."
112
+ AWS::S3::Bucket.create(bucket_name)
113
+ end
101
114
  end
102
115
  end
@@ -1,3 +1,3 @@
1
1
  module S3Share
2
- Version = VERSION = '0.1'
2
+ Version = VERSION = '0.2'
3
3
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3share
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 2
9
+ version: "0.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Federico Builes
@@ -14,10 +14,37 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-14 00:00:00 -05:00
17
+ date: 2010-12-06 00:00:00 -05:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: aws-s3
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
21
48
  description: |+
22
49
  S3Share allows simple uploads to Amazon S3 from your command line. Set
23
50
  your access ENV variables (see website) and upload the file: