sss 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sss.rb +39 -9
- metadata +45 -66
data/lib/sss.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
require "digest/md5"
|
2
|
+
|
1
3
|
class Sss
|
2
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.2"
|
3
5
|
|
4
6
|
NoBuckets = Class.new(StandardError)
|
5
7
|
NoFiles = Class.new(StandardError)
|
6
|
-
|
8
|
+
|
7
9
|
attr :files
|
8
10
|
|
9
11
|
def initialize
|
@@ -14,9 +16,9 @@ class Sss
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def add_file(file)
|
17
|
-
files << [file, File.basename(file)]
|
19
|
+
files << [file, File.basename(file)]
|
18
20
|
end
|
19
|
-
|
21
|
+
|
20
22
|
def use_key(key)
|
21
23
|
files.last[1] = key if files.any?
|
22
24
|
end
|
@@ -24,7 +26,7 @@ class Sss
|
|
24
26
|
def upload(buckets)
|
25
27
|
raise NoBuckets if buckets.empty?
|
26
28
|
raise NoFiles if files.empty?
|
27
|
-
|
29
|
+
|
28
30
|
connect
|
29
31
|
|
30
32
|
buckets.each do |bucket|
|
@@ -32,13 +34,29 @@ class Sss
|
|
32
34
|
|
33
35
|
files.each do |file, key|
|
34
36
|
AWS::S3::S3Object.store(key, File.open(file), bucket, options)
|
35
|
-
|
37
|
+
status(:copied, key, file, options)
|
38
|
+
|
39
|
+
if AWS::S3::S3Object.exists?(key, bucket)
|
40
|
+
status(:exists, key, file, options)
|
41
|
+
|
42
|
+
digest = Digest::MD5.file(file).hexdigest
|
43
|
+
|
44
|
+
object = AWS::S3::S3Object.find(key, bucket)
|
45
|
+
|
46
|
+
if digest == object.about["etag"].tr('"', "")
|
47
|
+
status(:checksum, key, file, options)
|
48
|
+
else
|
49
|
+
error("#{key} checksum failed.")
|
50
|
+
end
|
51
|
+
else
|
52
|
+
error("#{key} does not exist.")
|
53
|
+
end
|
36
54
|
end
|
37
55
|
end
|
38
56
|
end
|
39
|
-
|
57
|
+
|
40
58
|
def access(access)
|
41
|
-
@access = access
|
59
|
+
@access = access
|
42
60
|
end
|
43
61
|
|
44
62
|
def cache_control(cache_control)
|
@@ -46,6 +64,18 @@ class Sss
|
|
46
64
|
end
|
47
65
|
|
48
66
|
private
|
67
|
+
def status(type, key, file, options)
|
68
|
+
if options.any?
|
69
|
+
puts " #{key} -> #{file} (#{options.inspect}) [#{type}]"
|
70
|
+
else
|
71
|
+
puts " #{key} -> #{file} [#{type}]"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def error(message)
|
76
|
+
puts " !! #{message}"
|
77
|
+
end
|
78
|
+
|
49
79
|
def connect
|
50
80
|
require "aws/s3"
|
51
81
|
|
@@ -61,4 +91,4 @@ private
|
|
61
91
|
ret["Cache-Control"] = @cache_control if defined?(@cache_control)
|
62
92
|
end
|
63
93
|
end
|
64
|
-
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,70 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sss
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Cyril David
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2010-11-22 00:00:00 +08:00
|
12
|
+
date: 2011-07-26 00:00:00.000000000 +08:00
|
18
13
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
21
16
|
name: clap
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &2156016860 !ruby/object:Gem::Requirement
|
24
18
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
31
23
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: aws-s3
|
35
24
|
prerelease: false
|
36
|
-
|
25
|
+
version_requirements: *2156016860
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: aws-s3
|
28
|
+
requirement: &2156015860 !ruby/object:Gem::Requirement
|
37
29
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 0
|
43
|
-
version: "0"
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
44
34
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: cutest
|
48
35
|
prerelease: false
|
49
|
-
|
36
|
+
version_requirements: *2156015860
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: cutest
|
39
|
+
requirement: &2156015080 !ruby/object:Gem::Requirement
|
50
40
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
- 0
|
56
|
-
version: "0"
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
57
45
|
type: :development
|
58
|
-
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2156015080
|
59
48
|
description:
|
60
49
|
email: cyx@pipetodevnull.com
|
61
|
-
executables:
|
50
|
+
executables:
|
62
51
|
- sss
|
63
52
|
extensions: []
|
64
|
-
|
65
53
|
extra_rdoc_files: []
|
66
|
-
|
67
|
-
files:
|
54
|
+
files:
|
68
55
|
- lib/sss.rb
|
69
56
|
- README
|
70
57
|
- test/sss_test.rb
|
@@ -72,34 +59,26 @@ files:
|
|
72
59
|
has_rdoc: true
|
73
60
|
homepage: http://github.com/cyx/sss
|
74
61
|
licenses: []
|
75
|
-
|
76
62
|
post_install_message:
|
77
63
|
rdoc_options: []
|
78
|
-
|
79
|
-
require_paths:
|
64
|
+
require_paths:
|
80
65
|
- lib
|
81
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
67
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
|
88
|
-
version: "0"
|
89
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
73
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
|
95
|
-
- 0
|
96
|
-
version: "0"
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
97
78
|
requirements: []
|
98
|
-
|
99
79
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 1.6.2
|
101
81
|
signing_key:
|
102
82
|
specification_version: 2
|
103
83
|
summary: Simple CLI interface for copying files to S3.
|
104
84
|
test_files: []
|
105
|
-
|