toastyapps-gembox 1.3.4 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gembox.rb +24 -3
- data/lib/templates/gemrc +1 -1
- metadata +1 -1
data/lib/gembox.rb
CHANGED
@@ -3,7 +3,8 @@ require 'yaml'
|
|
3
3
|
require 'erb'
|
4
4
|
|
5
5
|
class Gembox
|
6
|
-
VERSION = '1.3.
|
6
|
+
VERSION = '1.3.6'
|
7
|
+
DEFAULTS = {'nodoc' => true, 'sources' => []}
|
7
8
|
attr_accessor :dir, :cfg, :box_name
|
8
9
|
|
9
10
|
def initialize
|
@@ -59,6 +60,7 @@ class Gembox
|
|
59
60
|
box_name = args.shift
|
60
61
|
@dir = "#{ENV['HOME']}/.gembox/#{box_name}"
|
61
62
|
if File.exists?(@dir)
|
63
|
+
generate_gem_yaml("#{@dir}/gem.yaml")
|
62
64
|
generate_gems_yaml("#{@dir}/gems.yaml")
|
63
65
|
system("sh #{@dir}/shell.bash")
|
64
66
|
else
|
@@ -67,6 +69,25 @@ class Gembox
|
|
67
69
|
end
|
68
70
|
|
69
71
|
private
|
72
|
+
|
73
|
+
def generate_gem_yaml(file)
|
74
|
+
data = `gem env`.split("\n")
|
75
|
+
config = {'gem_paths' => []}
|
76
|
+
lines = data.strip.split("\n")
|
77
|
+
lines.each_with_index do |line, i|
|
78
|
+
if line.match(/EXECUTABLE DIRECTORY:/)
|
79
|
+
config['executable_directory'] = line.match(/:\s(.*)/).captures[0]
|
80
|
+
elsif line.match(/GEM PATHS/)
|
81
|
+
j = i + 1
|
82
|
+
while !lines[j].match(/GEM CONFIGURATION/)
|
83
|
+
config['gem_paths'] << lines[j].match(/-\s(.*)/).captures[0]
|
84
|
+
j += 1
|
85
|
+
end
|
86
|
+
break
|
87
|
+
end
|
88
|
+
end
|
89
|
+
File.open(file, "w") { |f| f.puts config.to_yaml }
|
90
|
+
end
|
70
91
|
|
71
92
|
def generate_gems_yaml(file)
|
72
93
|
data = `gem query -d`.split("\n")
|
@@ -98,11 +119,11 @@ class Gembox
|
|
98
119
|
end
|
99
120
|
|
100
121
|
def load_config
|
101
|
-
@cfg = load_yaml(@cfg_path)
|
122
|
+
@cfg = DEFAULTS.merge(load_yaml(@cfg_path))
|
102
123
|
end
|
103
124
|
|
104
125
|
def load_yaml path
|
105
|
-
File.exists?(path) ? YAML.load(File.open(path)) :
|
126
|
+
File.exists?(path) ? YAML.load(File.open(path)) : {}
|
106
127
|
end
|
107
128
|
|
108
129
|
def method_missing(method, args)
|
data/lib/templates/gemrc
CHANGED