10
11
12
13
14
15
16
17
18
19
20
21
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
|
# File 'lib/pakman/fetcher.rb', line 10
def fetch_pak( manifestsrc, pakpath )
start = Time.now
uri = URI.parse( manifestsrc )
logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
dirname = File.dirname( uri.path )
filename = File.basename( uri.path )
pakname = Pakman.pakname_from_file( uri.path )
logger.debug "dirname >#{dirname}<"
logger.debug "filename >#{filename}<"
logger.debug "pakname >#{pakname}<"
dlbase = "#{uri.scheme}://#{uri.host}:#{uri.port}#{dirname}"
logger.debug "dlbase: #{dlbase}"
logger.debug "pakpath: #{pakpath}"
FileUtils.makedirs( pakpath ) unless File.directory?( pakpath )
puts "Fetching template pack '#{pakname}'"
puts " from '#{dlbase}'"
puts " saving to '#{pakpath}'"
manifestdest = "#{pakpath}/#{filename}"
puts " Downloading manifest '#{filename}'..."
fetch_file( manifestsrc, manifestdest )
manifest = Manifest.load_file_core_v2( manifestdest )
manifest.each do |entry|
source = entry[1]
destfull = File.expand_path( source, pakpath ) destpath = File.dirname( destfull )
FileUtils.makedirs( destpath ) unless File.directory?( destpath )
logger.debug "destfull=>#{destfull}<"
logger.debug "destpath=>#{destpath}<"
sourcefull = "#{dlbase}/#{source}"
if source =~ /\.erb\.|.erb$/
puts " Downloading template '#{source}'..."
else
puts " Downloading file '#{source}'..."
end
fetch_file( sourcefull, destfull )
end
puts "Done (in #{Time.now-start} s)."
end
|