gemenv 0.0.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/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/bin/gemenv +6 -0
- data/lib/gemenv/activate.erb +19 -0
- data/lib/gemenv/activate_script.rb +18 -0
- data/lib/gemenv/env_dir.rb +86 -0
- data/lib/gemenv/version.rb +5 -0
- data/lib/gemenv.rb +18 -0
- metadata +55 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2012 Alex Young <alex@bytemark.co.uk>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included
|
12
|
+
in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
gemenv
|
2
|
+
======
|
3
|
+
|
4
|
+
A tool for managing gem environments.
|
5
|
+
|
6
|
+
Introduction
|
7
|
+
------------
|
8
|
+
|
9
|
+
gemenv is a tool to build rubygem environments, in the spirit of
|
10
|
+
Python's virtualenv. It creates a directory with a complete GEM\_HOME
|
11
|
+
to contain all of your project's gems. It also contains an activation
|
12
|
+
script to enable this environment.
|
13
|
+
|
14
|
+
Here's an example session:
|
15
|
+
|
16
|
+
$ cd /tmp
|
17
|
+
$ gemenv my-new-env
|
18
|
+
$ ls my-new-env
|
19
|
+
bin/ gem\_home
|
20
|
+
$ source my-new-env/bin/activate
|
21
|
+
{gemenv:my-new-env}
|
22
|
+
$ gem install rake
|
23
|
+
Fetching: rake-10.0.3.gem (100%)
|
24
|
+
Successfully installed rake-10.0.3
|
25
|
+
1 gem installed
|
26
|
+
Installing ri documentation for rake-10.0.3...
|
27
|
+
Installing RDoc documentation for rake-10.0.3...
|
28
|
+
{gemenv:my-new-env}
|
29
|
+
$ ls my-new-env/gem\_home/gems
|
30
|
+
rake-10.0.3
|
31
|
+
{gemenv:my-new-env}
|
32
|
+
$ which rake
|
33
|
+
/tmp/my-new-env/gem_home/bin/rake
|
34
|
+
|
35
|
+
You can see that sourcing the activate script does three things:
|
36
|
+
|
37
|
+
1. It adds the environment name to the prompt
|
38
|
+
2. It sets GEM\_HOME so that gem installations go into the environment,
|
39
|
+
not your home or system GEM\_HOME
|
40
|
+
3. It adds the GEM\_HOME bin/ directory to your $PATH so that
|
41
|
+
gem-installed binaries are available.
|
42
|
+
|
43
|
+
This is (almost) all it does. There is currently no way to deactivate a
|
44
|
+
gemenv environment, although this could be added in the future.
|
45
|
+
|
46
|
+
Anything which respects GEM\_HOME should work with gemenv, so you can,
|
47
|
+
for instance, use bundler to install gems into a gemenv.
|
48
|
+
|
49
|
+
--
|
50
|
+
Alex Young <alex@bytemark.co.uk>
|
data/bin/gemenv
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
VIRTUAL_ENV="<%= @env_dir %>"
|
2
|
+
export VIRTUAL_ENV
|
3
|
+
|
4
|
+
PATH="$VIRTUAL_ENV/gem_home/bin:$PATH"
|
5
|
+
export PATH
|
6
|
+
|
7
|
+
if [ -n "$GEM_HOME" ]; then
|
8
|
+
unset GEM_HOME
|
9
|
+
fi
|
10
|
+
|
11
|
+
GEM_HOME=$VIRTUAL_ENV/gem_home
|
12
|
+
export GEM_HOME
|
13
|
+
GEM_PATH=$(gem env home)
|
14
|
+
|
15
|
+
PS1="{gemenv:$(basename $VIRTUAL_ENV)} $PS1"
|
16
|
+
|
17
|
+
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
|
18
|
+
hash -r 2> /dev/null
|
19
|
+
fi
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module Gemenv
|
5
|
+
class ActivateScript
|
6
|
+
def initialize( env_dir )
|
7
|
+
@env_dir = env_dir
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_bash
|
11
|
+
here = File.dirname( __FILE__ )
|
12
|
+
template_filename = File.join( here, "activate.erb" )
|
13
|
+
template = File.read( template_filename )
|
14
|
+
ERB.new( template ).result( binding )
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class Path
|
7
|
+
def initialize( dirname )
|
8
|
+
@pathname = Pathname( dirname )
|
9
|
+
end
|
10
|
+
|
11
|
+
def mkdir_p
|
12
|
+
FileUtils.mkdir_p( @pathname )
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def /(other)
|
17
|
+
self.class.new( @pathname + other )
|
18
|
+
end
|
19
|
+
|
20
|
+
def write( str )
|
21
|
+
File.open( self, "wb" ) { |f| f.write str }
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
def method_missing( sym, *args, &blk )
|
26
|
+
@pathname.__send__( sym, *args, &blk )
|
27
|
+
end
|
28
|
+
|
29
|
+
def respond_to?( sym )
|
30
|
+
super || @pathname.respond_to?( sym )
|
31
|
+
end
|
32
|
+
|
33
|
+
def dirname
|
34
|
+
self.class.new( @pathname.dirname )
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
@pathname.to_s
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
module Gemenv
|
44
|
+
class EnvDir
|
45
|
+
attr_reader :path
|
46
|
+
|
47
|
+
def initialize( env_dir, script_class )
|
48
|
+
@path = Path.new( env_dir )
|
49
|
+
@script_class = script_class
|
50
|
+
end
|
51
|
+
|
52
|
+
def make
|
53
|
+
@path.mkdir_p
|
54
|
+
|
55
|
+
make_activate()
|
56
|
+
make_gem_home()
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
def make_activate
|
62
|
+
activate_path.dirname.mkdir_p
|
63
|
+
activate_path.write( activate_contents )
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def make_gem_home
|
68
|
+
gem_home_path.mkdir_p
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def activate_path
|
73
|
+
@path/"bin"/"activate"
|
74
|
+
end
|
75
|
+
|
76
|
+
def gem_home_path
|
77
|
+
@path/"gem_home"
|
78
|
+
end
|
79
|
+
|
80
|
+
def activate_contents
|
81
|
+
@script_class.new( @path ).to_bash
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
data/lib/gemenv.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'gemenv/activate_script'
|
4
|
+
require 'gemenv/env_dir'
|
5
|
+
|
6
|
+
module Gemenv
|
7
|
+
class Application
|
8
|
+
def initialize( argv )
|
9
|
+
@env_dir = argv.shift
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
raise "Need an env dir!" unless @env_dir
|
14
|
+
full_env_dir = File.expand_path( @env_dir )
|
15
|
+
EnvDir.new( full_env_dir, ActivateScript ).make
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemenv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Young
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Gemenv provides a container for your gems, and otherwise stays out of
|
15
|
+
your way.
|
16
|
+
email:
|
17
|
+
- alex@bytemark.co.uk
|
18
|
+
executables:
|
19
|
+
- gemenv
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- bin/gemenv
|
24
|
+
- lib/gemenv/env_dir.rb
|
25
|
+
- lib/gemenv/activate_script.rb
|
26
|
+
- lib/gemenv/activate.erb
|
27
|
+
- lib/gemenv/version.rb
|
28
|
+
- lib/gemenv.rb
|
29
|
+
- LICENSE.txt
|
30
|
+
- README.md
|
31
|
+
homepage: http://github.com/regularfry/gemenv
|
32
|
+
licenses: []
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.3.6
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project: gemenv
|
51
|
+
rubygems_version: 1.8.24
|
52
|
+
signing_key:
|
53
|
+
specification_version: 3
|
54
|
+
summary: The best way to contain your dependencies
|
55
|
+
test_files: []
|