cloud_encrypted_sync 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloud_encrypted_sync (0.3.0)
4
+ cloud_encrypted_sync (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -23,11 +23,14 @@ preferred cloud.
23
23
  CES runs as a command line tool and takes options as CLI arguments and/or from a config file.
24
24
  Arguments passed at the command line take precedence over those in the config file.
25
25
 
26
- ### Example
26
+ ### Example (assuming CES S3 Adapter gem is installed)
27
27
 
28
- ces --adapter=s3 --bucket=my-backup-bucket \
29
- --s3-credentials=ACCESS_KEY_ID,SECRET_ACCESS_KEY \
30
- --encryption-key=MYENCRYPTIONKEY /path/to/source/folder
28
+ ces --adapter s3 \
29
+ --s3-bucket my-backup-bucket \
30
+ --s3-access-key-id ACCESS_KEY_ID \
31
+ --s3-access-id SECRET_ACCESS_KEY \
32
+ --encryption-key MYENCRYPTIONKEY \
33
+ /path/to/source/folder
31
34
 
32
35
  ## Configuration
33
36
 
@@ -37,13 +40,13 @@ The default location for the config file is `~/.cloud_encrypted_sync/config.rc.y
37
40
 
38
41
  ### Available Settings
39
42
 
40
- CES requires the following configuration settings. Any of thse may alternatively be placed in
41
- the `config.rc.yml` execpt for `--data-dir` (which tells CES which folder contains the config
43
+ CES requires the following configuration settings. Any of these may alternatively be placed in
44
+ the `config.rc.yml` except for `--data-dir` (which tells CES which folder contains the config
42
45
  file to use).
43
46
 
44
- * `--adapter=ADAPTERNAME` The name of the adapter to use. See instructions for your preferred
47
+ * `--adapter ADAPTERNAME` The name of the adapter to use. See instructions for your preferred
45
48
  adapter for instructions of what to place here.
46
- * `--encryption-key=XXX` The encryption key (shocking, I know).
49
+ * `--encryption-key XXX` The encryption key (shocking, I know).
47
50
 
48
51
  In addition to these settings, your chosen adapter will probably also have additional adapter
49
52
  specific settings as well, such as credentials to log into your cloud storage account. Adapter
@@ -53,6 +56,33 @@ tries to do something weird).
53
56
 
54
57
  ## Creating your own adapter
55
58
 
56
- TODO
59
+ To create your own adapter to a cloud storage service, you'll need to do the following.
60
+
61
+ * Create a Ruby Gem named `cloud_encrypted_sync_*_adapter` where `*` is the name of your adapter.
62
+ It is recommended that you name your adapter after the cloud service that it interfaces to.
63
+ (eg. cloud_encrypted_sync_s3_adapter ). CES will not be able to find and load your adapter
64
+ unless it precisely matches this naming convention.
65
+ * Your gem needs to provide a class within the `CloudEncryptedSync::Adapters` namespace that
66
+ inherites from `Template`. The name of this class will determine the value that users pass with
67
+ `--adaper` on the command line to select your adapter. For instance, if you name your class
68
+ `MySuperDooperAdapter`, then users will need to pass `--adapter my_super_dooper_adapter` at the
69
+ command line to select your adapter.
70
+ * See the [Baseline](https://github.com/jsgarvin/cloud_encrypted_sync_baseline_adapter/blob/master/lib/baseline/adapter.rb)
71
+ class in [cloud_encrypted_sync_baseline_adapter](https://github.com/jsgarvin/cloud_encrypted_sync_baseline_adapter "Cloud Encrypted Sync Baseline Adapter")
72
+ for a list of methods that your adapter class needs to respond to, what arguments they need to
73
+ accept, and what values they're expected to return.
74
+
75
+ Note: [cloud_encrypted_sync_baseline_adapter](https://github.com/jsgarvin/cloud_encrypted_sync_baseline_adapter "Cloud Encrypted Sync Baseline Adapter")
76
+ is a forkable repository that should make the above steps easier. Simply fork it, rename it,
77
+ update it as necessary, and push it to rubygems.org.
78
+
79
+ ### Testing your adapter locally before publishing to rubygems.org
80
+
81
+ It is likely that, before publishing your new adapter to rubygems.org, you'll want to build and
82
+ install your gem locally to test it with CES. When you do this you'll also want to have the CES
83
+ gem itself built and installed locally, rather than installed from rubygems.org. It has been found
84
+ that when CES has been installed from rubygems.org, it is unable to find and load locally built
85
+ adapters, and visa-versa. The CES author is very interested in any patches that provide an elegant
86
+ solution to this annoyance.
57
87
 
58
88
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/jsgarvin/cloud_encrypted_sync)
@@ -73,7 +73,7 @@ module CloudEncryptedSync
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
- AdapterLiaison.instance.adapters[adapter_name.to_sym].parse_command_line_options(parser)
76
+ fetch_selected_adapter_or_raise(adapter_name).parse_command_line_options(parser)
77
77
  end
78
78
  parser.on('--encryption-key KEY') do |key|
79
79
  clo[:encryption_key] = key
@@ -84,6 +84,12 @@ module CloudEncryptedSync
84
84
  return clo
85
85
  end
86
86
 
87
+ def fetch_selected_adapter_or_raise(adapter_name)
88
+ if AdapterLiaison.instance.adapters[adapter_name.to_sym]
89
+ return AdapterLiaison.instance.adapters[adapter_name.to_sym]
90
+ end
91
+ raise Errors::IncompleteConfigurationError.new("Unrecognized adapter. Available choices are: #{AdapterLiaison.instance.adapters.keys.join(', ')}.")
92
+ end
87
93
  end
88
94
  end
89
95
  end
@@ -74,7 +74,7 @@ module CloudEncryptedSync
74
74
 
75
75
  def delete_remote_files
76
76
  remote_files_to_delete.each_pair do |key,path|
77
- puts "Deleting Remote: #{path}"
77
+ print "\nDeleting Remote: #{path}"
78
78
  liaison.delete(key)
79
79
  self.finalize_required = true
80
80
  end
@@ -84,9 +84,9 @@ module CloudEncryptedSync
84
84
  local_files_to_delete.each_pair do |key,relative_path|
85
85
  full_path = Index.full_file_path(relative_path)
86
86
  if !File.exist?(full_path)
87
- puts "Not Deleting Local: #{relative_path}"
87
+ print "\nNot Deleting Local: #{relative_path}"
88
88
  else
89
- puts "Deleting Local: #{relative_path}"
89
+ print "\nDeleting Local: #{relative_path}"
90
90
  File.delete(full_path)
91
91
  self.finalize_required = true
92
92
  end
@@ -1,3 +1,3 @@
1
1
  module CloudEncryptedSync
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -30,6 +30,11 @@ module CloudEncryptedSync
30
30
  assert_raise(Errors::IncompleteConfigurationError) { Configuration.settings }
31
31
  end
32
32
 
33
+ test 'should gracefully fail with invalid adapter provided' do
34
+ ::ARGV = '--adapter nonexistent --bucket foobar'.split(/\s/)
35
+ assert_raise(Errors::IncompleteConfigurationError) { Configuration.settings }
36
+ end
37
+
33
38
  test 'should create data folder if it does not exist' do
34
39
  ::ARGV = '--adapter dummy --bucket foobar --data-dir /test --encryption-key somestringofcharacters /some/path'.split(/\s/)
35
40
  assert ! File.exist?('/test')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_encrypted_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
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-21 00:00:00.000000000 Z
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mocha