toastyapps-gembox 1.3.0 → 1.3.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/lib/gembox.rb +38 -16
- data/lib/templates/bashrc +1 -1
- metadata +1 -1
data/lib/gembox.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'yaml'
|
|
|
3
3
|
require 'erb'
|
|
4
4
|
|
|
5
5
|
class Gembox
|
|
6
|
-
VERSION = '1.3.
|
|
6
|
+
VERSION = '1.3.1'
|
|
7
7
|
attr_accessor :dir, :cfg
|
|
8
8
|
attr_accessor :cfg
|
|
9
9
|
|
|
@@ -13,29 +13,51 @@ class Gembox
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def self.create(args)
|
|
16
|
+
box_name = args.shift
|
|
17
|
+
@dir = "#{ENV['HOME']}/.gembox/#{box_name}"
|
|
16
18
|
|
|
17
|
-
dir
|
|
18
|
-
|
|
19
|
+
FileUtils.mkdir_p @dir # make gembox folder
|
|
20
|
+
FileUtils.mkdir_p "#{@dir}/usr/bin"
|
|
21
|
+
FileUtils.mkdir_p "#{@dir}/gems"
|
|
19
22
|
|
|
20
|
-
@dir
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
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")
|
|
24
|
+
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")
|
|
25
|
+
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")
|
|
26
|
+
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")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.list(args)
|
|
30
|
+
puts "Current Gem boxes:"
|
|
31
|
+
Dir.foreach("#{ENV['HOME']}/.gembox") do |file|
|
|
32
|
+
puts " - #{file}" if file !~ /^\./
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.delete(args)
|
|
37
|
+
box_name = args.shift
|
|
38
|
+
@dir = "#{ENV['HOME']}/.gembox/#{box_name}"
|
|
39
|
+
if File.exists?(@dir)
|
|
40
|
+
FileUtils.rm_r(@dir)
|
|
41
|
+
puts "Gem box #{box_name} has been deleted"
|
|
42
|
+
else
|
|
43
|
+
puts "Gem box #{box_name} does not exists"
|
|
44
|
+
end
|
|
29
45
|
end
|
|
30
46
|
|
|
31
47
|
def self.shell(args)
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
box_name = args.shift
|
|
49
|
+
@dir = "#{ENV['HOME']}/.gembox/#{box_name}"
|
|
50
|
+
if File.exists?(@dir)
|
|
51
|
+
generate_gems_yaml("#{@dir}/gems.yaml")
|
|
52
|
+
system("sh #{@dir}/shell.bash")
|
|
53
|
+
else
|
|
54
|
+
puts "Box #{box_name} does not exist"
|
|
55
|
+
end
|
|
34
56
|
end
|
|
35
57
|
|
|
36
58
|
private
|
|
37
59
|
|
|
38
|
-
def self.generate_gems_yaml
|
|
60
|
+
def self.generate_gems_yaml(file)
|
|
39
61
|
data = `gem query -d`.split("\n")
|
|
40
62
|
gemdata = {}
|
|
41
63
|
index = 'NULL'
|
|
@@ -61,7 +83,7 @@ class Gembox
|
|
|
61
83
|
end
|
|
62
84
|
end
|
|
63
85
|
end
|
|
64
|
-
File.open(
|
|
86
|
+
File.open(file, "w") { |f| f.puts gemdata.to_yaml }
|
|
65
87
|
end
|
|
66
88
|
|
|
67
89
|
def load_config
|
data/lib/templates/bashrc
CHANGED