s3_patron 0.0.2.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/s3patron +5 -0
- data/lib/s3_patron/cli.rb +89 -0
- data/lib/s3_patron/version.rb +3 -0
- data/lib/s3_patron.rb +6 -0
- data/s3_patron.gemspec +39 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ee834c0adc8d8c42f5f666dd151ef4166eca805
|
4
|
+
data.tar.gz: 39b5afc021171e595a5db2972a34d2444322f04e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 90f7f921c5e3a0a84453ab532226d87b0d0162a115252b8aa8dc352851b072b59cec1620ead4dc30809e9187587e6e71ad176442bd7865195f512298aa4de2e4
|
7
|
+
data.tar.gz: f6c799ab4fcd202f2b01500a2258776538c1043ffa5b83fece38835adf317851b94ef3acdea9bd431d4799f7c46a91c4a558cedeb10a54fdb919826e8e3ad119
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at suyeshb@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Suyesh Bhandari
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# S3-Patron - Command-line utility for S3 written in Ruby
|
2
|
+

|
3
|
+
|
4
|
+
S3-Patron lets you list, upload, download to and from s3 using your terminal
|
5
|
+
|
6
|
+
|
7
|
+
## Setup
|
8
|
+
Make sure [Ruby](https://www.ruby-lang.org/en/documentation/installation/) is installed.
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
```
|
12
|
+
$ gem install s3_patron
|
13
|
+
```
|
14
|
+
|
15
|
+
Set ENV variables
|
16
|
+
|
17
|
+
```
|
18
|
+
$ export AWS_ACCESS_KEY_ID="YOUR AWS ACCESS KEY"
|
19
|
+
$ export AWS_SECRET_ACCESS_KEY="YOUR AWS SECERET KEY"
|
20
|
+
$ export AWS_REGION="AWS REGION"
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```
|
26
|
+
Commands:
|
27
|
+
s3patron buckets REGION(OPTIONAL) # List all buckets
|
28
|
+
s3patron create BUCKET_NAME REGION(OPTIONAL) # create bucket
|
29
|
+
s3patron download BUCKET_NAME OBJECT DOWNLOAD_LOCATION(OPTIONAL) REGION(OPTIONAL) # Download object from bucket
|
30
|
+
s3patron help [COMMAND] # Describe Commands
|
31
|
+
s3patron list BUCKET_NAME REGION(OPTIONAL) # List objects inside bucket
|
32
|
+
s3patron upload BUCKET_NAME FILE REGION(OPTIONAL) PATH_TO_FILE # Upload into bucket
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "s3_patron"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/s3patron
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
require 'thor'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
module S3Patron
|
6
|
+
class Cli < Thor
|
7
|
+
desc 'list BUCKET_NAME REGION(OPTIONAL)', 'List objects inside of a bucket'
|
8
|
+
method_option :all, type: :boolean, default: false, aliases: '-a', desc: 'List all items'
|
9
|
+
method_option :limit, type: :numeric, default: 50, aliases: '-l', desc: 'Set limit of items to display'
|
10
|
+
def list(bucket, region=ENV['AWS_REGION'])
|
11
|
+
s3 = Aws::S3::Resource.new(region: region)
|
12
|
+
bucket = s3.bucket(bucket)
|
13
|
+
begin
|
14
|
+
if options[:all]
|
15
|
+
puts "Showing all objects inside bucket named #{bucket.name}.".yellow
|
16
|
+
bucket.objects.each do |item|
|
17
|
+
puts item.key
|
18
|
+
end
|
19
|
+
else
|
20
|
+
puts "Showing first #{options[:limit]} objects from #{bucket.name}.Use -a flag to show all objects".yellow
|
21
|
+
bucket.objects.limit(options[:limit]).each do |item|
|
22
|
+
puts item.key
|
23
|
+
end
|
24
|
+
end
|
25
|
+
rescue
|
26
|
+
puts 'Something went wrong. Please try again.'.red
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'upload BUCKET_NAME FILE REGION(OPTIONAL) PATH_TO_FILE', 'Upload into a bucket'
|
31
|
+
method_option :bucket, type: :string, default: false, aliases: '-b', desc: 'Name of the bucket where you want to upload'
|
32
|
+
def upload(bucket_name, file, region=ENV['AWS_REGION'])
|
33
|
+
s3 = Aws::S3::Resource.new(region: region)
|
34
|
+
begin
|
35
|
+
item = file
|
36
|
+
bucket = bucket_name
|
37
|
+
name = File.basename(item)
|
38
|
+
obj = s3.bucket(bucket).object(name)
|
39
|
+
obj.upload_file(item)
|
40
|
+
puts "#{file} successfully uploaded to #{bucket}".yellow
|
41
|
+
rescue
|
42
|
+
puts "Something went wrong. Please try again.".red
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'create BUCKET_NAME REGION(OPTIONAL)', 'create a bucket'
|
47
|
+
def create(bucket_name, region=ENV['AWS_REGION'])
|
48
|
+
s3 = Aws::S3::Resource.new(region: region)
|
49
|
+
s3.create_bucket(bucket: bucket_name.to_s)
|
50
|
+
puts "#{bucket_name} successfully created.".yellow
|
51
|
+
rescue Aws::S3::Errors::BucketAlreadyExists
|
52
|
+
puts 'The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.'.red
|
53
|
+
rescue Aws::S3::Errors::InvalidBucketName
|
54
|
+
puts "The specified bucket name is not a valid format based on AWS guidelines.\nFor more info please visit http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html".red
|
55
|
+
rescue Aws::S3::Errors::BucketAlreadyOwnedByYou
|
56
|
+
puts "There is already an existing bucket with the same name".red
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'download BUCKET_NAME OBJECT DOWNLOAD_LOCATION(OPTIONAL) REGION(OPTIONAL)', 'Download object from a bucket'
|
60
|
+
method_option :path, type: :string, default: false, aliases: '-p', desc: 'File path of location you want the file to be downloaded.'
|
61
|
+
def download(bucket_name, item, path=Dir.pwd, region=ENV['AWS_REGION'])
|
62
|
+
s3 = Aws::S3::Resource.new(region: region)
|
63
|
+
obj = s3.bucket(bucket_name).object(item)
|
64
|
+
obj.get(response_target: "#{path}/#{obj.key}")
|
65
|
+
end
|
66
|
+
|
67
|
+
desc 'buckets REGION(OPTIONAL)', 'List all the buckets in S3 account'
|
68
|
+
method_option :all, type: :boolean, default: false, aliases: '-a', desc: 'List all Items'
|
69
|
+
method_option :limit, type: :numeric, default: 50, aliases: '-l', desc: 'Set limit of items to display'
|
70
|
+
def buckets(region=ENV['AWS_REGION'])
|
71
|
+
s3 = Aws::S3::Resource.new(region: region)
|
72
|
+
begin
|
73
|
+
if options[:all]
|
74
|
+
puts 'Showing all buckets.'.yellow
|
75
|
+
s3.buckets.each do |b|
|
76
|
+
puts b.name.to_s
|
77
|
+
end
|
78
|
+
else
|
79
|
+
puts "Showing first #{options[:limit]} buckets.Use -a flag to show all listings".yellow
|
80
|
+
s3.buckets.limit(options[:limit]).each do |b|
|
81
|
+
puts b.name.to_s
|
82
|
+
end
|
83
|
+
end
|
84
|
+
rescue
|
85
|
+
puts 'Something went wrong. Please try again.'.red
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/s3_patron.rb
ADDED
data/s3_patron.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 's3_patron/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "s3_patron"
|
8
|
+
spec.version = S3Patron::VERSION
|
9
|
+
spec.authors = ["Suyesh Bhandari"]
|
10
|
+
spec.email = ["suyeshb@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Command-line utility to manage S3"
|
13
|
+
spec.description = "Command-line utility to manage S3"
|
14
|
+
spec.homepage = "https://github.com/suyesh/s3_patron"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "pry"
|
36
|
+
spec.add_dependency 'thor', '~> 0.19.4'
|
37
|
+
spec.add_dependency 'aws-sdk', '~> 2.6', '>= 2.6.35'
|
38
|
+
spec.add_dependency 'colorize'
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: s3_patron
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Suyesh Bhandari
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.19.4
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.19.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aws-sdk
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.6'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.6.35
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.6'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.6.35
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: colorize
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
description: Command-line utility to manage S3
|
104
|
+
email:
|
105
|
+
- suyeshb@gmail.com
|
106
|
+
executables:
|
107
|
+
- s3patron
|
108
|
+
extensions: []
|
109
|
+
extra_rdoc_files: []
|
110
|
+
files:
|
111
|
+
- ".gitignore"
|
112
|
+
- CODE_OF_CONDUCT.md
|
113
|
+
- Gemfile
|
114
|
+
- LICENSE.txt
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
119
|
+
- exe/s3patron
|
120
|
+
- lib/s3_patron.rb
|
121
|
+
- lib/s3_patron/cli.rb
|
122
|
+
- lib/s3_patron/version.rb
|
123
|
+
- s3_patron.gemspec
|
124
|
+
homepage: https://github.com/suyesh/s3_patron
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata:
|
128
|
+
allowed_push_host: https://rubygems.org
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 1.3.1
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.6.8
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Command-line utility to manage S3
|
149
|
+
test_files: []
|