lib/sprout/tasks/asdoc_task.rb in sprout-as3-bundle-0.2.9 vs lib/sprout/tasks/asdoc_task.rb in sprout-as3-bundle-1.0.8
- old
+ new
@@ -225,11 +225,17 @@
The default value is "API Documentation".
EOF
end
end
+ def exclude_expressions
+ @exclude_expressions ||= []
+ end
+
def define # :nodoc:
+ apply_exclusions_from_expression unless @exclude_expressions.nil?
+
super
validate_templates
CLEAN.add(output)
end
@@ -246,21 +252,21 @@
library_path << path
end
end
end
end
-
+
protected
def validate_templates
if(templates_path.size == 0)
templates_dir = Sprout.get_executable(gem_name, 'asdoc/templates', gem_version)
templates_dir = templates_dir.split('.exe').join('')
templates_path << templates_dir
end
end
-
+
def execute(*args)
update_helper_mode
begin
super
rescue ExecutionError => e
@@ -287,9 +293,34 @@
if(path.match(/.swc$/))
library_path << library_task.project_path
else
source_path << library_task.project_path
end
+ end
+
+ # Requires that @exclude_expressions is not nil.
+ def apply_exclusions_from_expression
+ FileList[@exclude_expressions].each do |file_path|
+ import_file = remove_source_path_from_file_path(file_path) || file_path
+ import_class = filename_to_import_class(import_file)
+
+ exclude_classes << import_class unless import_class.nil?
+ end
+ end
+
+ def remove_source_path_from_file_path(file)
+ source_path.each do |source_dir|
+ import_file = file.sub(Regexp.new("^#{source_dir}"),"")
+ return import_file if import_file != file
+ end
+
+ return file
+ end
+
+ def filename_to_import_class(filename)
+ name = filename.scan(/\w+/)
+ # Ignore the AS file extension.
+ name[0..-2].join('.') unless name[-1] != 'as'
end
end
end