22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/drakkon/lib/version.rb', line 22
def self.install!(raw)
if raw.nil? || raw.empty?
LogBot.fatal('Version', 'No Zip Provided!')
file = prompt.ask('Full path to DragonRuby Zip?')
unless File.exist?(file)
LogBot.fatal('Version', 'Not able to find zip!')
exit(1)
end
raw = [file]
end
zip = raw.first
if zip.nil? || File.extname(zip) != '.zip'
LogBot.fatal('Version', "Invalid Argument! Must be a zip file! '#{zip}'")
exit(1)
end
Dir.mktmpdir('drakkon-sauce-') do |tmp|
Zip::File.open(zip) do |zip_file|
zip_file.each do |entry|
path = File.join(tmp, entry.name)
FileUtils.mkdir_p(File.dirname(path))
next if File.exist?(path)
zip_file.(entry, path)
FileUtils.chmod(entry.unix_perms, path)
end
end
dr_dir = Dir["#{tmp}/*"].first
unless dr_dir.include?('dragonruby-')
LogBot.fatal('Version', "Valid Zip? Not finding DragonRuby Directory, #{dr_dir}")
exit(2)
end
unless File.exist?("#{dr_dir}/CHANGELOG-CURR.txt")
LogBot.fatal('Version', "Version File Missing! #{"#{dr_dir}/CHANGELOG-CURR.txt"}")
exit(2)
end
dr_version = File.open("#{dr_dir}/CHANGELOG-CURR.txt", &:readline)&.chomp&.split(' ', 2)&.last
if dr_version.nil?
LogBot.fatal('Version', "Unable to find DragonRuby Version!, #{dr_version}")
exit(2)
end
if Hub.version?(dr_version)
LogBot.fatal('Version', "Version already exists!, #{dr_version}")
exit(3)
end
FileUtils.cp_r(dr_dir, "#{Hub.dir}/#{dr_version}/")
Hub.version_add(dr_version)
LogBot.info('Version', "#{dr_version} Installed!")
end
end
|