rvmbs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +14 -0
- data/LICENSE +21 -0
- data/README.markdown +32 -0
- data/Rakefile +1 -0
- data/bin/rvmbs +5 -0
- data/lib/rvmbs/version.rb +3 -0
- data/lib/rvmbs.rb +90 -0
- data/rvmbs.gemspec +22 -0
- metadata +57 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.9.2@rvmbs
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Jorge Luis Pérez (jolisper@gmail.com)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
RVM Bootstrap
|
2
|
+
=============
|
3
|
+
|
4
|
+
Command to create a directory project with a configured .rvmrc into.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
-----------
|
8
|
+
|
9
|
+
gem install rvmbs
|
10
|
+
|
11
|
+
Usage
|
12
|
+
-----
|
13
|
+
|
14
|
+
$ rvmbs -d my_project
|
15
|
+
|
16
|
+
Generates a my_project directory with a trusted .rvmrc file contains:
|
17
|
+
|
18
|
+
rvm use --create 1.9.2@my_project
|
19
|
+
|
20
|
+
Run `rvmbs --help` for more options.
|
21
|
+
|
22
|
+
To Do
|
23
|
+
-----
|
24
|
+
|
25
|
+
* Add tests.
|
26
|
+
* Bundler integration.
|
27
|
+
|
28
|
+
Copyright
|
29
|
+
---------
|
30
|
+
|
31
|
+
Copyright (c) 2012 Jorge Luis Pérez. See LICENSE for details.
|
32
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/rvmbs
ADDED
data/lib/rvmbs.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require "rvmbs/version"
|
2
|
+
require "optparse"
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module RVMBS
|
6
|
+
|
7
|
+
module Command
|
8
|
+
|
9
|
+
def self.run(args)
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
optsp = nil
|
13
|
+
|
14
|
+
optparse = OptionParser.new do |opts|
|
15
|
+
optsp = opts
|
16
|
+
opts.banner = "Usage: rvmbs [options] PROJECT_NAME"
|
17
|
+
|
18
|
+
# This define the directory name.
|
19
|
+
opts.on('-d', '--directory NAME', "The name of the project's directory.") do |name|
|
20
|
+
options[:directory] = name
|
21
|
+
end
|
22
|
+
|
23
|
+
# This define the ruby interpreter.
|
24
|
+
options[:ruby] = '1.9.2'
|
25
|
+
opts.on('-r', '--ruby-implementation NAME', "The name of the Ruby implementation.") do |name|
|
26
|
+
options[:ruby] = name
|
27
|
+
end
|
28
|
+
|
29
|
+
# This define the ruby interpreter.
|
30
|
+
options[:force] = false
|
31
|
+
opts.on('-f', '--force', "Delete directory if already exists.") do
|
32
|
+
options[:force] = true
|
33
|
+
end
|
34
|
+
|
35
|
+
# This will print an options summary.
|
36
|
+
opts.on_tail("-h", "--help", "Show this message.") do
|
37
|
+
puts opts
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
end.parse!(args)
|
42
|
+
|
43
|
+
# Directory must be set.
|
44
|
+
if options[:directory] == nil
|
45
|
+
puts optsp
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
|
49
|
+
create_directory(options)
|
50
|
+
create_rvmrc(options)
|
51
|
+
set_rvmrc_trusted(options, Dir.pwd)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Creates the directory.
|
55
|
+
def self.create_directory(options)
|
56
|
+
begin
|
57
|
+
Dir.mkdir options[:directory]
|
58
|
+
rescue
|
59
|
+
if options[:force]
|
60
|
+
FileUtils.rm_rf options[:directory]
|
61
|
+
options[:force] = false
|
62
|
+
retry
|
63
|
+
end
|
64
|
+
puts "ERROR: directory already exists or cannot be created (try with --force)."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Creates the .rvmrc file.
|
69
|
+
def self.create_rvmrc(options)
|
70
|
+
Dir.chdir(options[:directory])
|
71
|
+
File.open(".rvmrc", "w") do |f|
|
72
|
+
f.write("rvm use --create #{options[:ruby]}@#{options[:directory]}\n")
|
73
|
+
end
|
74
|
+
Dir.chdir('..')
|
75
|
+
end
|
76
|
+
|
77
|
+
# Run rvm rvmrc trust command detached from console.
|
78
|
+
def self.set_rvmrc_trusted(options, current_dir)
|
79
|
+
current_dir =
|
80
|
+
pid = fork do
|
81
|
+
Process.daemon
|
82
|
+
exit system "rvm rvmrc trust #{current_dir}/#{options[:directory]}/"
|
83
|
+
end
|
84
|
+
_, status = Process.waitpid2(pid)
|
85
|
+
puts "ERROR: rvm rvmrc trust command fail!" if status != 0
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/rvmbs.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rvmbs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rvmbs"
|
7
|
+
s.version = RVMBS::VERSION
|
8
|
+
s.authors = ["Jorge Luis Pérez"]
|
9
|
+
s.email = ["jolisper@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/jolisper/rvmbs"
|
11
|
+
s.summary = %q{RVM Bootstrap}
|
12
|
+
s.description = %q{Command to create a project directory with a configured .rvmrc into.}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# specify any dependencies here; for example:
|
20
|
+
# s.add_development_dependency "rspec"
|
21
|
+
# s.add_runtime_dependency "rest-client"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rvmbs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jorge Luis Pérez
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-24 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Command to create a project directory with a configured .rvmrc into.
|
15
|
+
email:
|
16
|
+
- jolisper@gmail.com
|
17
|
+
executables:
|
18
|
+
- rvmbs
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- .rvmrc
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- LICENSE
|
27
|
+
- README.markdown
|
28
|
+
- Rakefile
|
29
|
+
- bin/rvmbs
|
30
|
+
- lib/rvmbs.rb
|
31
|
+
- lib/rvmbs/version.rb
|
32
|
+
- rvmbs.gemspec
|
33
|
+
homepage: http://github.com/jolisper/rvmbs
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.10
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: RVM Bootstrap
|
57
|
+
test_files: []
|