fnando-renv 0.0.1 → 0.0.2
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 +12 -7
- data/Rakefile +0 -1
- data/bin/renv +48 -7
- data/lib/renv/color.rb +71 -0
- data/lib/renv/env.rb +50 -16
- data/lib/renv/gem.rb +8 -9
- data/lib/renv.rb +12 -2
- data/renv.gemspec +2 -2
- metadata +2 -11
data/README.markdown
CHANGED
@@ -16,8 +16,8 @@ Or
|
|
16
16
|
Then put this on your `~/.bash_profile`:
|
17
17
|
|
18
18
|
export RENVDIR="$HOME/.renv"
|
19
|
-
export PATH="$
|
20
|
-
export
|
19
|
+
export PATH="$RENVDIR/active/bin:$PATH"
|
20
|
+
export GEM_PATH="$RENVDIR/active/lib"
|
21
21
|
|
22
22
|
Reload your profile with `source ~/.bash_profile`.
|
23
23
|
|
@@ -29,6 +29,9 @@ Here's the supported commands
|
|
29
29
|
renv install json -v 1.1.3
|
30
30
|
#=> install json 1.1.3
|
31
31
|
|
32
|
+
renv install "twitter4r xmpp4r"
|
33
|
+
#=> install multiple gems
|
34
|
+
|
32
35
|
renv uninstall json
|
33
36
|
#=> uninstall json
|
34
37
|
|
@@ -46,17 +49,19 @@ Here's the supported commands
|
|
46
49
|
|
47
50
|
renv gems
|
48
51
|
#=> list all installed gems in the current environment
|
49
|
-
|
52
|
+
|
50
53
|
To get all available commands, run `renv help`.
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
Renv outputs colored strings; to disable it add the following to your `~/.bash_profile`:
|
56
|
+
|
57
|
+
export RENV_NOCOLOR=1
|
58
|
+
|
59
|
+
**Note:** This gem was built before Rip 0.0.2 that handles compiled gems.
|
55
60
|
|
56
61
|
MAINTAINER
|
57
62
|
----------
|
58
63
|
|
59
|
-
* Nando Vieira (
|
64
|
+
* Nando Vieira (<http://simplesideias.com.br>)
|
60
65
|
|
61
66
|
LICENSE:
|
62
67
|
--------
|
data/Rakefile
CHANGED
data/bin/renv
CHANGED
@@ -10,6 +10,8 @@ Main {
|
|
10
10
|
|
11
11
|
VERSION: #{Renv::VERSION}
|
12
12
|
|
13
|
+
CURRENT ENV: #{Renv::Color.yellow(Renv.env, :options => [:underscore])}
|
14
|
+
|
13
15
|
USAGE: renv help [command]
|
14
16
|
TXT
|
15
17
|
|
@@ -32,7 +34,7 @@ Main {
|
|
32
34
|
|
33
35
|
mode(:clone) {
|
34
36
|
description <<-TXT
|
35
|
-
Clone
|
37
|
+
Clone an existing environment
|
36
38
|
TXT
|
37
39
|
|
38
40
|
examples <<-TXT
|
@@ -60,7 +62,21 @@ Main {
|
|
60
62
|
* renv list
|
61
63
|
TXT
|
62
64
|
|
63
|
-
run {
|
65
|
+
run {
|
66
|
+
Renv::Env.list
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
mode(:disable) {
|
71
|
+
description <<-TXT
|
72
|
+
Disable all environments
|
73
|
+
TXT
|
74
|
+
|
75
|
+
examples <<-TXT
|
76
|
+
* renv disable
|
77
|
+
TXT
|
78
|
+
|
79
|
+
run { Renv::Env.disable }
|
64
80
|
}
|
65
81
|
|
66
82
|
mode(:env) {
|
@@ -73,20 +89,30 @@ Main {
|
|
73
89
|
TXT
|
74
90
|
|
75
91
|
run {
|
76
|
-
|
92
|
+
Renv.puts_current_environment
|
77
93
|
}
|
78
94
|
}
|
79
95
|
|
80
96
|
mode(:gems) {
|
81
97
|
description <<-TXT
|
82
|
-
List all
|
98
|
+
List all installed gems
|
83
99
|
TXT
|
84
100
|
|
85
101
|
examples <<-TXT
|
86
102
|
* renv gems
|
87
103
|
TXT
|
88
104
|
|
89
|
-
run {
|
105
|
+
run {
|
106
|
+
gems = Renv::Gem.list
|
107
|
+
|
108
|
+
Renv.puts_current_environment
|
109
|
+
|
110
|
+
if gems.empty?
|
111
|
+
Renv.puts "\nno gems installed", :color => :yellow, :bgcolor => :black
|
112
|
+
else
|
113
|
+
Renv.puts "\n" + gems.join("\n")
|
114
|
+
end
|
115
|
+
}
|
90
116
|
}
|
91
117
|
|
92
118
|
mode(:delete) {
|
@@ -113,6 +139,8 @@ Main {
|
|
113
139
|
examples <<-TXT
|
114
140
|
* renv install json
|
115
141
|
* renv install json --version=1.1.3
|
142
|
+
* renv install fnando-recurrence --source=http://gems.github.com
|
143
|
+
* renv install fnando-recurrence --source=github
|
116
144
|
TXT
|
117
145
|
|
118
146
|
argument(:name) {
|
@@ -126,7 +154,17 @@ Main {
|
|
126
154
|
attr
|
127
155
|
}
|
128
156
|
|
129
|
-
|
157
|
+
option(:source, :s) {
|
158
|
+
optional
|
159
|
+
argument :required
|
160
|
+
desc "Gem source"
|
161
|
+
attr
|
162
|
+
}
|
163
|
+
|
164
|
+
run {
|
165
|
+
Renv.puts_current_environment
|
166
|
+
Renv::Gem.install(:name => name, :version => version, :source => source)
|
167
|
+
}
|
130
168
|
}
|
131
169
|
|
132
170
|
mode(:uninstall) {
|
@@ -150,7 +188,10 @@ Main {
|
|
150
188
|
attr
|
151
189
|
}
|
152
190
|
|
153
|
-
run {
|
191
|
+
run {
|
192
|
+
Renv.puts_current_environment
|
193
|
+
Renv::Gem.uninstall(:name => name, :version => version)
|
194
|
+
}
|
154
195
|
}
|
155
196
|
|
156
197
|
run { help! }
|
data/lib/renv/color.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
module Renv
|
2
|
+
module Color
|
3
|
+
extend self
|
4
|
+
|
5
|
+
COLORS = {
|
6
|
+
:black => "30",
|
7
|
+
:blue => "34",
|
8
|
+
:cyan => "36",
|
9
|
+
:gray => "30",
|
10
|
+
:green => "32",
|
11
|
+
:purple => "35",
|
12
|
+
:red => "31",
|
13
|
+
:white => "37",
|
14
|
+
:yellow => "33"
|
15
|
+
}
|
16
|
+
|
17
|
+
BGCOLORS = {
|
18
|
+
:black => "40",
|
19
|
+
:blue => "44",
|
20
|
+
:cyan => "46",
|
21
|
+
:gray => "47",
|
22
|
+
:green => "42",
|
23
|
+
:purple => "45",
|
24
|
+
:red => "41",
|
25
|
+
:white => "47",
|
26
|
+
:yellow => "43"
|
27
|
+
}
|
28
|
+
|
29
|
+
STYLES = {
|
30
|
+
:highlight => "1",
|
31
|
+
:blink => "5",
|
32
|
+
:underscore => "4"
|
33
|
+
}
|
34
|
+
|
35
|
+
def colorize(string, options={})
|
36
|
+
options = {
|
37
|
+
:options => []
|
38
|
+
}.merge(options)
|
39
|
+
|
40
|
+
colors = []
|
41
|
+
|
42
|
+
colors << COLORS[options[:color]]
|
43
|
+
colors << BGCOLORS[options[:bgcolor]]
|
44
|
+
|
45
|
+
options[:options] << :highlight if [options[:color], options[:bgcolor]].include?(:white)
|
46
|
+
|
47
|
+
options[:options].each do |option|
|
48
|
+
colors << STYLES[option]
|
49
|
+
end
|
50
|
+
|
51
|
+
colors.uniq!
|
52
|
+
colors.compact!
|
53
|
+
|
54
|
+
if ENV["RENV_NOCOLOR"] == "1"
|
55
|
+
string
|
56
|
+
else
|
57
|
+
%(\e[#{colors.join(";")}m#{string}\e[0m)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def method_missing(color_name, *args)
|
62
|
+
if COLORS.keys.include?(color_name.to_sym)
|
63
|
+
string = args.shift
|
64
|
+
options = args.pop || {}
|
65
|
+
colorize string, {:color => color_name}.merge(options)
|
66
|
+
else
|
67
|
+
super
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/renv/env.rb
CHANGED
@@ -8,79 +8,113 @@ module Renv
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def clone(options)
|
11
|
+
if %w(active env).include?(options[:destiny])
|
12
|
+
Renv.puts Renv::Color.red(options[:destiny], :options => [:underscore]) +
|
13
|
+
" cannot be used as environment name"
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
11
17
|
unless File.exists?(File.join(Renv.dir, options[:source]))
|
12
|
-
puts "source environment doesn't exist"
|
18
|
+
Renv.puts "source environment doesn't exist", :color => :red
|
13
19
|
exit 1
|
14
20
|
end
|
15
21
|
|
16
22
|
if File.exists?(File.join(Renv.dir, options[:destiny]))
|
17
|
-
puts "destiny environment already exist"
|
23
|
+
Renv.puts "destiny environment already exist", :color => :red
|
18
24
|
exit 1
|
19
25
|
end
|
20
26
|
|
27
|
+
$stdout << "cloning " + Renv::Color.yellow(options[:source], :options => [:underscore]) + "... "
|
21
28
|
FileUtils.cp_r(File.join(Renv.dir, options[:source]), File.join(Renv.dir, options[:destiny]))
|
29
|
+
$stdout << Renv::Color.green("done!\n")
|
22
30
|
use options[:destiny]
|
23
31
|
end
|
24
32
|
|
33
|
+
def disable
|
34
|
+
dir = File.join(Renv.dir, "active")
|
35
|
+
FileUtils.rm_rf(dir) if File.exists?(dir)
|
36
|
+
|
37
|
+
Renv.puts "all environments are now disabled", :color => :green
|
38
|
+
end
|
39
|
+
|
25
40
|
def list
|
26
41
|
envs = Dir.entries(Renv.dir).reject do |d|
|
27
42
|
%w(. .. active env).include?(d) || !File.directory?(File.join(Renv.dir, d))
|
28
43
|
end
|
29
44
|
|
30
45
|
if envs.empty?
|
31
|
-
puts "no environments created"
|
46
|
+
Renv.puts "no environments created", :color => :red
|
32
47
|
else
|
33
|
-
|
48
|
+
envs.collect! do |e|
|
49
|
+
e = "* " + Renv::Color.green(e) if e == Renv.env
|
50
|
+
e
|
51
|
+
end
|
52
|
+
|
53
|
+
Renv.puts envs.join("\n")
|
34
54
|
end
|
35
55
|
end
|
36
56
|
|
37
57
|
def delete(environment)
|
38
58
|
if Renv.env == environment
|
39
|
-
|
59
|
+
$stdout << "cannot remove #{Renv::Color.yellow("active", :options => [:underscore])} environment\n"
|
40
60
|
exit 1
|
41
61
|
end
|
42
62
|
|
43
|
-
|
63
|
+
unless File.directory?(File.join(Renv.dir, environment))
|
64
|
+
$stdout << Renv::Color.yellow(environment, :options => [:underscore]) + " is not a valid environment\n"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
$stdout << "removing #{Renv::Color.yellow(environment, :options => [:underscore])} environment... "
|
44
69
|
FileUtils.rm_rf File.join(Renv.dir, environment)
|
45
|
-
|
70
|
+
$stdout << Renv::Color.green("done!\n")
|
46
71
|
end
|
47
72
|
|
48
73
|
def create
|
49
74
|
target = File.join(Renv.dir, Renv.env)
|
50
75
|
|
51
76
|
unless File.directory?(target)
|
52
|
-
|
53
|
-
FileUtils.mkdir_p(target)
|
77
|
+
$stdout << "creating #{Renv::Color.yellow(Renv.env, :options => [:underscore])} environment... "
|
78
|
+
FileUtils.mkdir_p(File.join(target, "bin"))
|
79
|
+
FileUtils.mkdir_p(File.join(target, "lib"))
|
80
|
+
$stdout << Renv::Color.green("done!\n")
|
54
81
|
end
|
55
82
|
end
|
56
83
|
|
57
84
|
def create_root
|
58
85
|
unless File.directory?(Renv.dir)
|
59
|
-
|
86
|
+
$stdout << "creating " + Renv::Color.yellow("~/.renv", :options => [:underscore])
|
87
|
+
$stdout << "... "
|
60
88
|
FileUtils.mkdir_p(Renv.dir)
|
89
|
+
$stdout << Renv::Color.green("OK") if File.directory?(Renv.dir)
|
90
|
+
$stdout << Renv::Color.red("NOK") unless File.directory?(Renv.dir)
|
61
91
|
end
|
62
92
|
end
|
63
93
|
|
64
94
|
def use(environment)
|
65
95
|
if %w(active env).include?(environment)
|
66
|
-
puts
|
96
|
+
Renv.puts Renv::Color.red(environment, :options => [:underscore]) +
|
97
|
+
" cannot be used as environment name"
|
67
98
|
exit 1
|
68
99
|
end
|
69
100
|
|
70
|
-
puts "activating #{environment.inspect} environment"
|
71
101
|
File.open(File.join(Renv.dir, "env"), "w+") do |f|
|
72
102
|
f << environment
|
73
103
|
end
|
74
104
|
|
75
105
|
create
|
76
106
|
symlink
|
77
|
-
puts "done!"
|
78
107
|
end
|
79
108
|
|
80
109
|
def symlink
|
81
|
-
|
82
|
-
|
83
|
-
|
110
|
+
$stdout << "activating " + Renv::Color.yellow(Renv.env, :options => [:underscore]) + " environment... "
|
111
|
+
|
112
|
+
active = File.join(Renv.dir, "active")
|
113
|
+
|
114
|
+
system %(rm -rf #{active}) if File.exists?(active)
|
115
|
+
system %(ln -s #{File.join(Renv.dir, Renv.env)} #{active})
|
116
|
+
|
117
|
+
$stdout << Renv::Color.green("done!\n")
|
84
118
|
end
|
85
119
|
end
|
86
120
|
end
|
data/lib/renv/gem.rb
CHANGED
@@ -2,18 +2,22 @@ module Renv
|
|
2
2
|
module Gem
|
3
3
|
extend self
|
4
4
|
|
5
|
+
SOURCES = {
|
6
|
+
"github" => "http://gems.github.com"
|
7
|
+
}
|
8
|
+
|
5
9
|
def install(options)
|
6
10
|
cmd = "gem install #{options[:name]}"
|
7
11
|
cmd << " --no-rdoc --no-ri"
|
8
12
|
cmd << " -i #{File.join(Renv.dir, Renv.env)}/lib"
|
9
13
|
cmd << " -n #{File.join(Renv.dir, Renv.env)}/bin"
|
10
14
|
cmd << " --version=#{options[:version]}" if options[:version]
|
15
|
+
cmd << " --source=#{SOURCES[options[:source]] || options[:source]}" if options[:source]
|
11
16
|
|
12
17
|
system cmd
|
13
18
|
end
|
14
19
|
|
15
20
|
def uninstall(options)
|
16
|
-
puts "uninstalling gem with #{options.inspect}"
|
17
21
|
cmd = "gem uninstall #{options[:name]}"
|
18
22
|
cmd << " -i #{File.join(Renv.dir, Renv.env)}/lib"
|
19
23
|
cmd << " -n #{File.join(Renv.dir, Renv.env)}/bin"
|
@@ -23,14 +27,9 @@ module Renv
|
|
23
27
|
end
|
24
28
|
|
25
29
|
def list
|
26
|
-
|
27
|
-
gems
|
28
|
-
|
29
|
-
if gems.empty?
|
30
|
-
puts "no gems installed"
|
31
|
-
else
|
32
|
-
puts gems.join(", ")
|
33
|
-
end
|
30
|
+
gems = Dir["#{File.join(Renv.dir, Renv.env)}/lib/specifications/*.gemspec"]
|
31
|
+
gems.collect! {|name| File.basename(name).gsub(/\.gemspec$/i, "") }
|
32
|
+
gems
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
data/lib/renv.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Renv
|
2
2
|
extend self
|
3
3
|
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.2"
|
5
5
|
|
6
6
|
def dir
|
7
7
|
ENV["RENVDIR"] || File.expand_path("~/.renv")
|
@@ -12,6 +12,15 @@ module Renv
|
|
12
12
|
exit 1 unless File.file?(file)
|
13
13
|
File.read(file)
|
14
14
|
end
|
15
|
+
|
16
|
+
def puts(string, options={})
|
17
|
+
string = Renv::Color.colorize(string, options) if options
|
18
|
+
$stdout << %(#{string}\n)
|
19
|
+
end
|
20
|
+
|
21
|
+
def puts_current_environment
|
22
|
+
Renv.puts %(active renv: ) + Renv::Color.colorize(Renv.env, :color => :yellow, :options => [:underscore])
|
23
|
+
end
|
15
24
|
end
|
16
25
|
|
17
26
|
# add renv lib to load path
|
@@ -19,4 +28,5 @@ $LOAD_PATH << File.dirname(__FILE__)
|
|
19
28
|
|
20
29
|
require "FileUtils" unless defined?(FileUtils)
|
21
30
|
require "renv/env"
|
22
|
-
require "renv/gem"
|
31
|
+
require "renv/gem"
|
32
|
+
require "renv/color"
|
data/renv.gemspec
CHANGED
@@ -10,15 +10,15 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.bindir = "bin"
|
11
11
|
s.executables = ["renv"]
|
12
12
|
s.summary = "Renv is a simple and dumb environment manager for RubyGems."
|
13
|
-
s.add_dependency "rubigen", ">= 0"
|
14
13
|
s.add_dependency "main", ">= 0"
|
15
|
-
s.version = "0.0.
|
14
|
+
s.version = "0.0.2"
|
16
15
|
s.require_paths = ["lib"]
|
17
16
|
s.files = ["Rakefile",
|
18
17
|
"renv.gemspec",
|
19
18
|
"README.markdown",
|
20
19
|
"bin/renv",
|
21
20
|
"lib/renv",
|
21
|
+
"lib/renv/color.rb",
|
22
22
|
"lib/renv/env.rb",
|
23
23
|
"lib/renv/gem.rb",
|
24
24
|
"lib/renv.rb"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fnando-renv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
@@ -12,16 +12,6 @@ cert_chain: []
|
|
12
12
|
date: 2009-05-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: rubigen
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
25
15
|
- !ruby/object:Gem::Dependency
|
26
16
|
name: main
|
27
17
|
type: :runtime
|
@@ -47,6 +37,7 @@ files:
|
|
47
37
|
- README.markdown
|
48
38
|
- bin/renv
|
49
39
|
- lib/renv
|
40
|
+
- lib/renv/color.rb
|
50
41
|
- lib/renv/env.rb
|
51
42
|
- lib/renv/gem.rb
|
52
43
|
- lib/renv.rb
|