s3rbsync 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/s3rbsync +8 -0
- data/lib/s3rbsync/command.rb +55 -0
- data/lib/s3rbsync/configure.rb +30 -0
- data/lib/s3rbsync/synchronizer.rb +23 -0
- data/lib/s3rbsync/version.rb +3 -0
- data/lib/s3rbsync.rb +10 -0
- data/s3rbsync.gemspec +23 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebc53f7796f4a28c4735b5d5076ff8f3750b7863
|
4
|
+
data.tar.gz: 3150ca401442393cd9eef4f286ad02f0b58a0a68
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d52365fb6ccbc4579e301605d9dbf8b7f271a055e38b40a8a33135df306141efca6670fc22771d45bb2b8ac19621983b65cbe9d588465c5647b37ab44100cf2c
|
7
|
+
data.tar.gz: 9c7da501f5b6569db26706eb5e3276a60b4469d8e3b0ee7e243271da897958b37dfd6b9e7276b6817e08ed5a4454667d613cc380e71de321578bafab11593786
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Naohiro Sakuma
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# S3rbsync
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 's3rbsync'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install s3rbsync
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/s3rbsync
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module S3rbsync
|
4
|
+
class Command < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
desc 'init', "Set up S3rbsync. (ganerate configure)"
|
8
|
+
def init
|
9
|
+
if yes? "Do you wish to continue [yes(y) / no(n)] ?", :cyan
|
10
|
+
access_key = ask("aws_access_key:")
|
11
|
+
secret_key = ask("aws_secret_access_key:")
|
12
|
+
bucket_name = ask("bucket_name:")
|
13
|
+
create_file "~/.aws.yml" do
|
14
|
+
<<-"YAML"
|
15
|
+
:aws_access_key: #{access_key}
|
16
|
+
:aws_secret_access_key: #{secret_key}
|
17
|
+
:bucket_name: #{bucket_name}
|
18
|
+
YAML
|
19
|
+
end
|
20
|
+
else
|
21
|
+
puts "...exit"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'test', "The connection test to AWS."
|
26
|
+
def test
|
27
|
+
say "\nChecking config...\n", :cyan
|
28
|
+
conf = S3rbsync::Configure.new
|
29
|
+
print "Config file: "
|
30
|
+
if conf.valid_yaml_file?
|
31
|
+
say "OK\n", :green
|
32
|
+
else
|
33
|
+
say "NG\n", :red
|
34
|
+
say "\n...Done\n", :cyan
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
38
|
+
print "Test connection: "
|
39
|
+
if conf.connected?
|
40
|
+
say "OK", :green
|
41
|
+
#...
|
42
|
+
else
|
43
|
+
say "NG", :red
|
44
|
+
say " -> Connection falid: Chack config file, or 's3rbsync init'", :yellow
|
45
|
+
end
|
46
|
+
say "\n...Done\n", :cyan
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'hello', "say hello."
|
50
|
+
def hello
|
51
|
+
puts "hello s3rbsync world"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module S3rbsync
|
4
|
+
class Configure
|
5
|
+
CONF_FILE = "#{ENV["HOME"]}/.aws.yml"
|
6
|
+
attr_accessor :access_key, :secret_key, :bucket_name
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@access_key = @secret_key = @bucket_name = @error_message = nil
|
10
|
+
begin
|
11
|
+
@conf = YAML.load_file CONF_FILE
|
12
|
+
rescue => e
|
13
|
+
@error_message = "Error: #{e.message}"
|
14
|
+
else
|
15
|
+
@access_key = @conf[:aws_access_key]
|
16
|
+
@secret_key = @conf[:aws_secret_access_key]
|
17
|
+
@bucket_name = @conf[:bucket_name]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid_yaml_file?
|
22
|
+
@error_message.nil? and @access_key and @secret_key and @bucket_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def connected?
|
26
|
+
s3 = S3rbsync::Synchronizer.new(self)
|
27
|
+
s3.connected?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'fog'
|
2
|
+
|
3
|
+
module S3rbsync
|
4
|
+
class Synchronizer
|
5
|
+
|
6
|
+
def initialize(configure)
|
7
|
+
@configure = configure
|
8
|
+
@s3= Fog::Storage.new(:provider => 'AWS',
|
9
|
+
:aws_access_key_id => @configure.access_key,
|
10
|
+
:aws_secret_access_key => @configure.secret_key,
|
11
|
+
:region => 'ap-northeast-1', # TODO: get configre
|
12
|
+
:persistent => false )
|
13
|
+
end
|
14
|
+
|
15
|
+
def connected?
|
16
|
+
@s3.get_bucket(@configure.bucket_name)
|
17
|
+
rescue
|
18
|
+
false
|
19
|
+
else
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/s3rbsync.rb
ADDED
data/s3rbsync.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 's3rbsync/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "s3rbsync"
|
8
|
+
spec.version = S3rbsync::VERSION
|
9
|
+
spec.authors = ["Naohiro Sakuma"]
|
10
|
+
spec.email = ["nao.bear@gmail.com"]
|
11
|
+
spec.description = %q{Synchronize the files to S3.}
|
12
|
+
spec.summary = %q{Synchronize the files to S3.}
|
13
|
+
spec.homepage = "https://github.com/n-sakuma/s3rbsync"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = ['s3rbsync']
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: s3rbsync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naohiro Sakuma
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-01 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Synchronize the files to S3.
|
42
|
+
email:
|
43
|
+
- nao.bear@gmail.com
|
44
|
+
executables:
|
45
|
+
- s3rbsync
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/s3rbsync
|
55
|
+
- lib/s3rbsync.rb
|
56
|
+
- lib/s3rbsync/command.rb
|
57
|
+
- lib/s3rbsync/configure.rb
|
58
|
+
- lib/s3rbsync/synchronizer.rb
|
59
|
+
- lib/s3rbsync/version.rb
|
60
|
+
- s3rbsync.gemspec
|
61
|
+
homepage: https://github.com/n-sakuma/s3rbsync
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.0.3
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Synchronize the files to S3.
|
85
|
+
test_files: []
|