s3deployer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/.rbenv-gemsets ADDED
@@ -0,0 +1 @@
1
+ s3deployer
data/README.markdown CHANGED
@@ -1,5 +1,16 @@
1
- = Deploy A Pile of Stuff to S3
2
- After rewriting a script to deploy an app to S3, I eventually got sick of it and
3
- just made this gem.
1
+ # Deploy A Pile of Stuff to S3
4
2
 
5
- Have fun.
3
+ Because sometimes, you just want to shove a bunch of stuff onto S3
4
+
5
+ ## Deploying via a Script
6
+
7
+ deployer = S3Deployer.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
8
+ deployer.deploy("#{Dir.pwd}/directory_to_deploy", "amazon.bucket.name")
9
+
10
+ ## Deploying via the Command Line
11
+
12
+ Just `cd` to the directory you want to deploy and run
13
+
14
+ s3deploy BUCKET_NAME
15
+
16
+ ![ShoveIt](s3deployer/raw/master/ShoveItOverThere.jpg)
Binary file
data/bin/s3deploy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 's3deployer'
4
+
5
+ if ARGV[0].nil?
6
+ raise "Please supply a bucket name"
7
+ exit 1
8
+ end
9
+
10
+ bucket = ARGV[0]
11
+ access_key,secret_key = ENV['ACCESS_KEY'],ENV['SECRET_KEY']
12
+ deployer = S3Deployer.new access_key, secret_key
13
+ deployer.deploy '.', bucket
14
+
@@ -1,3 +1,3 @@
1
1
  class S3Deployer
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/s3deployer.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'aws/s3'
2
+ require 'pathname'
3
+
2
4
  class S3Deployer
3
5
  attr_accessor :directory_to_deploy, :bucket_name
4
6
  def initialize(access_key, secret_key)
@@ -8,7 +10,7 @@ class S3Deployer
8
10
  end
9
11
  def deploy(directory_to_deploy, bucket_name)
10
12
  @bucket_name = bucket_name
11
- @directory_to_deploy = directory_to_deploy
13
+ @directory_to_deploy = File.expand_path(directory_to_deploy)
12
14
  iterate_through_and_deploy(directory_to_deploy)
13
15
  end
14
16
 
@@ -25,7 +27,8 @@ class S3Deployer
25
27
  end
26
28
 
27
29
  def upload_item(item)
28
- s3_name = item.gsub(directory_to_deploy,'')
30
+ item_as_path = Pathname.new(item)
31
+ s3_name = item_as_path.sub("#{@directory_to_deploy}/", '').cleanpath.to_s
29
32
  puts "uploading #{item} as #{s3_name}"
30
33
  AWS::S3::S3Object.store(s3_name, open(item), bucket_name)
31
34
  end
data/s3deployer.gemspec CHANGED
@@ -12,5 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.summary = "A simple way to deploy a directory to Amazon s3"
13
13
  s.files = `git ls-files`.split("\n")
14
14
  s.require_paths = ['lib']
15
+ s.executables = %w(s3deploy)
15
16
  s.add_dependency("aws-s3")
16
17
  end
@@ -23,12 +23,31 @@ describe S3Deployer do
23
23
  create_file("thing", "asdf");
24
24
  create_file("hiphopper", "qwer");
25
25
  subject.deploy("#{Dir.pwd}/files", 'bucket')
26
- AWS::S3::S3Object.should have_received(:store).with('/thing', "asdf", 'bucket')
27
- AWS::S3::S3Object.should have_received(:store).with('/hiphopper', "asdf", 'bucket')
26
+ AWS::S3::S3Object.should have_received(:store).with('thing', "asdf", 'bucket')
27
+ AWS::S3::S3Object.should have_received(:store).with('hiphopper', "asdf", 'bucket')
28
28
  File.delete("#{Dir.pwd}/files/thing")
29
29
  File.delete("#{Dir.pwd}/files/hiphopper")
30
30
  end
31
31
  end
32
+ context "with . as directory to deploy" do
33
+ it "doesn't strip out .'s in file names" do
34
+ create_file("blah.html", "asdf")
35
+ Dir.chdir "#{Dir.pwd}/files" do
36
+ subject.deploy '.', 'bucket'
37
+ end
38
+ AWS::S3::S3Object.should have_received(:store).with 'blah.html', 'asdf', 'bucket'
39
+ File.delete("#{Dir.pwd}/files/blah.html")
40
+ end
41
+ it "includes directories" do
42
+ Dir.mkdir 'files/sub' unless Dir.exists? 'files/sub'
43
+ create_file "sub/blah.html", "asdf"
44
+ Dir.chdir "#{Dir.pwd}/files" do
45
+ subject.deploy '.', 'bucket'
46
+ end
47
+ AWS::S3::S3Object.should have_received(:store).with 'sub/blah.html', 'asdf', 'bucket'
48
+ File.delete("#{Dir.pwd}/files/sub/blah.html")
49
+ end
50
+ end
32
51
  end
33
52
  end
34
53
  def create_file(filename, content)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-03-12 00:00:00.000000000 Z
12
+ date: 2012-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-s3
16
- requirement: &70290852195300 !ruby/object:Gem::Requirement
16
+ requirement: &70175425134860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,20 +21,25 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70290852195300
24
+ version_requirements: *70175425134860
25
25
  description: A simple way to deploy a directory to Amazon s3
26
26
  email:
27
27
  - zee@zeespencer.com
28
- executables: []
28
+ executables:
29
+ - s3deploy
29
30
  extensions: []
30
31
  extra_rdoc_files: []
31
32
  files:
33
+ - .gitignore
34
+ - .rbenv-gemsets
32
35
  - .rvmrc
33
36
  - Gemfile
34
37
  - Gemfile.lock
35
38
  - Makefile
36
39
  - README.markdown
37
40
  - Rakefile
41
+ - ShoveItOverThere.jpg
42
+ - bin/s3deploy
38
43
  - lib/s3deployer.rb
39
44
  - lib/s3deployer/version.rb
40
45
  - s3deployer.gemspec