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
48
49
50
51
|
# File 'lib/zarchitect/assets.rb', line 48
def copy_file(a, b)
GPI.print "Copying from #{a} to #{b}.", GPI::CLU.check_option('v')
File.copy(a, b)
end
|
#cpdirs ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/zarchitect/assets.rb', line 35
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
31
32
33
|
# File 'lib/zarchitect/assets.rb', line 10
def update
Dir.glob(File.join(@from, '**', '*'), File::FNM_DOTMATCH).reject do |fullpath|
path = fullpath[(@from.length)..-1]
next if path[-1] == '.'
next if path.include?('.sass-cache')
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
|