Class: Assets
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
#initialize ⇒ Assets
Returns a new instance of Assets.
5
6
7
8
|
# File 'lib/zarchitect/assets.rb', line 5
def initialize
@from = ASSETDIR
@to = File.join(HTMLDIR, ASSETSDIR)
end
|
Instance Method Details
#copy_file(a, b) ⇒ Object
45
46
47
48
|
# File 'lib/zarchitect/assets.rb', line 45
def copy_file(a, b)
GPI.print "Copying from #{a} to #{b}.", GPI::CLU.check_option('v')
File.copy(a, b)
end
|
#cpdirs ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/zarchitect/assets.rb', line 32
def cpdirs
Dir[ File.join(@from, '**', '*') ].reject do |fullpath|
path = fullpath[(@from.length)..-1]
if path.include?(HTMLDIR)
realpath = path[1..-1]
else
realpath = File.join(@to, path)
Util.mkdir(realpath) if File.directory?(fullpath)
end
end
end
|
#update ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/zarchitect/assets.rb', line 10
def update
Dir[ File.join(@from, '**', '*') ].reject do |fullpath|
path = fullpath[(@from.length)..-1]
if path.include?(HTMLDIR)
realpath = path[1..-1]
else
realpath = File.join(@to, path)
Util.mkdir(realpath) if File.directory?(fullpath)
end
next if File.directory?(fullpath)
if File.exist?(realpath)
if File.stat(fullpath).mtime > File.stat(realpath).mtime
copy_file(fullpath, realpath)
end
else
copy_file(fullpath, realpath)
end
end
end
|