Class: FileManager
Constant Summary
Constants inherited
from Zarchitect
Zarchitect::ASSETDIR, Zarchitect::ASSETSDIR, Zarchitect::BUILDIR, Zarchitect::CONFIGDIR, Zarchitect::DEBUGSDIR, Zarchitect::DRAFTDIR, Zarchitect::FILEDIR, Zarchitect::FILESDIR, Zarchitect::HTMLDIR, Zarchitect::LAYOUTDIR, Zarchitect::NODEDIR, Zarchitect::SHARESDIR, Zarchitect::VERSION
Instance Method Summary
collapse
Methods inherited from Zarchitect
#main, #rss
Constructor Details
Returns a new instance of FileManager.
3
4
5
6
7
8
9
10
11
|
# File 'lib/zarchitect/file_manager.rb', line 3
def initialize
@from = FILEDIR @to = File.join(HTMLDIR, FILESDIR)
@img = Array.new
@audio = Array.new
@video = Array.new
@misc = Array.new
end
|
Instance Method Details
#clean ⇒ Object
59
60
61
62
|
# File 'lib/zarchitect/file_manager.rb', line 59
def clean
%x{rm -r _html/files/*}
end
|
#run ⇒ Object
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
|
# File 'lib/zarchitect/file_manager.rb', line 13
def run
Dir[ File.join(@from, '**', '*') ].reject do |fullpath|
path = fullpath[(@from.length)..-1]
realpath = File.join(@to, path)
Util.mkdir(realpath) if File.directory?(fullpath)
next if File.directory?(fullpath)
if Image.is_valid?(fullpath)
GPI.print "processing #{fullpath} as image file",
GPI::CLU.check_option('v')
@img.push ImageSet.new(path, fullpath, realpath)
elsif Audio.is_valid?(fullpath)
GPI.print "processing #{fullpath} as audio file",
GPI::CLU.check_option('v')
@audio.push Audio.new(fullpath)
elsif Video.is_valid?(fullpath)
GPI.print "processing #{fullpath} as video file",
GPI::CLU.check_option('v')
@video.push Video.new(fullpath)
else
GPI.print "processing #{fullpath} as any file",
GPI::CLU.check_option('v')
@misc.push MiscFile.new(fullpath)
end
unless File.symlink?(realpath)
rrealpath = File.join(Dir.getwd, fullpath)
symlink(rrealpath, realpath)
end
end
end
|
#symlink(from, to) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/zarchitect/file_manager.rb', line 51
def symlink(from, to)
GPI.print "creating symlink #{to} ~> #{from}",
GPI::CLU.check_option('v')
File.symlink(from, to)
GPI.print "created symlink #{to} ~> #{from}",
GPI::CLU.check_option('v')
end
|