ruby-llenv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ .*.swp
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ .llenv
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+ vendor/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruby-llenv.gemspec
4
+ gemspec
5
+
6
+ gem "thor"
7
+ gem "tapp"
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 riywo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # LLenv
2
+
3
+ LL install and exec manager
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ruby-llenv'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ruby-llenv
18
+
19
+ ## Usage
20
+
21
+ $ cd your-project
22
+ $ echo ruby-1.9.3-p327 > .llenv
23
+ $ llenv install
24
+
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).
26
+
27
+ $ cd your-project
28
+ $ llenv exec rackup
29
+
30
+ See [exec.sh](https://github.com/riywo/ruby-llenv/blob/master/declare/ruby-1.9.3-p327/exec.sh).
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require "llenv/cli"
6
+
7
+ LLenv::CLI.start
@@ -0,0 +1,6 @@
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 "$@"
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,6 @@
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 "$@"
@@ -0,0 +1,17 @@
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 .
@@ -0,0 +1,6 @@
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 "$@"
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ export PATH="$HOME/.rbenv/bin:$PATH"
3
+ eval "$(rbenv init -)"
4
+
5
+ bundle exec "$@"
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,5 @@
1
+ require "llenv/version"
2
+
3
+ module LLenv
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,64 @@
1
+ require "llenv"
2
+ require "llenv/declare"
3
+ require "thor"
4
+ require "tapp"
5
+
6
+ class LLenv::CLI < Thor
7
+
8
+ class_option :declare, :type => :string, :aliases => "-d", :desc => "Specify a user declare directory"
9
+ class_option :home, :type => :string, :aliases => "-h", :desc => "Specify a home directory of LL (Default: ~/.llenv)"
10
+
11
+ desc "install", "Install declared LL"
12
+ def install
13
+ load_llenv_file!
14
+ check_homedir!
15
+ load_declare!
16
+ @declare.install
17
+ end
18
+
19
+ desc "exec", "Execute command with declared LL"
20
+ def exec(*argv)
21
+ load_llenv_file!
22
+ check_homedir!
23
+ load_declare!
24
+ @declare.execute(argv)
25
+ end
26
+
27
+ desc "version", "Display LLenv gem version"
28
+
29
+ map ["-v", "--version"] => :version
30
+ def version
31
+ puts LLenv::VERSION
32
+ end
33
+
34
+ private ######################################################################
35
+
36
+ def error(message)
37
+ puts "ERROR: #{message}"
38
+ exit 1
39
+ end
40
+
41
+ def load_llenv_file!
42
+ root = File.expand_path(Dir.pwd)
43
+ default_env = File.join(root, ".llenv")
44
+ error("#{default_env} does not exist.") unless File.exist?(default_env)
45
+ @llenv = File.read(default_env).split("\n")[0]
46
+ end
47
+
48
+ def check_homedir!
49
+ home = options[:home] || File.expand_path("~/.llenv")
50
+ llhome = File.join(home, @llenv)
51
+ Dir.mkdir(home) unless Dir.exists?(home)
52
+ Dir.mkdir(llhome) unless Dir.exists?(llhome)
53
+ @llhome = llhome
54
+ end
55
+
56
+ def load_declare!
57
+ declare_dirs = []
58
+ declare_dirs << File.join(options[:declare], @llenv) if options[:declare]
59
+ declare_dirs << File.expand_path("../../../declare/#{@llenv}", __FILE__)
60
+ dir = declare_dirs.detect { |d| Dir.exists?(d) } or error("Declare of '#{@llenv}' does not exist.")
61
+ @declare = LLenv::Declare.new(dir, @llhome)
62
+ end
63
+
64
+ end
@@ -0,0 +1,33 @@
1
+ require "llenv"
2
+
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
8
+ end
9
+
10
+ def install
11
+ set_env
12
+ system(@install_sh)
13
+ end
14
+
15
+ def execute(argv)
16
+ set_env
17
+ exec(@exec_sh, *argv)
18
+ end
19
+
20
+ private
21
+
22
+ def set_env
23
+ ENV.clear
24
+ env = `. /etc/profile && env`
25
+ env.split("\n").map do |e|
26
+ k, v = e.split("=")
27
+ ENV[k] = v
28
+ end
29
+ ENV["HOME"] = @llhome
30
+ ENV["SHELL"] = "/bin/bash"
31
+ end
32
+
33
+ end
@@ -0,0 +1,3 @@
1
+ module LLenv
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'llenv/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "ruby-llenv"
8
+ gem.version = LLenv::VERSION
9
+ gem.authors = ["riywo"]
10
+ gem.email = ["riywo.jp@gmail.com"]
11
+ gem.description = %q{LL install and exec}
12
+ gem.summary = %q{Using .llenv file of repository}
13
+ gem.homepage = "https://github.com/riywo/ruby-llenv"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-llenv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - riywo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: LL install and exec
15
+ email:
16
+ - riywo.jp@gmail.com
17
+ executables:
18
+ - llenv
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bin/llenv
28
+ - declare/node-0.9.3/exec.sh
29
+ - declare/node-0.9.3/install.sh
30
+ - declare/perl-5.16.2/exec.sh
31
+ - declare/perl-5.16.2/install.sh
32
+ - declare/python-2.7.3/exec.sh
33
+ - declare/python-2.7.3/install.sh
34
+ - declare/ruby-1.9.3-p327/exec.sh
35
+ - declare/ruby-1.9.3-p327/install.sh
36
+ - lib/llenv.rb
37
+ - lib/llenv/cli.rb
38
+ - lib/llenv/declare.rb
39
+ - lib/llenv/version.rb
40
+ - ruby-llenv.gemspec
41
+ homepage: https://github.com/riywo/ruby-llenv
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.23
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Using .llenv file of repository
65
+ test_files: []