strongspace 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -18,21 +18,28 @@ Run via command line:
18
18
  `strongspace help`
19
19
 
20
20
  === General Commands
21
+ help # show this usage
22
+ version # show the gem version
23
+
24
+ upload <local_file> <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
+
29
+ === SSH Keys
30
+ keys # show your user's public keys
31
+ keys:add [<path to keyfile>] # add a public key
32
+ keys:remove <id> # remove a key by id
33
+ keys:clear # remove all keys
34
+
35
+ === Spaces
36
+ spaces # show your user's spaces
37
+ spaces:create <space_name> [type] # add a new space. type => (normal,public,backup)
38
+ spaces:delete <space_name> [type] # remove a space by and destroy its data
39
+ spaces:snapshots <space_name> # show a space's snapshots
40
+ spaces:create_snapshot <space_name@snapshot_name> # take a space of a space.
41
+ spaces:delete_snapshot <space_name@snapshot_name> # remove a snapshot from a space
21
42
 
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
43
 
37
44
 
38
45
 
@@ -1,4 +1,5 @@
1
1
  require 'strongspace/helpers'
2
+ require 'strongspace/plugin'
2
3
  require 'strongspace/commands/base'
3
4
 
4
5
  Dir["#{File.dirname(__FILE__)}/commands/*.rb"].each { |c| require c }
@@ -13,6 +14,7 @@ module Strongspace
13
14
  class << self
14
15
 
15
16
  def run(command, args, retries=0)
17
+ Strongspace::Plugin.load!
16
18
  begin
17
19
  run_internal 'auth:reauthorize', args.dup if retries > 0
18
20
  run_internal(command, args.dup)
@@ -50,7 +52,7 @@ module Strongspace
50
52
  case parts.size
51
53
  when 1
52
54
  begin
53
- return eval("Strongspace::Command::#{command.capitalize}"), :index
55
+ return eval("Strongspace::Command::#{command.camelize}"), :index
54
56
  rescue NameError, NoMethodError
55
57
  return Strongspace::Command::Base, command.to_sym
56
58
  end
@@ -1,8 +1,12 @@
1
1
  require 'fileutils'
2
+ require 'strongspace/plugin_interface'
3
+
2
4
 
3
5
  module Strongspace::Command
4
6
  class Base
5
7
  include Strongspace::Helpers
8
+ include Strongspace::PluginInterface
9
+
6
10
  attr_accessor :args
7
11
  def initialize(args, strongspace=nil)
8
12
  @args = args
@@ -37,12 +37,16 @@ module Strongspace::Command
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'
40
- group.space
40
+ end
41
+
42
+ group 'SSH Keys' do |group|
41
43
  group.command 'keys', 'show your user\'s public keys'
42
44
  group.command 'keys:add [<path to keyfile>]', 'add a public key'
43
45
  group.command 'keys:remove <id> ', 'remove a key by id'
44
46
  group.command 'keys:clear', 'remove all keys'
45
- group.space
47
+ end
48
+
49
+ group 'Spaces' do |group|
46
50
  group.command 'spaces', 'show your user\'s spaces'
47
51
  group.command 'spaces:create <space_name> [type]', 'add a new space. type => (normal,public,backup)'
48
52
  group.command 'spaces:delete <space_name> [type]', 'remove a space by and destroy its data'
@@ -50,8 +54,17 @@ module Strongspace::Command
50
54
  group.command 'spaces:create_snapshot <space_name@snapshot_name>', 'take a space of a space.'
51
55
  group.command 'spaces:delete_snapshot <space_name@snapshot_name>', 'remove a snapshot from a space'
52
56
  end
57
+
58
+ group 'Plugins' do |group|
59
+ group.command 'plugins', 'list installed plugins'
60
+ group.command 'plugins:install <url>', 'install the plugin from the specified git url'
61
+ group.command 'plugins:uninstall <url/name>', 'remove the specified plugin'
62
+ end
63
+
53
64
  end
54
65
 
66
+
67
+
55
68
  def index
56
69
  display usage
57
70
  end
@@ -67,7 +80,6 @@ module Strongspace::Command
67
80
 
68
81
  self.class.groups.inject(StringIO.new) do |output, group|
69
82
  output.puts "=== %s" % group.title
70
- output.puts
71
83
 
72
84
  group.each do |command, description|
73
85
  if command.empty?
@@ -0,0 +1,39 @@
1
+ module Strongspace::Command
2
+ class Plugins < Base
3
+ def list
4
+ ::Strongspace::Plugin.list.each do |plugin|
5
+ display plugin
6
+ end
7
+ end
8
+ alias :index :list
9
+
10
+ def install
11
+ plugin = Strongspace::Plugin.new(args.shift)
12
+ if plugin.install
13
+ begin
14
+ Strongspace::Plugin.load_plugin(plugin.name)
15
+ rescue Exception => ex
16
+ installation_failed(plugin, ex.message)
17
+ end
18
+ display "#{plugin} installed"
19
+ else
20
+ error "Could not install #{plugin}. Please check the URL and try again"
21
+ end
22
+ end
23
+
24
+ def uninstall
25
+ plugin = Strongspace::Plugin.new(args.shift)
26
+ plugin.uninstall
27
+ display "#{plugin} uninstalled"
28
+ end
29
+
30
+ protected
31
+
32
+ def installation_failed(plugin, message)
33
+ plugin.uninstall
34
+ error <<-ERROR
35
+ Could not initialize #{plugin}: #{message}
36
+ ERROR
37
+ end
38
+ end
39
+ end
@@ -84,3 +84,11 @@ unless String.method_defined?(:shellescape)
84
84
  end
85
85
  end
86
86
  end
87
+
88
+ unless String.method_defined?(:camelize)
89
+ class String
90
+ def camelize
91
+ self.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,78 @@
1
+ # based on the Rails Plugin
2
+
3
+ module Strongspace
4
+ class Plugin
5
+ class << self
6
+ include Strongspace::Helpers
7
+ end
8
+
9
+ attr_reader :name, :uri
10
+
11
+ def self.directory
12
+ File.expand_path("#{home_directory}/.strongspace/plugins")
13
+ end
14
+
15
+ def self.list
16
+ Dir["#{directory}/*"].sort.map do |folder|
17
+ File.basename(folder)
18
+ end
19
+ end
20
+
21
+ def self.load!
22
+ list.each do |plugin|
23
+ begin
24
+ load_plugin(plugin)
25
+ rescue Exception => e
26
+ display "Unable to load plugin: #{plugin}: #{e.message}"
27
+ end
28
+ end
29
+ end
30
+
31
+ def self.load_plugin(plugin)
32
+ folder = "#{self.directory}/#{plugin}"
33
+ $: << "#{folder}/lib" if File.directory? "#{folder}/lib"
34
+ load "#{folder}/init.rb" if File.exists? "#{folder}/init.rb"
35
+ end
36
+
37
+ def self.remove_plugin(plugin)
38
+ FileUtils.rm_rf("#{self.directory}/#{plugin}")
39
+ end
40
+
41
+
42
+ def initialize(uri)
43
+ @uri = uri
44
+ guess_name(uri)
45
+ end
46
+
47
+ def to_s
48
+ name
49
+ end
50
+
51
+ def path
52
+ "#{self.class.directory}/#{name}"
53
+ end
54
+
55
+ def install
56
+ FileUtils.mkdir_p(path)
57
+ Dir.chdir(path) do
58
+ system("git init -q")
59
+ if !system("git pull #{uri} master -q")
60
+ FileUtils.rm_rf path
61
+ return false
62
+ end
63
+ end
64
+ true
65
+ end
66
+
67
+ def uninstall
68
+ FileUtils.rm_r path if File.directory?(path)
69
+ end
70
+
71
+ private
72
+ def guess_name(url)
73
+ @name = File.basename(url)
74
+ @name = File.basename(File.dirname(url)) if @name.empty?
75
+ @name.gsub!(/\.git$/, '') if @name =~ /\.git$/
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,15 @@
1
+ module Strongspace::PluginInterface
2
+
3
+ def self.included(base)
4
+ base.extend Strongspace::PluginInterface
5
+ end
6
+
7
+ def command(command, *args)
8
+ Strongspace::Command.run_internal command.to_s, args
9
+ end
10
+
11
+ def base_command
12
+ @base_command ||= Strongspace::Command::Base.new(ARGV)
13
+ end
14
+
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Strongspace
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongspace
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 6
9
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
10
11
  platform: ruby
11
12
  authors:
12
13
  - Strongspace
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-12-08 00:00:00 -05:00
18
+ date: 2010-12-12 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 3
28
30
  segments:
29
31
  - 0
30
32
  version: "0"
@@ -38,6 +40,7 @@ dependencies:
38
40
  requirements:
39
41
  - - ~>
40
42
  - !ruby/object:Gem::Version
43
+ hash: 27
41
44
  segments:
42
45
  - 1
43
46
  - 3
@@ -53,6 +56,7 @@ dependencies:
53
56
  requirements:
54
57
  - - ~>
55
58
  - !ruby/object:Gem::Version
59
+ hash: 5
56
60
  segments:
57
61
  - 0
58
62
  - 3
@@ -68,6 +72,7 @@ dependencies:
68
72
  requirements:
69
73
  - - ~>
70
74
  - !ruby/object:Gem::Version
75
+ hash: 3
71
76
  segments:
72
77
  - 1
73
78
  - 5
@@ -83,6 +88,7 @@ dependencies:
83
88
  requirements:
84
89
  - - <
85
90
  - !ruby/object:Gem::Version
91
+ hash: 11
86
92
  segments:
87
93
  - 1
88
94
  - 7
@@ -98,6 +104,7 @@ dependencies:
98
104
  requirements:
99
105
  - - <
100
106
  - !ruby/object:Gem::Version
107
+ hash: 3
101
108
  segments:
102
109
  - 1
103
110
  - 5
@@ -122,9 +129,12 @@ files:
122
129
  - lib/strongspace/commands/files.rb
123
130
  - lib/strongspace/commands/help.rb
124
131
  - lib/strongspace/commands/keys.rb
132
+ - lib/strongspace/commands/plugins.rb
125
133
  - lib/strongspace/commands/spaces.rb
126
134
  - lib/strongspace/commands/version.rb
127
135
  - lib/strongspace/helpers.rb
136
+ - lib/strongspace/plugin.rb
137
+ - lib/strongspace/plugin_interface.rb
128
138
  - lib/strongspace/version.rb
129
139
  - lib/strongspace.rb
130
140
  - README.markdown
@@ -142,6 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
152
  requirements:
143
153
  - - ">="
144
154
  - !ruby/object:Gem::Version
155
+ hash: 3
145
156
  segments:
146
157
  - 0
147
158
  version: "0"
@@ -150,6 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
161
  requirements:
151
162
  - - ">="
152
163
  - !ruby/object:Gem::Version
164
+ hash: 3
153
165
  segments:
154
166
  - 0
155
167
  version: "0"