strongspace 0.0.9 → 0.1.1
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/README.markdown +28 -20
- data/bin/ss +14 -0
- data/lib/strongspace/command.rb +5 -0
- data/lib/strongspace/commands/help.rb +8 -8
- data/lib/strongspace/helpers.rb +30 -0
- data/lib/strongspace/version.rb +1 -1
- data/spec/base.rb +19 -0
- data/spec/client_spec.rb +23 -0
- metadata +93 -19
data/README.markdown
CHANGED
|
@@ -15,33 +15,41 @@ Install:
|
|
|
15
15
|
`gem install strongspace`
|
|
16
16
|
|
|
17
17
|
Run via command line:
|
|
18
|
-
`strongspace help`
|
|
18
|
+
`strongspace help` or `ss help`
|
|
19
19
|
|
|
20
20
|
=== General Commands
|
|
21
|
-
help
|
|
22
|
-
version
|
|
21
|
+
help # show this usage
|
|
22
|
+
version # show the gem version
|
|
23
23
|
|
|
24
|
-
upload <
|
|
25
|
-
download <remote_path>
|
|
26
|
-
mkdir <remote_path>
|
|
27
|
-
delete <remote_path>
|
|
24
|
+
upload <local_path> <remote_path> # upload a file
|
|
25
|
+
download <remote_path> # download a file from Strongspace to the current directory
|
|
26
|
+
mkdir <remote_path> # create a folder on Strongspace
|
|
27
|
+
delete <remote_path> # delete a file or recursively delete a folder on Strongspace
|
|
28
28
|
|
|
29
29
|
=== SSH Keys
|
|
30
|
-
keys
|
|
31
|
-
keys:add [<
|
|
32
|
-
keys:
|
|
33
|
-
keys:
|
|
30
|
+
keys # show your user's public keys
|
|
31
|
+
keys:add [<keyfile_path>] # Add an public key or generate a new SSH keypair and add
|
|
32
|
+
keys:generate # Generate a new SSH keypair
|
|
33
|
+
keys:remove <id> # remove a key by id
|
|
34
|
+
keys:clear # remove all keys
|
|
34
35
|
|
|
35
36
|
=== Spaces
|
|
36
|
-
spaces
|
|
37
|
-
spaces:create <
|
|
38
|
-
spaces:delete <
|
|
39
|
-
spaces:snapshots <
|
|
40
|
-
spaces:create_snapshot <
|
|
41
|
-
spaces:delete_snapshot <
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
spaces # show your user's spaces
|
|
38
|
+
spaces:create <name> [type] # add a new space. type => (normal,public,backup)
|
|
39
|
+
spaces:delete <name> [type] # remove a space by and destroy its data
|
|
40
|
+
spaces:snapshots <name> # show a space's snapshots
|
|
41
|
+
spaces:create_snapshot <name@snapshot_name> # take a space of a space.
|
|
42
|
+
spaces:delete_snapshot <name@snapshot_name> # remove a snapshot from a space
|
|
43
|
+
|
|
44
|
+
=== Plugins
|
|
45
|
+
plugins # list installed plugins
|
|
46
|
+
plugins:install <url> # install the plugin from the specified git url
|
|
47
|
+
plugins:uninstall <url/name> # remove the specified plugin
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Plugins
|
|
51
|
+
------
|
|
52
|
+
Check out our sample [Rsync Plugin](https://github.com/expandrive/strongspace-rsync) as an example of how to add functionality
|
|
45
53
|
|
|
46
54
|
|
|
47
55
|
Meta
|
data/bin/ss
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
|
4
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
|
5
|
+
|
|
6
|
+
require 'strongspace'
|
|
7
|
+
require 'strongspace/command'
|
|
8
|
+
|
|
9
|
+
args = ARGV.dup
|
|
10
|
+
ARGV.clear
|
|
11
|
+
command = args.shift.strip rescue 'help'
|
|
12
|
+
|
|
13
|
+
Strongspace::Command.run(command, args)
|
|
14
|
+
|
data/lib/strongspace/command.rb
CHANGED
|
@@ -16,6 +16,11 @@ module Strongspace
|
|
|
16
16
|
def run(command, args, retries=0)
|
|
17
17
|
Strongspace::Plugin.load!
|
|
18
18
|
begin
|
|
19
|
+
# internal-only commands cannot be be run from the command line
|
|
20
|
+
if command.index(":_")
|
|
21
|
+
raise InvalidCommand
|
|
22
|
+
end
|
|
23
|
+
|
|
19
24
|
run_internal 'auth:reauthorize', args.dup if retries > 0
|
|
20
25
|
run_internal(command, args.dup)
|
|
21
26
|
rescue InvalidCommand
|
|
@@ -33,7 +33,7 @@ module Strongspace::Command
|
|
|
33
33
|
group.command 'help', 'show this usage'
|
|
34
34
|
group.command 'version', 'show the gem version'
|
|
35
35
|
group.space
|
|
36
|
-
group.command 'upload <
|
|
36
|
+
group.command 'upload <local_path> <remote_path>', 'upload a file'
|
|
37
37
|
group.command 'download <remote_path>', 'download a file from Strongspace to the current directory'
|
|
38
38
|
group.command 'mkdir <remote_path>', 'create a folder on Strongspace'
|
|
39
39
|
group.command 'delete <remote_path>', 'delete a file or recursively delete a folder on Strongspace'
|
|
@@ -43,10 +43,10 @@ module Strongspace::Command
|
|
|
43
43
|
group.command 'keys', 'show your user\'s public keys'
|
|
44
44
|
|
|
45
45
|
if not RUBY_PLATFORM =~ /mswin32|mingw32/
|
|
46
|
-
group.command 'keys:add [<
|
|
46
|
+
group.command 'keys:add [<keyfile_path>]', 'Add an public key or generate a new SSH keypair and add'
|
|
47
47
|
group.command 'keys:generate', 'Generate a new SSH keypair'
|
|
48
48
|
else
|
|
49
|
-
group.command 'keys:add [<
|
|
49
|
+
group.command 'keys:add [<keyfile_path>]', 'Add an public key'
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
group.command 'keys:remove <id> ', 'remove a key by id'
|
|
@@ -55,11 +55,11 @@ module Strongspace::Command
|
|
|
55
55
|
|
|
56
56
|
group 'Spaces' do |group|
|
|
57
57
|
group.command 'spaces', 'show your user\'s spaces'
|
|
58
|
-
group.command 'spaces:create <
|
|
59
|
-
group.command 'spaces:delete <
|
|
60
|
-
group.command 'spaces:snapshots <
|
|
61
|
-
group.command 'spaces:create_snapshot <
|
|
62
|
-
group.command 'spaces:delete_snapshot <
|
|
58
|
+
group.command 'spaces:create <name> [type]', 'add a new space. type => (normal,public,backup)'
|
|
59
|
+
group.command 'spaces:delete <name> [type]', 'remove a space by and destroy its data'
|
|
60
|
+
group.command 'spaces:snapshots <name>', 'show a space\'s snapshots'
|
|
61
|
+
group.command 'spaces:create_snapshot <name@snapshot_name>', 'take a space of a space.'
|
|
62
|
+
group.command 'spaces:delete_snapshot <name@snapshot_name>', 'remove a snapshot from a space'
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
group 'Plugins' do |group|
|
data/lib/strongspace/helpers.rb
CHANGED
|
@@ -163,6 +163,36 @@ module Strongspace
|
|
|
163
163
|
def shell(cmd)
|
|
164
164
|
FileUtils.cd(Dir.pwd) {|d| return `#{cmd}`}
|
|
165
165
|
end
|
|
166
|
+
|
|
167
|
+
def space_exist?(name)
|
|
168
|
+
strongspace.spaces["spaces"].each do |space|
|
|
169
|
+
# TODO: clean up the json returned by the strongspace API requests to simplify this iteration
|
|
170
|
+
space = space["space"]
|
|
171
|
+
return true if space["name"] == name
|
|
172
|
+
end
|
|
173
|
+
return false
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def valid_space_name?(name)
|
|
177
|
+
# For now, just make sure the space name is all "word characters," i.e. [0-9A-Za-z_]
|
|
178
|
+
return false if name =~ /\W/
|
|
179
|
+
return true
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def backup_space?(name)
|
|
183
|
+
space = nil
|
|
184
|
+
strongspace.spaces["spaces"].each do |s|
|
|
185
|
+
s = s["space"]
|
|
186
|
+
if s["name"] == name then
|
|
187
|
+
space = s
|
|
188
|
+
break
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
return space["type"] == "backup"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
166
196
|
end
|
|
167
197
|
end
|
|
168
198
|
|
data/lib/strongspace/version.rb
CHANGED
data/spec/base.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
|
|
3
|
+
# ruby 1.9.2 drops . from the load path
|
|
4
|
+
$:.unshift File.expand_path("../..", __FILE__)
|
|
5
|
+
|
|
6
|
+
require 'spec'
|
|
7
|
+
require 'fileutils'
|
|
8
|
+
require 'tmpdir'
|
|
9
|
+
require 'webmock/rspec'
|
|
10
|
+
|
|
11
|
+
require 'strongspace/command'
|
|
12
|
+
require 'strongspace/commands/base'
|
|
13
|
+
Dir["#{File.dirname(__FILE__)}/../lib/strongspace/commands/*"].each { |c| require c }
|
|
14
|
+
|
|
15
|
+
include WebMock::API
|
|
16
|
+
|
|
17
|
+
def stub_api_request(method, path)
|
|
18
|
+
stub_request(method, "https://www.strongspace.com/api/v1#{path}")
|
|
19
|
+
end
|
data/spec/client_spec.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path("./base", File.dirname(__FILE__))
|
|
2
|
+
require "cgi"
|
|
3
|
+
require "strongspace/client"
|
|
4
|
+
|
|
5
|
+
describe Strongspace::Client do
|
|
6
|
+
before do
|
|
7
|
+
@client = Strongspace::Client.new(nil, nil)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "Client.auth -> get user details" do
|
|
11
|
+
api_token = { "api_key" => "abc" }
|
|
12
|
+
stub_request(:get, "https://foo:bar@www.strongspace.com/api/v1/api_token").to_return(:body => api_token.to_json)
|
|
13
|
+
Strongspace::Client.auth("foo", "bar").should == api_token
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "list -> get a list of this user's apps" do
|
|
17
|
+
stub_api_request(:get, "/spaces").to_return(:body => <<-EOJSON)
|
|
18
|
+
{"spaces":[{"space":{"name":"a space", "snapshots":0, "type":"normal"}}, {"space":{"name":"diskimages", "snapshots":0, "type":"normal"}}]}
|
|
19
|
+
EOJSON
|
|
20
|
+
@client.spaces.should == {"spaces"=>[{"space"=>{"name"=>"a space", "snapshots"=>0, "type"=>"normal"}}, {"space"=>{"name"=>"diskimages", "snapshots"=>0, "type"=>"normal"}}]}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strongspace
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 25
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
version: 0.
|
|
8
|
+
- 1
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.1.1
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Strongspace
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
18
|
+
date: 2011-01-11 00:00:00 -05:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -33,9 +33,51 @@ dependencies:
|
|
|
33
33
|
type: :development
|
|
34
34
|
version_requirements: *id001
|
|
35
35
|
- !ruby/object:Gem::Dependency
|
|
36
|
-
name:
|
|
36
|
+
name: ZenTest
|
|
37
37
|
prerelease: false
|
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
hash: 3
|
|
44
|
+
segments:
|
|
45
|
+
- 0
|
|
46
|
+
version: "0"
|
|
47
|
+
type: :development
|
|
48
|
+
version_requirements: *id002
|
|
49
|
+
- !ruby/object:Gem::Dependency
|
|
50
|
+
name: autotest-growl
|
|
51
|
+
prerelease: false
|
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
53
|
+
none: false
|
|
54
|
+
requirements:
|
|
55
|
+
- - ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
hash: 3
|
|
58
|
+
segments:
|
|
59
|
+
- 0
|
|
60
|
+
version: "0"
|
|
61
|
+
type: :development
|
|
62
|
+
version_requirements: *id003
|
|
63
|
+
- !ruby/object:Gem::Dependency
|
|
64
|
+
name: autotest-fsevent
|
|
65
|
+
prerelease: false
|
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
67
|
+
none: false
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
hash: 3
|
|
72
|
+
segments:
|
|
73
|
+
- 0
|
|
74
|
+
version: "0"
|
|
75
|
+
type: :development
|
|
76
|
+
version_requirements: *id004
|
|
77
|
+
- !ruby/object:Gem::Dependency
|
|
78
|
+
name: rspec
|
|
79
|
+
prerelease: false
|
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
39
81
|
none: false
|
|
40
82
|
requirements:
|
|
41
83
|
- - ~>
|
|
@@ -47,11 +89,11 @@ dependencies:
|
|
|
47
89
|
- 0
|
|
48
90
|
version: 1.3.0
|
|
49
91
|
type: :development
|
|
50
|
-
version_requirements: *
|
|
92
|
+
version_requirements: *id005
|
|
51
93
|
- !ruby/object:Gem::Dependency
|
|
52
94
|
name: taps
|
|
53
95
|
prerelease: false
|
|
54
|
-
requirement: &
|
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
55
97
|
none: false
|
|
56
98
|
requirements:
|
|
57
99
|
- - ~>
|
|
@@ -63,11 +105,11 @@ dependencies:
|
|
|
63
105
|
- 11
|
|
64
106
|
version: 0.3.11
|
|
65
107
|
type: :development
|
|
66
|
-
version_requirements: *
|
|
108
|
+
version_requirements: *id006
|
|
67
109
|
- !ruby/object:Gem::Dependency
|
|
68
110
|
name: webmock
|
|
69
111
|
prerelease: false
|
|
70
|
-
requirement: &
|
|
112
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
71
113
|
none: false
|
|
72
114
|
requirements:
|
|
73
115
|
- - ~>
|
|
@@ -79,11 +121,11 @@ dependencies:
|
|
|
79
121
|
- 0
|
|
80
122
|
version: 1.5.0
|
|
81
123
|
type: :development
|
|
82
|
-
version_requirements: *
|
|
124
|
+
version_requirements: *id007
|
|
83
125
|
- !ruby/object:Gem::Dependency
|
|
84
126
|
name: open4
|
|
85
127
|
prerelease: false
|
|
86
|
-
requirement: &
|
|
128
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
|
87
129
|
none: false
|
|
88
130
|
requirements:
|
|
89
131
|
- - ">="
|
|
@@ -93,11 +135,11 @@ dependencies:
|
|
|
93
135
|
- 0
|
|
94
136
|
version: "0"
|
|
95
137
|
type: :development
|
|
96
|
-
version_requirements: *
|
|
138
|
+
version_requirements: *id008
|
|
97
139
|
- !ruby/object:Gem::Dependency
|
|
98
140
|
name: ruby-fsevent
|
|
99
141
|
prerelease: false
|
|
100
|
-
requirement: &
|
|
142
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
|
101
143
|
none: false
|
|
102
144
|
requirements:
|
|
103
145
|
- - ">="
|
|
@@ -107,11 +149,39 @@ dependencies:
|
|
|
107
149
|
- 0
|
|
108
150
|
version: "0"
|
|
109
151
|
type: :development
|
|
110
|
-
version_requirements: *
|
|
152
|
+
version_requirements: *id009
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: open4
|
|
155
|
+
prerelease: false
|
|
156
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
|
157
|
+
none: false
|
|
158
|
+
requirements:
|
|
159
|
+
- - ">="
|
|
160
|
+
- !ruby/object:Gem::Version
|
|
161
|
+
hash: 3
|
|
162
|
+
segments:
|
|
163
|
+
- 0
|
|
164
|
+
version: "0"
|
|
165
|
+
type: :runtime
|
|
166
|
+
version_requirements: *id010
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: cronedit
|
|
169
|
+
prerelease: false
|
|
170
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
|
171
|
+
none: false
|
|
172
|
+
requirements:
|
|
173
|
+
- - ">="
|
|
174
|
+
- !ruby/object:Gem::Version
|
|
175
|
+
hash: 3
|
|
176
|
+
segments:
|
|
177
|
+
- 0
|
|
178
|
+
version: "0"
|
|
179
|
+
type: :runtime
|
|
180
|
+
version_requirements: *id011
|
|
111
181
|
- !ruby/object:Gem::Dependency
|
|
112
182
|
name: rest-client
|
|
113
183
|
prerelease: false
|
|
114
|
-
requirement: &
|
|
184
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
|
115
185
|
none: false
|
|
116
186
|
requirements:
|
|
117
187
|
- - <
|
|
@@ -123,11 +193,11 @@ dependencies:
|
|
|
123
193
|
- 0
|
|
124
194
|
version: 1.7.0
|
|
125
195
|
type: :runtime
|
|
126
|
-
version_requirements: *
|
|
196
|
+
version_requirements: *id012
|
|
127
197
|
- !ruby/object:Gem::Dependency
|
|
128
198
|
name: json_pure
|
|
129
199
|
prerelease: false
|
|
130
|
-
requirement: &
|
|
200
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
|
131
201
|
none: false
|
|
132
202
|
requirements:
|
|
133
203
|
- - <
|
|
@@ -139,16 +209,18 @@ dependencies:
|
|
|
139
209
|
- 0
|
|
140
210
|
version: 1.5.0
|
|
141
211
|
type: :runtime
|
|
142
|
-
version_requirements: *
|
|
212
|
+
version_requirements: *id013
|
|
143
213
|
description: Client library and command line tool for Strongspace.
|
|
144
214
|
email: support@strongspace.com
|
|
145
215
|
executables:
|
|
146
216
|
- strongspace
|
|
217
|
+
- ss
|
|
147
218
|
extensions: []
|
|
148
219
|
|
|
149
220
|
extra_rdoc_files: []
|
|
150
221
|
|
|
151
222
|
files:
|
|
223
|
+
- bin/ss
|
|
152
224
|
- bin/strongspace
|
|
153
225
|
- lib/strongspace/client.rb
|
|
154
226
|
- lib/strongspace/command.rb
|
|
@@ -166,6 +238,8 @@ files:
|
|
|
166
238
|
- lib/strongspace/version.rb
|
|
167
239
|
- lib/strongspace.rb
|
|
168
240
|
- README.markdown
|
|
241
|
+
- spec/base.rb
|
|
242
|
+
- spec/client_spec.rb
|
|
169
243
|
has_rdoc: true
|
|
170
244
|
homepage: http://github.com/expandrive/strongspace
|
|
171
245
|
licenses: []
|