s3cmd 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/LICENSE +19 -0
  2. data/README.md +23 -0
  3. data/bin/s3cmd +4 -0
  4. data/lib/s3cmd.rb +71 -0
  5. data/lib/s3cmd/version.rb +3 -0
  6. metadata +120 -0
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Samuel Kadolph
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ # s3cmd
2
+
3
+ ## Installing
4
+
5
+ ### Recommended
6
+
7
+ ```
8
+ gem install s3cmd
9
+ ```
10
+
11
+ ### Edge
12
+
13
+ ```
14
+ git clone https://github.com/samuelkadolph/s3cmd
15
+ cd s3cmd && rake install
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```
21
+ s3cmd create-bucket foo
22
+ s3cmd put foo abc/def somefile
23
+ ```
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "s3cmd"
4
+ S3Cmd::Main.start
@@ -0,0 +1,71 @@
1
+ require "rubygems"
2
+ require "aws"
3
+ require "proxifier/env"
4
+ require "thor"
5
+
6
+ module S3Cmd
7
+ require "s3cmd/version"
8
+
9
+ class Main < Thor
10
+ desc "list-buckets", "lists all of your buckets"
11
+ def list_buckets
12
+ puts s3.buckets
13
+ end
14
+
15
+ desc "create-bucket name", "creates a bucket"
16
+ method_option :region, :default => "US"
17
+ def create_bucket(name)
18
+ bucket = s3.bucket(name, true)
19
+ end
20
+
21
+ desc "list-keys bucket", "list the keys of a bucket"
22
+ def list_keys(bucket)
23
+ puts s3.bucket(bucket).keys
24
+ end
25
+
26
+ desc "get bucket key", "get the file for the key from the bucket"
27
+ def get(bucket, key)
28
+ bucket = s3.bucket(bucket)
29
+ $stdout << bucket.get(key)
30
+ end
31
+
32
+ desc "put bucket key file", "puts a file for the key in the bucket"
33
+ def put(bucket, key, file)
34
+ bucket = s3.bucket(bucket)
35
+ File.open(file, "r") { |f| bucket.put(key, f) }
36
+ end
37
+
38
+ private
39
+ def s3
40
+ @s3 ||= begin
41
+ access_key, secret_key = nil, nil
42
+
43
+ if ENV["AWS_CREDENTIAL_FILE"]
44
+ File.open(ENV["AWS_CREDENTIAL_FILE"]) do |file|
45
+ file.lines.each do |line|
46
+ access_key = $1 if line =~ /^AWSAccessKeyId=(.*)$/
47
+ secret_key = $1 if line =~ /^AWSSecretKey=(.*)$/
48
+ end
49
+ end
50
+ elsif ENV["AWS_ACCESS_KEY"] || ENV["AWS_SECRET_KEY"]
51
+ access_key = ENV["AWS_ACCESS_KEY"]
52
+ secret_key = ENV["AWS_SECRET_KEY"]
53
+ end
54
+
55
+ unless access_key
56
+ $stderr.puts "AWS_CREDENTIAL_FILE must containt AWSAccessKeyId or AWS_ACCESS_KEY must be set"
57
+ exit 1
58
+ end
59
+ unless secret_key
60
+ $stderr.puts "AWS_CREDENTIAL_FILE must containt AWSSecretKey or AWS_SECRET_KEY must be set"
61
+ exit 1
62
+ end
63
+
64
+ logger = Logger.new(STDERR)
65
+ logger.level = Logger::FATAL
66
+
67
+ Aws::S3.new(access_key, secret_key, :logger => logger)
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module S3Cmd
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: s3cmd
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Samuel Kadolph
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-25 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: aws
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 23
29
+ segments:
30
+ - 2
31
+ - 5
32
+ - 6
33
+ version: 2.5.6
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: proxifier
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: thor
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 43
59
+ segments:
60
+ - 0
61
+ - 14
62
+ - 6
63
+ version: 0.14.6
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ description: |
67
+ Provides a s3cmd binary that allows you to create and list buckets as well as list the keys of a bucket and get and upload files
68
+ to s3.
69
+
70
+ email:
71
+ - samuel@kadolph.com
72
+ executables:
73
+ - s3cmd
74
+ extensions: []
75
+
76
+ extra_rdoc_files: []
77
+
78
+ files:
79
+ - bin/s3cmd
80
+ - lib/s3cmd/version.rb
81
+ - lib/s3cmd.rb
82
+ - LICENSE
83
+ - README.md
84
+ homepage: https://github.com/samuelkadolph/s3cmd
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options: []
89
+
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 57
98
+ segments:
99
+ - 1
100
+ - 8
101
+ - 7
102
+ version: 1.8.7
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ requirements: []
113
+
114
+ rubyforge_project:
115
+ rubygems_version: 1.8.6
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: Simple cli tool for interacting with S3.
119
+ test_files: []
120
+