lib/brief/repository.rb in brief-1.7.2 vs lib/brief/repository.rb in brief-1.7.3
- old
+ new
@@ -21,10 +21,15 @@
end
def method_missing(meth, *args, &block)
in_model_group = model_groups.include?(meth.to_s)
+ if options[:caching] == false || options[:cache] == false
+ @all_models = nil
+ @all_models_by_type = nil
+ end
+
if in_model_group && args.empty?
find_models_by_type(meth)
elsif in_model_group && !args.empty?
group = find_models_by_type(meth)
Brief::DocumentMapper::Query.new(group).send(:where, *args)
@@ -50,12 +55,18 @@
def documents_at!(*paths)
documents_at(*paths).select {|doc| doc.path.exist? }
end
+ InvalidPath = Class.new(Exception)
+
def normalize_path(p)
- docs_path.join(p)
+ docs_path.join(p).tap do |normalized|
+ if normalized.to_s.split("/").length < docs_path.realpath.to_s.split("/").length
+ raise InvalidPath
+ end
+ end
end
def documents_at(*paths)
paths.compact!
@@ -94,10 +105,10 @@
Brief::Document.new(path).in_briefcase(briefcase)
end
end
def document_paths
- Dir[root.join('**/*.md').to_s].map { |p| Pathname(p) }
+ Dir[docs_path.join('**/*.md').to_s].map { |p| Pathname(p) }
end
def all_models
@all_models ||= begin
list = documents.select(&:refresh!).map(&:to_model)