lib/gumdrop/build.rb in gumdrop-0.5.1 vs lib/gumdrop/build.rb in gumdrop-0.5.2
- old
+ new
@@ -34,10 +34,11 @@
node= Content.new(file_path)
path= node.to_s
# Sort out Layouts, Generators, and Partials
if File.extname(path) == ".template"
+ Gumdrop.layouts[path]= node
Gumdrop.layouts[File.basename(path)]= node
elsif File.extname(path) == ".generator"
Gumdrop.generators[File.basename(path)]= Generator.new( node )
@@ -60,14 +61,15 @@
Gumdrop.generators.each_pair do |path, generator|
generator.execute()
end
end
+ # Expunge blacklisted files
def filter_tree
- Gumdrop.blacklist.each do |skip_path|
+ Gumdrop.blacklist.each do |blacklist_pattern|
Gumdrop.site.keys.each do |source_path|
- if source_path.starts_with? skip_path
+ if path_match source_path, blacklist_pattern
Gumdrop.report "-excluding: #{source_path}", :info
Gumdrop.site.delete source_path
end
end
end
@@ -76,11 +78,11 @@
def render
unless opts[:dry_run]
output_base_path= File.expand_path(Gumdrop.config.output_dir)
Gumdrop.report "[Compiling to #{output_base_path}]", :info
Gumdrop.site.keys.sort.each do |path|
- unless Gumdrop.greylist.any? {|p| path.starts_with?(p) }
+ unless Gumdrop.greylist.any? {|pattern| path_match path, pattern }
node= Gumdrop.site[path]
output_path= File.join(output_base_path, node.to_s)
FileUtils.mkdir_p File.dirname(output_path)
node.renderTo output_path, Gumdrop.content_filters
else
@@ -95,9 +97,15 @@
run_generators()
filter_tree()
render()
self
end
+
+ # Match a path using a glob-like file pattern
+ def path_match(path, pattern)
+ File.fnmatch pattern, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_CASEFOLD
+ end
+
class << self
def run(root, src, opts={})
new(root, src, opts).run()
end
\ No newline at end of file