cloud_encrypted_sync 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/cloud_encrypted_sync/adapter_template.rb +3 -3
- data/lib/cloud_encrypted_sync/configuration.rb +6 -6
- data/lib/cloud_encrypted_sync/dummy_adapter.rb +4 -8
- data/lib/cloud_encrypted_sync/version.rb +1 -1
- data/test/test_helper.rb +2 -0
- data/test/unit/adapter_template_test.rb +1 -1
- data/test/unit/configuration_test.rb +1 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -14,8 +14,8 @@ module CloudEncryptedSync
|
|
14
14
|
@children ||= {}
|
15
15
|
end
|
16
16
|
|
17
|
-
def parse_command_line_options(
|
18
|
-
instance.parse_command_line_options(
|
17
|
+
def parse_command_line_options(parser)
|
18
|
+
instance.parse_command_line_options(parser)
|
19
19
|
end
|
20
20
|
|
21
21
|
def write(data, key)
|
@@ -49,7 +49,7 @@ module CloudEncryptedSync
|
|
49
49
|
|
50
50
|
end
|
51
51
|
|
52
|
-
def parse_command_line_options(
|
52
|
+
def parse_command_line_options(parser)
|
53
53
|
raise Errors::TemplateMethodCalled.new('parse_command_line_options')
|
54
54
|
end
|
55
55
|
|
@@ -66,16 +66,16 @@ module CloudEncryptedSync
|
|
66
66
|
executable_name = File.basename($PROGRAM_NAME)
|
67
67
|
clo = {:data_dir => "#{Etc.getpwuid.dir}/.cloud_encrypted_sync"}
|
68
68
|
|
69
|
-
@option_parser = OptionParser.new do |
|
70
|
-
|
71
|
-
|
69
|
+
@option_parser = OptionParser.new do |parser|
|
70
|
+
parser.banner = "Usage: #{executable_name} [options] /path/to/folder/to/sync"
|
71
|
+
parser.on('--data-dir PATH',"Data directory where indexes and config file are found.") do |path|
|
72
72
|
clo[:data_dir] = path
|
73
73
|
end
|
74
|
-
|
74
|
+
parser.on('--adapter ADAPTERNAME', 'Name of cloud adapter to use.') do |adapter_name|
|
75
75
|
clo[:adapter_name] = adapter_name
|
76
|
-
|
76
|
+
AdapterLiaison.instance.adapters[adapter_name.to_sym].parse_command_line_options(parser)
|
77
77
|
end
|
78
|
-
|
78
|
+
parser.on('--encryption-key KEY') do |key|
|
79
79
|
clo[:encryption_key] = key
|
80
80
|
end
|
81
81
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module CloudEncryptedSync
|
2
2
|
module Adapters
|
3
3
|
class Dummy < Template
|
4
|
+
attr_accessor :bucket_name
|
4
5
|
|
5
6
|
def write(data,key)
|
6
7
|
stored_data[bucket_name][key] = data
|
7
8
|
end
|
8
9
|
|
9
|
-
def parse_command_line_options(
|
10
|
-
|
11
|
-
|
10
|
+
def parse_command_line_options(parser)
|
11
|
+
parser.on('--bucket BUCKETNAME', 'Name of cloud adapter to use.') do |bucket_argument|
|
12
|
+
self.bucket_name = bucket_argument
|
12
13
|
end
|
13
|
-
return command_line_options
|
14
14
|
end
|
15
15
|
|
16
16
|
def read(key)
|
@@ -34,10 +34,6 @@ module CloudEncryptedSync
|
|
34
34
|
@stored_data ||= { bucket_name => {} }
|
35
35
|
end
|
36
36
|
|
37
|
-
def bucket_name
|
38
|
-
Configuration.settings[:bucket].to_sym
|
39
|
-
end
|
40
|
-
|
41
37
|
end
|
42
38
|
end
|
43
39
|
end
|
data/test/test_helper.rb
CHANGED
@@ -33,11 +33,13 @@ module CloudEncryptedSync
|
|
33
33
|
:sync_path => test_source_folder
|
34
34
|
})
|
35
35
|
Configuration.stubs(:data_folder_path).returns("#{Etc.getpwuid.dir}/.cloud_encrypted_sync")
|
36
|
+
Adapters::Dummy.any_instance.stubs(:bucket_name).returns('test-bucket')
|
36
37
|
end
|
37
38
|
|
38
39
|
def unstub_configuration
|
39
40
|
Configuration.unstub(:settings)
|
40
41
|
Configuration.unstub(:data_folder_path)
|
42
|
+
Adapters::Dummy.any_instance.unstub(:bucket_name)
|
41
43
|
end
|
42
44
|
|
43
45
|
def test_source_folder
|
@@ -15,7 +15,7 @@ module CloudEncryptedSync
|
|
15
15
|
test 'should raise errors on public methods' do
|
16
16
|
|
17
17
|
method_argument_map = {
|
18
|
-
:parse_command_line_options =>
|
18
|
+
:parse_command_line_options => :foo,
|
19
19
|
:write => [:foo,:bar],
|
20
20
|
:read => :foobar,
|
21
21
|
:delete => :foobar,
|
@@ -17,7 +17,7 @@ module CloudEncryptedSync
|
|
17
17
|
assert_equal('dummy',settings[:adapter_name])
|
18
18
|
assert_equal('~/test/folder',settings[:data_dir])
|
19
19
|
assert_equal('somestringofcharacters',settings[:encryption_key])
|
20
|
-
assert_equal('foobar',
|
20
|
+
assert_equal('foobar',Adapters::Dummy.instance.bucket_name)
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'should gracefully fail without path in ARGV' do
|