rip 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +12 -0
- data/lib/rip.rb +1 -0
- data/lib/rip/commands.rb +1 -24
- data/lib/rip/commands/build.rb +1 -0
- data/lib/rip/commands/core.rb +9 -11
- data/lib/rip/commands/install.rb +3 -3
- data/lib/rip/env.rb +48 -10
- data/lib/rip/help.rb +49 -0
- data/lib/rip/packages/git_package.rb +1 -1
- data/lib/rip/setup.rb +2 -1
- data/lib/rip/version.rb +1 -1
- data/test/test_helper.rb +9 -2
- metadata +3 -2
data/README.markdown
CHANGED
@@ -293,6 +293,18 @@ Contributors
|
|
293
293
|
* [Blake Mizerany](http://github.com/bmizerany)
|
294
294
|
* [Ryan Tomayko](http://github.com/rtomayko)
|
295
295
|
* [Pat Nakajima](http://github.com/nakajima)
|
296
|
+
* Eero Saynatkari
|
297
|
+
* Coda Hale
|
298
|
+
* Simon Rozet
|
299
|
+
* Gabriel Horner
|
300
|
+
* Pistos
|
301
|
+
* Mark Turner
|
302
|
+
* Hongli Lai
|
303
|
+
* Tim Carey-Smith
|
304
|
+
* August Lilleaas
|
305
|
+
* Andre Arko
|
306
|
+
* Rick Olson
|
307
|
+
* Ben Burkert
|
296
308
|
|
297
309
|
Special Thanks
|
298
310
|
--------------
|
data/lib/rip.rb
CHANGED
data/lib/rip/commands.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Rip
|
2
2
|
module Commands
|
3
3
|
extend self
|
4
|
+
extend Help
|
4
5
|
|
5
6
|
def invoke(args)
|
6
7
|
command, options, args = parse_args(args)
|
@@ -41,30 +42,6 @@ module Rip
|
|
41
42
|
end
|
42
43
|
|
43
44
|
private
|
44
|
-
# tasty dsl for adding help text
|
45
|
-
|
46
|
-
def o(usage)
|
47
|
-
@usage ||= {}
|
48
|
-
@next_usage = usage
|
49
|
-
end
|
50
|
-
|
51
|
-
def x(help = '')
|
52
|
-
@help ||= {}
|
53
|
-
@next_help ||= []
|
54
|
-
@next_help.push help
|
55
|
-
end
|
56
|
-
|
57
|
-
def method_added(method)
|
58
|
-
@help[method.to_s] = @next_help if @next_help
|
59
|
-
@usage[method.to_s] = @next_usage if @next_usage
|
60
|
-
@next_help = nil
|
61
|
-
@next_usage = nil
|
62
|
-
end
|
63
|
-
|
64
|
-
def ui
|
65
|
-
Rip.ui
|
66
|
-
end
|
67
|
-
|
68
45
|
def manager(env = nil)
|
69
46
|
@manager ||= PackageManager.new(env)
|
70
47
|
end
|
data/lib/rip/commands/build.rb
CHANGED
data/lib/rip/commands/core.rb
CHANGED
@@ -28,13 +28,21 @@ module Rip
|
|
28
28
|
x 'Type rip env to see valid options.'
|
29
29
|
def env(options = {}, command = nil, *args)
|
30
30
|
if command && Rip::Env.commands.include?(command)
|
31
|
+
args.push(options)
|
31
32
|
ui.puts 'ripenv: ' + Rip::Env.call(command, *args).to_s
|
32
33
|
else
|
33
|
-
show_help :env
|
34
|
+
Rip::Env.show_help :env
|
34
35
|
ui.puts '', "current ripenv: #{Rip::Env.active}"
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
o 'rip use RIPENV'
|
40
|
+
x 'Activate a ripenv.'
|
41
|
+
x 'Shortcut for `rip env use`'
|
42
|
+
def use(options = {}, ripenv = nil, *args)
|
43
|
+
puts 'ripenv: ' + Rip::Env.use(ripenv.to_s)
|
44
|
+
end
|
45
|
+
|
38
46
|
x 'Outputs all installed libraries (and their versions) for the active env.'
|
39
47
|
x 'Can be saved as a .rip and installed by other rip users with:'
|
40
48
|
x ' rip install file.rip'
|
@@ -50,16 +58,6 @@ module Rip
|
|
50
58
|
end
|
51
59
|
|
52
60
|
private
|
53
|
-
def show_help(command, commands)
|
54
|
-
subcommand = command.to_s.empty? ? nil : "#{command} "
|
55
|
-
ui.puts "Usage: rip #{subcommand}COMMAND [options]", ""
|
56
|
-
ui.puts "Commands available:"
|
57
|
-
|
58
|
-
commands.each do |method|
|
59
|
-
ui.puts " #{method}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
61
|
def show_general_help
|
64
62
|
commands = public_instance_methods.reject do |method|
|
65
63
|
method =~ /-/ || %w( help version ).include?(method)
|
data/lib/rip/commands/install.rb
CHANGED
@@ -19,20 +19,20 @@ module Rip
|
|
19
19
|
end
|
20
20
|
|
21
21
|
package = Rip::Package.for(source, version)
|
22
|
+
installed_package = manager.package(package.name)
|
22
23
|
|
23
24
|
if !package
|
24
25
|
ui.abort "I don't know how to install #{source}"
|
25
26
|
end
|
26
27
|
|
27
|
-
if options[:f]
|
28
|
-
Installer.new.uninstall(
|
28
|
+
if options[:f] && installed_package
|
29
|
+
Installer.new.uninstall(installed_package) if installed_package.installed?
|
29
30
|
Installer.new.install(package)
|
30
31
|
elsif package.installed?
|
31
32
|
ui.puts "#{package} already installed"
|
32
33
|
else
|
33
34
|
installer = Installer.new
|
34
35
|
installer.install(package)
|
35
|
-
# puts "#{installer.installed.size.to_i} packages installed"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/rip/env.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module Rip
|
2
2
|
module Env
|
3
3
|
extend self
|
4
|
+
extend Help
|
4
5
|
PRIVATE_ENV = /^(rip-|active)/i
|
5
6
|
|
6
7
|
def commands
|
7
|
-
instance_methods - %w( call active_dir commands ui )
|
8
|
+
instance_methods - %w( call active_dir commands ui validate_ripenv )
|
8
9
|
end
|
9
10
|
|
11
|
+
x 'Create the SOURCE environment.'
|
10
12
|
def create(env)
|
11
13
|
dir = File.join(Rip.dir, env)
|
12
14
|
|
@@ -29,28 +31,26 @@ module Rip
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
34
|
+
x 'Activate the SOURCE environment.'
|
32
35
|
def use(env)
|
33
36
|
if env.strip.empty?
|
34
37
|
return "must give a ripenv to use"
|
35
38
|
end
|
36
39
|
|
37
|
-
if
|
38
|
-
return
|
39
|
-
end
|
40
|
-
|
41
|
-
if !File.exists?(target = File.join(Rip.dir, env))
|
42
|
-
return "#{env} doesn't exist"
|
40
|
+
if error = validate_ripenv(env)
|
41
|
+
return error
|
43
42
|
end
|
44
43
|
|
45
44
|
begin
|
46
45
|
FileUtils.rm active_dir
|
47
46
|
rescue Errno::ENOENT
|
48
47
|
end
|
49
|
-
FileUtils.ln_s(
|
48
|
+
FileUtils.ln_s(File.join(Rip.dir, env), active_dir)
|
50
49
|
|
51
50
|
"using #{env}"
|
52
51
|
end
|
53
52
|
|
53
|
+
x 'Remove the SOURCE environment.'
|
54
54
|
def delete(env)
|
55
55
|
if active == env
|
56
56
|
return "can't delete active environment"
|
@@ -72,7 +72,14 @@ module Rip
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
|
75
|
+
x 'Display all rip environments.'
|
76
|
+
def list(options = {})
|
77
|
+
# check if we got passed an env. kinda ghetto.
|
78
|
+
if options.is_a? String
|
79
|
+
target_env = options
|
80
|
+
options = {}
|
81
|
+
end
|
82
|
+
|
76
83
|
envs = Dir.glob(File.join(Rip.dir, '*')).map do |env|
|
77
84
|
env.split('/').last
|
78
85
|
end
|
@@ -81,16 +88,37 @@ module Rip
|
|
81
88
|
|
82
89
|
if envs.empty?
|
83
90
|
"none. make one with `rip env create <env>`"
|
91
|
+
elsif target_env
|
92
|
+
if error = validate_ripenv(target_env)
|
93
|
+
return error
|
94
|
+
end
|
95
|
+
|
96
|
+
manager = PackageManager.new(target_env)
|
97
|
+
output = [ target_env, "" ]
|
98
|
+
output += manager.packages
|
99
|
+
output.join("\n")
|
84
100
|
else
|
85
|
-
|
101
|
+
output = [ "all installed ripenvs", "" ]
|
102
|
+
output += envs.map do |env|
|
103
|
+
if options[:p]
|
104
|
+
packages = PackageManager.new(env).packages
|
105
|
+
packages = packages.size > 3 ? packages[0, 3] + ['...'] : packages
|
106
|
+
"#{env} - #{packages.join(', ')}"
|
107
|
+
else
|
108
|
+
env
|
109
|
+
end
|
110
|
+
end
|
111
|
+
output.join("\n")
|
86
112
|
end
|
87
113
|
end
|
88
114
|
|
115
|
+
x 'Display the name of the active environment.'
|
89
116
|
def active
|
90
117
|
active = File.readlink(active_dir)
|
91
118
|
active.split('/').last
|
92
119
|
end
|
93
120
|
|
121
|
+
x 'Clone the active environment.'
|
94
122
|
def copy(new)
|
95
123
|
if new.strip.empty?
|
96
124
|
return "must give a ripenv to copy to"
|
@@ -140,5 +168,15 @@ module Rip
|
|
140
168
|
def ui
|
141
169
|
Rip.ui
|
142
170
|
end
|
171
|
+
|
172
|
+
def validate_ripenv(env)
|
173
|
+
if env.strip =~ PRIVATE_ENV
|
174
|
+
return "invalid environment name"
|
175
|
+
end
|
176
|
+
|
177
|
+
if !File.exists?(File.join(Rip.dir, env))
|
178
|
+
return "#{env} doesn't exist"
|
179
|
+
end
|
180
|
+
end
|
143
181
|
end
|
144
182
|
end
|
data/lib/rip/help.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Rip
|
2
|
+
# tasty dsl for adding help text
|
3
|
+
module Help
|
4
|
+
|
5
|
+
def show_help(command, commands = commands)
|
6
|
+
subcommand = command.to_s.empty? ? nil : "#{command} "
|
7
|
+
ui.puts "Usage: rip #{subcommand}COMMAND [options]", ""
|
8
|
+
ui.puts "Commands available:"
|
9
|
+
|
10
|
+
show_command_table begin
|
11
|
+
commands.zip begin
|
12
|
+
commands.map { |c| @help[c].first unless @help[c].nil? }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def ui
|
19
|
+
Rip.ui
|
20
|
+
end
|
21
|
+
|
22
|
+
def o(usage)
|
23
|
+
@usage ||= {}
|
24
|
+
@next_usage = usage
|
25
|
+
end
|
26
|
+
|
27
|
+
def x(help = '')
|
28
|
+
@help ||= {}
|
29
|
+
@next_help ||= []
|
30
|
+
@next_help.push help
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_added(method)
|
34
|
+
@help[method.to_s] = @next_help if @next_help
|
35
|
+
@usage[method.to_s] = @next_usage if @next_usage
|
36
|
+
@next_help = nil
|
37
|
+
@next_usage = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def show_command_table(table)
|
41
|
+
offset = table.map {|a| a.first.size }.max + 2
|
42
|
+
offset += 1 unless offset % 2 == 0
|
43
|
+
|
44
|
+
table.each do |(command, help)|
|
45
|
+
ui.puts " #{command}" << ' ' * (offset - command.size) << help.to_s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/rip/setup.rb
CHANGED
@@ -100,6 +100,7 @@ module Rip
|
|
100
100
|
src = File.join(RIPROOT, 'bin', 'rip')
|
101
101
|
dst = File.join(BINDIR, 'rip')
|
102
102
|
FileUtils.cp src, dst, :verbose => verbose, :preserve => true
|
103
|
+
FileUtils.chmod(0755, dst)
|
103
104
|
|
104
105
|
ruby_bin = File.expand_path(File.join(BINDIR, RbConfig::CONFIG['ruby_install_name']))
|
105
106
|
if File.exist? ruby_bin
|
@@ -258,7 +259,7 @@ end_error
|
|
258
259
|
lines = File.readlines(file)[1..-1]
|
259
260
|
File.open(file, 'w') do |f|
|
260
261
|
f.puts first_line
|
261
|
-
f.puts lines.join
|
262
|
+
f.puts lines.join
|
262
263
|
f.flush
|
263
264
|
end
|
264
265
|
end
|
data/lib/rip/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -8,9 +8,16 @@ Rip.dir = File.expand_path(File.join(File.dirname(__FILE__), 'ripdir'))
|
|
8
8
|
Rip.ui = nil
|
9
9
|
|
10
10
|
require 'mock_git'
|
11
|
-
require 'fakefs'
|
12
11
|
require 'test/unit'
|
13
|
-
|
12
|
+
|
13
|
+
%w( fakefs test/spec/mini ).each do |dep|
|
14
|
+
begin
|
15
|
+
require dep
|
16
|
+
rescue LoadError => e
|
17
|
+
warn "*** run 'rip install test/dev.rip' before testing ***"
|
18
|
+
raise e
|
19
|
+
end
|
20
|
+
end
|
14
21
|
|
15
22
|
begin; require 'redgreen'; rescue LoadError; end
|
16
23
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-06 00:00:00 -07:00
|
13
13
|
default_executable: ""
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/rip/commands/setup.rb
|
40
40
|
- lib/rip/commands/uninstall.rb
|
41
41
|
- lib/rip/env.rb
|
42
|
+
- lib/rip/help.rb
|
42
43
|
- lib/rip/installer.rb
|
43
44
|
- lib/rip/memoize.rb
|
44
45
|
- lib/rip/package.rb
|