toastyapps-gembox 1.3.1 → 1.3.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.txt +2 -0
- data/lib/gembox.rb +40 -20
- data/lib/templates/dispatch.rb +33 -32
- data/lib/templates/gemrc +5 -1
- metadata +1 -1
data/README.txt
CHANGED
data/lib/gembox.rb
CHANGED
|
@@ -3,47 +3,67 @@ require 'yaml'
|
|
|
3
3
|
require 'erb'
|
|
4
4
|
|
|
5
5
|
class Gembox
|
|
6
|
-
VERSION = '1.3.
|
|
6
|
+
VERSION = '1.3.2'
|
|
7
7
|
attr_accessor :dir, :cfg
|
|
8
8
|
attr_accessor :cfg
|
|
9
9
|
|
|
10
10
|
def initialize
|
|
11
|
-
@cfg_path =
|
|
11
|
+
@cfg_path = "#{ENV['HOME']}/.gembox/config.yml"
|
|
12
12
|
load_config
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def self.help
|
|
16
|
+
puts File.read("../README.txt")
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def self.create(args)
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
args.each do |box_name|
|
|
21
|
+
|
|
22
|
+
@dir = "#{ENV['HOME']}/.gembox/#{box_name}"
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
if File.exists?(@dir)
|
|
25
|
+
puts "Box #{box_name} already exists"
|
|
26
|
+
else
|
|
27
|
+
FileUtils.mkdir_p @dir # make gembox folder
|
|
28
|
+
FileUtils.mkdir_p "#{@dir}/usr/bin"
|
|
29
|
+
FileUtils.mkdir_p "#{@dir}/gems"
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
File.open("#{@dir}/.gemrc", 'w') { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/gemrc").read).result(binding) } unless File.exists?("#{@dir}/.gemrc")
|
|
32
|
+
File.open("#{@dir}/.bashrc", "w") { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/bashrc").read).result(binding) } unless File.exists?("#{@dir}/.bashrc")
|
|
33
|
+
File.open("#{@dir}/shell.bash", "w") {|f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/shell.bash").read).result(binding) } unless File.exists?("#{@dir}/shell.bash")
|
|
34
|
+
File.open("#{@dir}/dispatch.rb", "w") { |f| f.puts ERB.new(File.open(File.dirname(__FILE__)+"/templates/dispatch.rb").read).result(binding) } unless File.exists?("#{@dir}/dispatch.rb")
|
|
35
|
+
puts "Box #{box_name} has been created"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
27
38
|
end
|
|
28
39
|
|
|
29
40
|
def self.list(args)
|
|
30
|
-
puts "Current
|
|
41
|
+
puts "Current Boxes:\n"
|
|
31
42
|
Dir.foreach("#{ENV['HOME']}/.gembox") do |file|
|
|
32
|
-
puts "
|
|
43
|
+
puts " #{file}" if file !~ /^\./
|
|
33
44
|
end
|
|
34
45
|
end
|
|
35
46
|
|
|
47
|
+
def self.del(args)
|
|
48
|
+
delete(args)
|
|
49
|
+
end
|
|
50
|
+
|
|
36
51
|
def self.delete(args)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
args.each do |box_name|
|
|
53
|
+
@dir = "#{ENV['HOME']}/.gembox/#{box_name}"
|
|
54
|
+
if File.exists?(@dir)
|
|
55
|
+
FileUtils.rm_r(@dir)
|
|
56
|
+
puts "Box #{box_name} has been deleted"
|
|
57
|
+
else
|
|
58
|
+
puts "Box #{box_name} does not exists"
|
|
59
|
+
end
|
|
44
60
|
end
|
|
45
61
|
end
|
|
46
62
|
|
|
63
|
+
def self.sh(args)
|
|
64
|
+
shell(args)
|
|
65
|
+
end
|
|
66
|
+
|
|
47
67
|
def self.shell(args)
|
|
48
68
|
box_name = args.shift
|
|
49
69
|
@dir = "#{ENV['HOME']}/.gembox/#{box_name}"
|
data/lib/templates/dispatch.rb
CHANGED
|
@@ -8,7 +8,7 @@ case command
|
|
|
8
8
|
when 'install'
|
|
9
9
|
system("gem --config-file <%= @dir %>/.gemrc #{command} --bindir <%= @dir %>/usr/bin #{ARGV.join(' ')}")
|
|
10
10
|
when 'load_config'
|
|
11
|
-
cfg_path =
|
|
11
|
+
cfg_path = "#{ENV['HOME']}/.gembox/config.yml"
|
|
12
12
|
if File.exists?(cfg_path)
|
|
13
13
|
data = YAML.load(File.open(cfg_path).read)
|
|
14
14
|
if data['symlink']
|
|
@@ -21,41 +21,42 @@ when 'load_config'
|
|
|
21
21
|
end
|
|
22
22
|
when 'symlink'
|
|
23
23
|
data = YAML.load(File.open('<%= @dir %>/gems.yaml').read)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
args.each do |gem_name|
|
|
25
|
+
if data[gem_name] && data[gem_name].keys.length > 0
|
|
26
|
+
FileUtils.mkdir_p('<%= @dir %>/gems/gems/')
|
|
27
|
+
FileUtils.mkdir_p('<%= @dir %>/gems/specifications/')
|
|
28
|
+
versions = []
|
|
29
|
+
if data[gem_name].keys.length == 1
|
|
30
|
+
versions << data[gem_name].keys[0]
|
|
31
|
+
elsif data[gem_name].keys.length > 1
|
|
32
|
+
puts 'Select gem to symlink:'
|
|
33
|
+
index = 1
|
|
34
|
+
data[gem_name].keys.each do |key|
|
|
35
|
+
puts " #{index}. #{gem_name}-#{key}"
|
|
36
|
+
index += 1
|
|
37
|
+
end
|
|
38
|
+
puts " #{index}. All versions"
|
|
39
|
+
print "> "
|
|
40
|
+
choice = gets
|
|
41
|
+
if choice == index
|
|
42
|
+
versions = data[gem_name].keys
|
|
43
|
+
else
|
|
44
|
+
versions << data[gem_name].keys[choice.to_i - 1]
|
|
45
|
+
end
|
|
37
46
|
end
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
versions.each do |version|
|
|
49
|
+
gemdir = data[gem_name][version]
|
|
50
|
+
gemname = gem_name+'-'+version
|
|
51
|
+
gem_file = gemdir + '/gems/' + gemname
|
|
52
|
+
spec_file = gemdir + '/specifications/' + gemname + '.gemspec'
|
|
53
|
+
`ln -s #{gem_file} <%= @dir %>/gems/gems/#{gemname} && ln -s #{spec_file} <%= @dir %>/gems/specifications/#{gemname}.gemspec`
|
|
54
|
+
puts "Successfully symlinked #{gemname}"
|
|
45
55
|
end
|
|
46
|
-
end
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
gemname = gem_name+'-'+version
|
|
51
|
-
gem_file = gemdir + '/gems/' + gemname
|
|
52
|
-
spec_file = gemdir + '/specifications/' + gemname + '.gemspec'
|
|
53
|
-
`ln -s #{gem_file} <%= @dir %>/gems/gems/#{gemname} && ln -s #{spec_file} <%= @dir %>/gems/specifications/#{gemname}.gemspec`
|
|
54
|
-
puts "Successfully symlinked #{gemname}"
|
|
57
|
+
else
|
|
58
|
+
puts "Could not find gem #{gem_name}"
|
|
55
59
|
end
|
|
56
|
-
|
|
57
|
-
else
|
|
58
|
-
puts "Could not find gem #{gem_name}"
|
|
59
60
|
end
|
|
60
61
|
else
|
|
61
62
|
system("gem --config-file <%= @dir %>/.gemrc #{command} #{ARGV.join(' ')}")
|
data/lib/templates/gemrc
CHANGED