cloud_encrypted_sync_s3_adapter 0.1.2 → 0.2.0
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.
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,13 +2,8 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
cloud_encrypted_sync_s3_adapter (0.1.2)
|
5
|
-
aws-sdk (~> 1.
|
6
|
-
cloud_encrypted_sync (~> 0.
|
7
|
-
|
8
|
-
PATH
|
9
|
-
remote: ~/workspace/cloud_encrypted_sync
|
10
|
-
specs:
|
11
|
-
cloud_encrypted_sync (0.1.1)
|
5
|
+
aws-sdk (~> 1.7.1)
|
6
|
+
cloud_encrypted_sync (~> 0.2.0)
|
12
7
|
|
13
8
|
GEM
|
14
9
|
remote: http://rubygems.org/
|
@@ -16,16 +11,17 @@ GEM
|
|
16
11
|
activesupport (3.2.3)
|
17
12
|
i18n (~> 0.6)
|
18
13
|
multi_json (~> 1.0)
|
19
|
-
aws-sdk (1.
|
14
|
+
aws-sdk (1.7.1)
|
20
15
|
httparty (~> 0.7)
|
21
16
|
json (~> 1.4)
|
22
17
|
nokogiri (>= 1.4.4)
|
23
18
|
uuidtools (~> 2.1)
|
24
|
-
|
19
|
+
cloud_encrypted_sync (0.2.0)
|
20
|
+
httparty (0.9.0)
|
25
21
|
multi_json (~> 1.0)
|
26
22
|
multi_xml
|
27
23
|
i18n (0.6.0)
|
28
|
-
json (1.7.
|
24
|
+
json (1.7.5)
|
29
25
|
metaclass (0.0.1)
|
30
26
|
mocha (0.11.4)
|
31
27
|
metaclass (~> 0.0.1)
|
@@ -37,14 +33,13 @@ GEM
|
|
37
33
|
multi_json (~> 1.0)
|
38
34
|
simplecov-html (~> 0.5.3)
|
39
35
|
simplecov-html (0.5.3)
|
40
|
-
uuidtools (2.1.
|
36
|
+
uuidtools (2.1.3)
|
41
37
|
|
42
38
|
PLATFORMS
|
43
39
|
ruby
|
44
40
|
|
45
41
|
DEPENDENCIES
|
46
42
|
activesupport
|
47
|
-
cloud_encrypted_sync!
|
48
43
|
cloud_encrypted_sync_s3_adapter!
|
49
44
|
mocha
|
50
45
|
rake
|
@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.summary = %q{Plugin adapter for CloudEncryptedSync gem that provides interface to AmazonS3.}
|
11
11
|
s.description = %q{Plugin adapter for CloudEncryptedSync gem that provides interface to AmazonS3.}
|
12
12
|
|
13
|
-
s.add_dependency('aws-sdk', '~> 1.
|
14
|
-
s.add_dependency('cloud_encrypted_sync', '~> 0.
|
13
|
+
s.add_dependency('aws-sdk', '~> 1.7.1')
|
14
|
+
s.add_dependency('cloud_encrypted_sync', '~> 0.2.0')
|
15
15
|
|
16
16
|
s.add_development_dependency('rake')
|
17
17
|
s.add_development_dependency('mocha')
|
@@ -4,59 +4,56 @@ module CloudEncryptedSync
|
|
4
4
|
module Adapters
|
5
5
|
class S3 < Template
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
opts.on('--bucket=BUCKETNAME', 'Name of S3 bucket to use.') do |bucket_name|
|
11
|
-
command_line_options[:bucket] = bucket_name
|
12
|
-
end
|
13
|
-
opts.on('--s3-credentials=ACCESS_KEY_ID,SECRET_ACCESS_KEY', Array, "Credentials for your S3 account." ) do| credentials|
|
14
|
-
command_line_options[:s3_credentials] = credentials
|
15
|
-
end
|
16
|
-
return command_line_options
|
7
|
+
def parse_command_line_options(opts,command_line_options)
|
8
|
+
opts.on('--bucket BUCKETNAME', 'Name of S3 bucket to use.') do |bucket_name|
|
9
|
+
command_line_options[:bucket] = bucket_name
|
17
10
|
end
|
18
|
-
|
19
|
-
|
20
|
-
bucket.objects.create(key,data)
|
11
|
+
opts.on('--s3-credentials ACCESS_KEY_ID,SECRET_ACCESS_KEY', Array, "Credentials for your S3 account." ) do| credentials|
|
12
|
+
command_line_options[:s3_credentials] = credentials
|
21
13
|
end
|
14
|
+
return command_line_options
|
15
|
+
end
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
rescue AWS::S3::Errors::NoSuchKey => exception
|
27
|
-
raise CloudEncryptedSync::Errors::NoSuchKey.new(exception.message)
|
28
|
-
end
|
29
|
-
end
|
17
|
+
def write(data, key)
|
18
|
+
bucket.objects.create(key,data)
|
19
|
+
end
|
30
20
|
|
31
|
-
|
32
|
-
|
21
|
+
def read(key)
|
22
|
+
begin
|
23
|
+
bucket.objects[key].read
|
24
|
+
rescue AWS::S3::Errors::NoSuchKey => exception
|
25
|
+
raise CloudEncryptedSync::Errors::NoSuchKey.new(exception.message)
|
33
26
|
end
|
27
|
+
end
|
34
28
|
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
def delete(key)
|
30
|
+
bucket.objects[key].delete
|
31
|
+
end
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
def key_exists?(key)
|
34
|
+
bucket.objects[key].exists?
|
35
|
+
end
|
42
36
|
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
#######
|
38
|
+
private
|
39
|
+
#######
|
46
40
|
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
def credentials
|
42
|
+
Configuration.settings[:s3_credentials]
|
43
|
+
end
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
def connection
|
46
|
+
@connection ||= AWS::S3.new(:access_key_id => credentials[0], :secret_access_key => credentials[1])
|
47
|
+
end
|
54
48
|
|
55
|
-
|
56
|
-
|
57
|
-
|
49
|
+
def bucket_name
|
50
|
+
Configuration.settings[:bucket].to_sym
|
51
|
+
end
|
58
52
|
|
53
|
+
def bucket
|
54
|
+
connection.buckets[bucket_name]
|
59
55
|
end
|
56
|
+
|
60
57
|
end
|
61
58
|
end
|
62
59
|
end
|
data/test/test_helper.rb
CHANGED
@@ -13,18 +13,10 @@ require 'cloud_encrypted_sync_s3_adapter'
|
|
13
13
|
module CloudEncryptedSyncS3Adapter
|
14
14
|
class ActiveSupport::TestCase
|
15
15
|
|
16
|
-
setup :preset_environment
|
17
|
-
|
18
|
-
def preset_environment
|
19
|
-
CloudEncryptedSync::Master.instance_variable_set(:@config,nil)
|
20
|
-
CloudEncryptedSync::Master.instance_variable_set(:@command_line_options, {
|
21
|
-
:data_dir => "#{Etc.getpwuid.dir}/.cloud_encrypted_sync"
|
22
|
-
})
|
23
|
-
end
|
24
|
-
|
25
16
|
def adapter
|
26
17
|
CloudEncryptedSync::Adapters::S3
|
27
18
|
end
|
19
|
+
|
28
20
|
end
|
29
21
|
end
|
30
22
|
require 'mocha'
|
data/test/unit/adapter_test.rb
CHANGED
@@ -19,6 +19,21 @@ module CloudEncryptedSyncS3Adapter
|
|
19
19
|
create_test_bucket
|
20
20
|
end
|
21
21
|
|
22
|
+
def teardown
|
23
|
+
delete_test_bucket
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'should parse command line options' do
|
27
|
+
Object.send(:remove_const,:ARGV)
|
28
|
+
::ARGV = '--bucket foobar --s3-credentials KEY_ID,ACCESS_KEY'.split(/\s/)
|
29
|
+
@command_line_options = {}
|
30
|
+
@option_parser = OptionParser.new do |opts|
|
31
|
+
@command_line_options = adapter.parse_command_line_options(opts,@command_line_options)
|
32
|
+
end
|
33
|
+
@option_parser.parse!
|
34
|
+
assert_equal({:bucket => 'foobar', :s3_credentials => ['KEY_ID','ACCESS_KEY']},@command_line_options)
|
35
|
+
end
|
36
|
+
|
22
37
|
test 'should write readable data to s3 and then delete it' do
|
23
38
|
|
24
39
|
skip 'S3 credentials for test bucket not provided.' unless credentials.is_a?(Array) and credentials != []
|
@@ -27,14 +42,14 @@ module CloudEncryptedSyncS3Adapter
|
|
27
42
|
test_key = 'testkey'
|
28
43
|
|
29
44
|
assert !adapter.key_exists?(test_key)
|
30
|
-
assert_difference('adapter.send(:bucket).objects.count') do
|
45
|
+
assert_difference('adapter.instance.send(:bucket).objects.count') do
|
31
46
|
adapter.write(test_data,test_key)
|
32
47
|
end
|
33
48
|
assert adapter.key_exists?(test_key)
|
34
49
|
|
35
50
|
assert_equal(test_data,adapter.read(test_key))
|
36
51
|
|
37
|
-
assert_difference('adapter.send(:bucket).objects.count',-1) do
|
52
|
+
assert_difference('adapter.instance.send(:bucket).objects.count',-1) do
|
38
53
|
adapter.delete(test_key)
|
39
54
|
end
|
40
55
|
assert !adapter.key_exists?(test_key)
|
@@ -54,11 +69,11 @@ module CloudEncryptedSyncS3Adapter
|
|
54
69
|
end
|
55
70
|
|
56
71
|
def create_test_bucket
|
57
|
-
adapter.send(:connection).buckets.create(test_bucket_name)
|
72
|
+
adapter.instance.send(:connection).buckets.create(test_bucket_name)
|
58
73
|
end
|
59
74
|
|
60
75
|
def delete_test_bucket
|
61
|
-
adapter.send(:bucket).delete! unless credentials == [] or !credentials.is_a?(Array)
|
76
|
+
adapter.instance.send(:bucket).delete! unless credentials == [] or !credentials.is_a?(Array)
|
62
77
|
end
|
63
78
|
|
64
79
|
def test_bucket_name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_encrypted_sync_s3_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.7.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.7.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: cloud_encrypted_sync
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.2.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.2.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rake
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|