ruby-llenv 0.0.3 → 0.0.4

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.
@@ -1,3 +1,10 @@
1
+ ## 0.0.4 (2012-11-25)
2
+
3
+ * Refactoring
4
+ * Divide declaring repository
5
+ * Omit command line options
6
+ * use ENV
7
+
1
8
  ## 0.0.3 (2012-11-25)
2
9
 
3
10
  * Dir.exists? -> File.directory? for ruby 1.8.7
data/README.md CHANGED
@@ -18,16 +18,27 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ Install ruby-1.9.3-p327 to ~/.llenv/ruby-1.9.3-p327/, and also `bundle install` required modules to your-project/vendor/bundle. See [install.sh](https://github.com/riywo/llenv-declare/blob/master/ruby-1.9.3-p327/install.sh).
22
+
21
23
  $ cd your-project
22
24
  $ echo ruby-1.9.3-p327 > .llenv
23
25
  $ llenv install
24
26
 
25
- Install ruby-1.9.3-p327 to ~/.llenv/ruby-1.9.3-p327/, and also `bundle install` required modules to your-project/vendor/bundle. See [install.sh](https://github.com/riywo/ruby-llenv/blob/master/declare/ruby-1.9.3-p327/install.sh).
27
+ Execute any command. See [exec.sh](https://github.com/riywo/llenv-declare/blob/master/ruby-1.9.3-p327/exec.sh).
26
28
 
27
29
  $ cd your-project
30
+ $ llenv exec ruby -v
28
31
  $ llenv exec rackup
29
32
 
30
- See [exec.sh](https://github.com/riywo/ruby-llenv/blob/master/declare/ruby-1.9.3-p327/exec.sh).
33
+ ## ENV
34
+
35
+ ### `LLENV_ROOT`
36
+
37
+ Root directory installed all LLs. Default: "~/.llenv"
38
+
39
+ ### `LLENV_DECLARE_URL`
40
+
41
+ Declare repository URL. Default: [https://github.com/riywo/llenv-declare.git](https://github.com/riywo/llenv-declare.git)
31
42
 
32
43
  ## Contributing
33
44
 
@@ -4,27 +4,32 @@ require "thor"
4
4
 
5
5
  class LLenv::CLI < Thor
6
6
 
7
- class_option :declare, :type => :string, :aliases => "-d", :desc => "Specify a user declare directory"
8
- class_option :home, :type => :string, :aliases => "-h", :desc => "Specify a home directory of LL (Default: ~/.llenv)"
7
+ def initialize(args = [], options = {}, config = {})
8
+ @root_dir = ENV["LLENV_ROOT"] || File.expand_path("~/.llenv")
9
+ @declare_repo = ENV["LLENV_DECLARE_URL"] || "https://github.com/riywo/llenv-declare.git"
10
+ @declare = LLenv::Declare.new(@root_dir)
11
+ super
12
+ end
13
+
14
+ desc "list", "List of declaring"
15
+ def list
16
+ check_root_dir!
17
+ @declare.list
18
+ end
9
19
 
10
20
  desc "install", "Install declared LL"
11
21
  def install
12
- load_llenv_file!
13
- check_homedir!
14
- load_declare!
15
- @declare.install
22
+ check_root_dir!
23
+ @declare.install(llenv)
16
24
  end
17
25
 
18
26
  desc "exec", "Execute command with declared LL"
19
27
  def exec(*argv)
20
- load_llenv_file!
21
- check_homedir!
22
- load_declare!
23
- @declare.execute(argv)
28
+ check_root_dir!
29
+ @declare.execute(llenv, argv)
24
30
  end
25
31
 
26
32
  desc "version", "Display LLenv gem version"
27
-
28
33
  map ["-v", "--version"] => :version
29
34
  def version
30
35
  puts LLenv::VERSION
@@ -37,27 +42,18 @@ private ######################################################################
37
42
  exit 1
38
43
  end
39
44
 
40
- def load_llenv_file!
41
- root = File.expand_path(Dir.pwd)
42
- default_env = File.join(root, ".llenv")
43
- error("#{default_env} does not exist.") unless File.exist?(default_env)
44
- @llenv = File.read(default_env).split("\n")[0]
45
- end
46
-
47
- def check_homedir!
48
- home = options[:home] || File.expand_path("~/.llenv")
49
- llhome = File.join(home, @llenv)
50
- Dir.mkdir(home) unless File.directory?(home)
51
- Dir.mkdir(llhome) unless File.directory?(llhome)
52
- @llhome = llhome
45
+ def llenv
46
+ pwd = File.expand_path(Dir.pwd)
47
+ llenv_file = File.join(pwd, ".llenv")
48
+ error("#{llenv_file} does not exist.") unless File.exist?(llenv_file)
49
+ llenv = File.read(llenv_file).split("\n")[0]
50
+ llenv
53
51
  end
54
52
 
55
- def load_declare!
56
- declare_dirs = []
57
- declare_dirs << File.join(options[:declare], @llenv) if options[:declare]
58
- declare_dirs << File.expand_path("../../../declare/#{@llenv}", __FILE__)
59
- dir = declare_dirs.detect { |d| File.directory?(d) } or error("Declare of '#{@llenv}' does not exist.")
60
- @declare = LLenv::Declare.new(dir, @llhome)
53
+ def check_root_dir!
54
+ unless File.directory?(@root_dir)
55
+ system("git clone #{@declare_repo} #{@root_dir} > /dev/null 2>&1") or error("git clone #{@declare_repo}")
56
+ end
61
57
  end
62
58
 
63
59
  end
@@ -1,32 +1,46 @@
1
1
  require "llenv"
2
2
 
3
3
  class LLenv::Declare
4
- def initialize(dir, llhome)
5
- @install_sh = File.join(dir, "install.sh")
6
- @exec_sh = File.join(dir, "exec.sh")
7
- @llhome = llhome
4
+ def initialize(dir)
5
+ @root_dir = dir
8
6
  end
9
7
 
10
- def install
11
- set_env
12
- system(@install_sh)
8
+ def install(llenv)
9
+ set_env(llenv)
10
+ install_sh = File.join(@declare_dir, "install.sh")
11
+ system(install_sh)
13
12
  end
14
13
 
15
- def execute(argv)
16
- set_env
17
- exec(@exec_sh, *argv)
14
+ def execute(llenv, argv)
15
+ set_env(llenv)
16
+ exec_sh = File.join(@declare_dir, "exec.sh")
17
+ exec(exec_sh, *argv)
18
+ end
19
+
20
+ def list
21
+ Dir.entries(@root_dir).each do |f|
22
+ next if f =~ /^\./
23
+ next unless File.directory?(File.join(@root_dir, f))
24
+ print f + "\n"
25
+ end
18
26
  end
19
27
 
20
28
  private
21
29
 
22
- def set_env
30
+ def set_env(llenv)
31
+ @declare_dir = File.join(@root_dir, llenv)
32
+ raise "#{llenv} not declared in #{@root_dir}" unless File.directory?(@declare_dir)
33
+
23
34
  ENV.clear
24
35
  env = `. /etc/profile && env`
25
36
  env.split("\n").map do |e|
26
37
  k, v = e.split("=")
27
38
  ENV[k] = v
28
39
  end
29
- ENV["HOME"] = @llhome
40
+
41
+ home = File.join(@declare_dir, ".home")
42
+ Dir.mkdir(home) unless File.directory?(home)
43
+ ENV["HOME"] = home
30
44
  ENV["SHELL"] = "/bin/bash"
31
45
  end
32
46
 
@@ -1,3 +1,3 @@
1
1
  module LLenv
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-llenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -42,14 +42,6 @@ files:
42
42
  - README.md
43
43
  - Rakefile
44
44
  - bin/llenv
45
- - declare/node-0.9.3/exec.sh
46
- - declare/node-0.9.3/install.sh
47
- - declare/perl-5.16.2/exec.sh
48
- - declare/perl-5.16.2/install.sh
49
- - declare/python-2.7.3/exec.sh
50
- - declare/python-2.7.3/install.sh
51
- - declare/ruby-1.9.3-p327/exec.sh
52
- - declare/ruby-1.9.3-p327/install.sh
53
45
  - lib/llenv.rb
54
46
  - lib/llenv/cli.rb
55
47
  - lib/llenv/declare.rb
@@ -1,6 +0,0 @@
1
- #!/bin/sh
2
- source "$HOME/nvm/nvm.sh"
3
- nvm use v0.9.3 > /dev/null
4
- export PATH="./node_modules/.bin:$PATH"
5
-
6
- exec "$@"
@@ -1,13 +0,0 @@
1
- #!/bin/sh
2
- if ! [ -d "$HOME/nvm" ]; then
3
- git clone git://github.com/creationix/nvm.git "$HOME/nvm"
4
- fi
5
-
6
- source "$HOME/nvm/nvm.sh"
7
-
8
- if ! [ -d "$HOME/nvm/v0.9.3" ]; then
9
- nvm install v0.9.3
10
- fi
11
-
12
- nvm use v0.9.3
13
- npm install
@@ -1,6 +0,0 @@
1
- #!/bin/sh
2
- source $HOME/perl5/perlbrew/etc/bashrc
3
- export PERL5OPT="-Mlib=./local/lib/perl5"
4
- export PATH="./local/bin:$PATH"
5
-
6
- exec "$@"
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
- if ! [ -f $HOME/perl5/perlbrew/etc/bashrc ]; then
3
- curl -kL http://install.perlbrew.pl | bash
4
- fi
5
-
6
- source $HOME/perl5/perlbrew/etc/bashrc
7
-
8
- if [ "$PERLBREW_PERL" != "perl-5.16.2" ]; then
9
- perlbrew install perl-5.16.2 -n -j 2
10
- perlbrew switch perl-5.16.2
11
- fi
12
-
13
- if [ -z "$(which cpanm)" ]; then
14
- perlbrew install-cpanm
15
- fi
16
-
17
- cpanm -v -l local --installdeps .
@@ -1,6 +0,0 @@
1
- #!/bin/sh
2
- source "$HOME/.pythonbrew/etc/bashrc"
3
- source "$HOME/.pythonbrew/pythons/Python-2.7.3/bin/virtualenvwrapper.sh"
4
- workon env
5
-
6
- exec "$@"
@@ -1,24 +0,0 @@
1
- #!/bin/sh
2
- if ! [ -f "$HOME/.pythonbrew/etc/bashrc" ]; then
3
- curl -kL http://xrl.us/pythonbrewinstall | bash
4
- fi
5
-
6
- source "$HOME/.pythonbrew/etc/bashrc"
7
-
8
- if ! [[ "$PYTHONPATH" =~ Python-2.7.3 ]]; then
9
- pythonbrew install 2.7.3
10
- pythonbrew switch 2.7.3
11
- fi
12
-
13
- if ! [ -f "$HOME/.pythonbrew/pythons/Python-2.7.3/bin/virtualenvwrapper.sh" ]; then
14
- pip install virtualenv virtualenvwrapper
15
- fi
16
-
17
- source "$HOME/.pythonbrew/pythons/Python-2.7.3/bin/virtualenvwrapper.sh"
18
-
19
- if ! [ -d "$HOME/.virtualenvs/env" ]; then
20
- mkvirtualenv env
21
- fi
22
-
23
- workon env
24
- pip install -r requirements.txt
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
- export PATH="$HOME/.rbenv/bin:$PATH"
3
- eval "$(rbenv init -)"
4
-
5
- bundle exec "$@"
@@ -1,25 +0,0 @@
1
- #!/bin/sh
2
- if ! [ -d $HOME/.rbenv ]; then
3
- git clone git://github.com/sstephenson/rbenv.git $HOME/.rbenv
4
- fi
5
-
6
- if ! [ -d $HOME/.rbenv/plugins/ruby-build ]; then
7
- git clone git://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build
8
- fi
9
-
10
- export PATH="$HOME/.rbenv/bin:$PATH"
11
- eval "$(rbenv init -)"
12
- rbenv rehash
13
-
14
- if ! [[ $(rbenv version) =~ ^1\.9\.3-p327 ]]; then
15
- rbenv install 1.9.3-p327
16
- rbenv global 1.9.3-p327
17
- rbenv rehash
18
- fi
19
-
20
- if [[ -z $(gem list bundler | grep bundler) ]]; then
21
- gem install bundler
22
- rbenv rehash
23
- fi
24
-
25
- bundle install --path=vendor/bundle