strongspace 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +45 -0
- data/lib/strongspace/client.rb +20 -2
- data/lib/strongspace/command.rb +1 -1
- data/lib/strongspace/commands/base.rb +2 -0
- data/lib/strongspace/commands/files.rb +57 -0
- data/lib/strongspace/commands/help.rb +6 -3
- data/lib/strongspace/commands/spaces.rb +4 -4
- data/lib/strongspace/version.rb +1 -1
- metadata +6 -4
data/README.markdown
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
Strongspace Ruby Library and Command-line interface
|
2
|
+
===================================================
|
3
|
+
|
4
|
+
This is a Ruby library and command line interface to Strongspace online storage.
|
5
|
+
|
6
|
+
For more about Strongspace see <http://www.strongspace.com>.
|
7
|
+
|
8
|
+
For full documentation see <http://www.strongspace.com/help>.
|
9
|
+
|
10
|
+
|
11
|
+
Usage
|
12
|
+
-----
|
13
|
+
|
14
|
+
Install:
|
15
|
+
`gem install strongspace`
|
16
|
+
|
17
|
+
Run via command line:
|
18
|
+
`strongspace help`
|
19
|
+
|
20
|
+
=== General Commands
|
21
|
+
|
22
|
+
help # show this usage
|
23
|
+
version # show the gem version
|
24
|
+
|
25
|
+
keys # show your user's public keys
|
26
|
+
keys:add [<path to keyfile>] # add a public key
|
27
|
+
keys:remove <id> # remove a key by id
|
28
|
+
keys:clear # remove all keys
|
29
|
+
|
30
|
+
spaces # show your user's spaces
|
31
|
+
spaces:create <space_name> [type] # add a new space. type => (normal,public,backup)
|
32
|
+
spaces:destroy <space_name> [type] # remove a space by and destroy its data
|
33
|
+
spaces:snapshots <space_name> # show a space's snapshots
|
34
|
+
spaces:create_snapshot <space_name@snapshot_name> # take a space of a space.
|
35
|
+
spaces:destroy_snapshot <space_name@snapshot_name> # remove a snapshot from a space
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
Meta
|
41
|
+
-----
|
42
|
+
|
43
|
+
Many thanks to the Heroku team, whose fantastic Heroku gem provided the basis for this project.
|
44
|
+
|
45
|
+
Released under the [MIT license](http://www.opensource.org/licenses/mit-license.php).
|
data/lib/strongspace/client.rb
CHANGED
@@ -37,11 +37,29 @@ class Strongspace::Client
|
|
37
37
|
@host = host
|
38
38
|
end
|
39
39
|
|
40
|
+
# returns a tempfile to the loaded file
|
41
|
+
def download(path)
|
42
|
+
RestClient::Request.execute(:method => :get, :url => (@host + '/api/v1/files' + escape(path)), :user => @user, :password => @password, :raw_response => true, :headers => {:accept_encoding => ''}).file
|
43
|
+
end
|
44
|
+
|
45
|
+
def upload(file, dest_path)
|
46
|
+
r = resource(@host + '/api/v1/files/' + escape(dest_path[1..-1] + "/" + File.basename(file.path)))
|
47
|
+
r.post(:file => file)
|
48
|
+
end
|
49
|
+
|
50
|
+
def mkdir(path)
|
51
|
+
doc = post("/api/v1/files/#{escape(path[1..-1])}", :op => "mkdir")
|
52
|
+
end
|
53
|
+
|
54
|
+
def rm(path)
|
55
|
+
doc = delete("/api/v1/files/#{escape(path[1..-1])}")
|
56
|
+
end
|
57
|
+
|
40
58
|
def spaces
|
41
59
|
doc = JSON.parse get('/api/v1/spaces')
|
42
60
|
end
|
43
61
|
|
44
|
-
def
|
62
|
+
def delete_space(space_name)
|
45
63
|
doc = JSON.parse delete("/api/v1/spaces/#{escape(space_name)}").to_s
|
46
64
|
end
|
47
65
|
|
@@ -57,7 +75,7 @@ class Strongspace::Client
|
|
57
75
|
doc = JSON.parse get("/api/v1/spaces/#{escape(space_name)}/snapshots").to_s
|
58
76
|
end
|
59
77
|
|
60
|
-
def
|
78
|
+
def delete_snapshot(space_name, snapshot_name)
|
61
79
|
doc = JSON.parse delete("/api/v1/spaces/#{escape(space_name)}/snapshots/#{escape(snapshot_name)}").to_s
|
62
80
|
end
|
63
81
|
|
data/lib/strongspace/command.rb
CHANGED
@@ -52,7 +52,7 @@ module Strongspace
|
|
52
52
|
begin
|
53
53
|
return eval("Strongspace::Command::#{command.capitalize}"), :index
|
54
54
|
rescue NameError, NoMethodError
|
55
|
-
return Strongspace::Command::
|
55
|
+
return Strongspace::Command::Base, command.to_sym
|
56
56
|
end
|
57
57
|
else
|
58
58
|
begin
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'ftools'
|
2
|
+
|
3
|
+
module Strongspace::Command
|
4
|
+
class Download < Base
|
5
|
+
def index
|
6
|
+
path = Pathname.new(args.first)
|
7
|
+
display "Downloading #{path.basename}"
|
8
|
+
tempfile = strongspace.download(path.to_s)
|
9
|
+
File.move(tempfile.path, path.basename)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Upload < Base
|
14
|
+
def index
|
15
|
+
|
16
|
+
if args.length != 2
|
17
|
+
error "usage: strongspace upload <local file> </destination/path>"
|
18
|
+
end
|
19
|
+
|
20
|
+
if not File.exist?(args.first)
|
21
|
+
error "#{args.first} does not exist"
|
22
|
+
end
|
23
|
+
|
24
|
+
if not File.readable?(args.first)
|
25
|
+
error "You don't have permissions to read #{args.first}"
|
26
|
+
end
|
27
|
+
|
28
|
+
display "Uploading #{Pathname.new(args.first).basename} to #{args[1]}"
|
29
|
+
file = File.new(args.first, 'rb')
|
30
|
+
strongspace.upload(file, args[1])
|
31
|
+
display "Succesfully uploaded #{Pathname.new(args.first).basename}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Mkdir < Base
|
36
|
+
def index
|
37
|
+
if args.length != 1
|
38
|
+
error "please supply a remote path"
|
39
|
+
end
|
40
|
+
|
41
|
+
strongspace.mkdir(args[0])
|
42
|
+
display "Created #{args[0]}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Delete < Base
|
47
|
+
def index
|
48
|
+
if args.length != 1
|
49
|
+
error "please supply a remote path"
|
50
|
+
end
|
51
|
+
|
52
|
+
strongspace.rm(args[0])
|
53
|
+
display "Deleted #{args[0]}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -33,19 +33,22 @@ 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 <local_file> <remote_path>', 'upload a file'
|
37
|
+
group.command 'download <remote_path>', 'download a file from Strongspace to the current directory'
|
38
|
+
group.command 'mkdir <remote_path>', 'create a folder on Strongspace'
|
39
|
+
group.command 'delete <remote_path>', 'delete a file or recursively delete a folder on Strongspace'
|
36
40
|
group.space
|
37
41
|
group.command 'keys', 'show your user\'s public keys'
|
38
42
|
group.command 'keys:add [<path to keyfile>]', 'add a public key'
|
39
43
|
group.command 'keys:remove <id> ', 'remove a key by id'
|
40
44
|
group.command 'keys:clear', 'remove all keys'
|
41
45
|
group.space
|
42
|
-
group.space
|
43
46
|
group.command 'spaces', 'show your user\'s spaces'
|
44
47
|
group.command 'spaces:create <space_name> [type]', 'add a new space. type => (normal,public,backup)'
|
45
|
-
group.command 'spaces:
|
48
|
+
group.command 'spaces:delete <space_name> [type]', 'remove a space by and destroy its data'
|
46
49
|
group.command 'spaces:snapshots <space_name>', 'show a space\'s snapshots'
|
47
50
|
group.command 'spaces:create_snapshot <space_name@snapshot_name>', 'take a space of a space.'
|
48
|
-
group.command 'spaces:
|
51
|
+
group.command 'spaces:delete_snapshot <space_name@snapshot_name>', 'remove a snapshot from a space'
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
@@ -24,8 +24,8 @@ module Strongspace::Command
|
|
24
24
|
display "Create space #{name}"
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
strongspace.
|
27
|
+
def delete
|
28
|
+
strongspace.delete_space(args.first)
|
29
29
|
display "Space #{args.first} removed."
|
30
30
|
end
|
31
31
|
|
@@ -54,10 +54,10 @@ module Strongspace::Command
|
|
54
54
|
display "Created snapshot '#{args[0]}'"
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
57
|
+
def delete_snapshot
|
58
58
|
space_name, snapshot_name = args[0].split("@")
|
59
59
|
|
60
|
-
strongspace.
|
60
|
+
strongspace.delete_snapshot(space_name, snapshot_name)
|
61
61
|
display "Destroyed snapshot '#{args.first}'"
|
62
62
|
end
|
63
63
|
|
data/lib/strongspace/version.rb
CHANGED
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: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
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: 2010-12-
|
18
|
+
date: 2010-12-08 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/strongspace/command.rb
|
127
127
|
- lib/strongspace/commands/auth.rb
|
128
128
|
- lib/strongspace/commands/base.rb
|
129
|
+
- lib/strongspace/commands/files.rb
|
129
130
|
- lib/strongspace/commands/help.rb
|
130
131
|
- lib/strongspace/commands/keys.rb
|
131
132
|
- lib/strongspace/commands/spaces.rb
|
@@ -133,6 +134,7 @@ files:
|
|
133
134
|
- lib/strongspace/helpers.rb
|
134
135
|
- lib/strongspace/version.rb
|
135
136
|
- lib/strongspace.rb
|
137
|
+
- README.markdown
|
136
138
|
has_rdoc: true
|
137
139
|
homepage: http://github.com/expandrive/strongspace
|
138
140
|
licenses: []
|