Class: Stool::Command::LibPool::Add
Instance Method Summary
collapse
existLocalAndClone, pools_from_config
#checkConfigFile, options, #pp
Constructor Details
#initialize(argv) ⇒ Add
def self.options
[
['--progress', 'Show the progress of cloning the spec repository'],
].concat(super)
end
25
26
27
28
29
30
31
|
# File 'lib/stool/Command/LibPool/Add.rb', line 25
def initialize(argv)
puts 'Add --- init'
@pInfo.name = argv.shift_argument
@pInfo.path = argv.shift_argument
super
end
|
Instance Method Details
#cachePath ⇒ Object
86
87
88
89
|
# File 'lib/stool/Command/LibPool/Add.rb', line 86
def cachePath
path = "#{@@PathForCache + @name + '.yaml'}"
path.to_s
end
|
#doCacheByYamlToPath(cacheDirPath, fileName) ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/stool/Command/LibPool/Add.rb', line 76
def doCacheByYamlToPath(cacheDirPath,fileName)
puts "....do cache to #{cacheDirPath}"
unless File::exists?(cacheDirPath)
Dir.mkdir(cacheDirPath,0777)
end
File.open(File.join(cacheDirPath,fileName) + '.yaml', "w") { |file|
YAML.dump(self, file)
}
end
|
#hadCached? ⇒ Boolean
66
67
68
69
70
71
72
73
74
|
# File 'lib/stool/Command/LibPool/Add.rb', line 66
def hadCached?
puts "@PathForCache = #{@@PathForCache}"
puts "@name = #{@name}"
obj = nil
if File.exist?(self.cachePath)
obj = YAML::load(File.open(self.cachePath))
end
end
|
#run ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/stool/Command/LibPool/Add.rb', line 46
def run
puts 'Add --- run'
obj = hadCached?
if obj
obj.path = @path
else
doCacheByYamlToPath(@@PathForCache,@name)
end
end
|
#validate! ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/stool/Command/LibPool/Add.rb', line 33
def validate!
super
puts 'Add --- validate!'
unless @pInfo.name && @pInfo.path
help! 'Adding a libPool needs a `NAME` and a `PATH`.'
end
unless File.exist?(@path)
raise Informative,
'To add a pool, please give a ensure the path of folder is exist.'
end
end
|