lib/batcave/dsl.rb in batcave-0.0.5 vs lib/batcave/dsl.rb in batcave-0.0.6
- old
+ new
@@ -94,11 +94,12 @@
# * yield "/foo/bar/one"
# * yield "/foo/bar/two"
#
# A {foo} will check both @foo and @foos
def expand(paths, &block)
- skip_re = /(^|\/)\.(\.|git|svn)/
+ # Skip .svn and .git directories
+ skip_re = %r{(^|/)\.(\.|git|svn)(/|$)}
paths.each do |path|
next if skip_re.match(path)
# find all {...} in the string
tokens = path.scan(/{[^}]+}/)
if tokens.include?("{name}")
@@ -141,10 +142,11 @@
@logger.error("Can't sync, no source defined")
return
end
paths = Dir.glob(File.join(@sourcedir, "**", "*"), File::FNM_DOTMATCH)
+
expand(paths) do |source, target|
next if source == @configfile # skip the 'THING' file
originalpath = source[@sourcedir.length + 1 .. -1]
localpath = File.join(path(@environment), target[@sourcedir.length + 1 .. -1])
@@ -154,11 +156,9 @@
use_erb = true
else
use_erb = false
end
- # TODO(sissel): if this is a directory, create it.
- # TODO(sissel): if this a file, copy it.
if File.directory?(source)
FileUtils.mkdir_p(localpath) unless File.directory?(localpath)
else
localdir = File.dirname(localpath)
FileUtils.mkdir_p(localdir) unless File.directory?(localdir)