lib/lookbook/support/utils/path_utils.rb in lookbook-1.5.5 vs lib/lookbook/support/utils/path_utils.rb in lookbook-2.0.0.beta.0
- old
+ new
@@ -13,11 +13,11 @@
file_name = File.basename(path).split(".").first
segments = [*directory_path&.split("/"), file_name].compact
stripped_segments = segments.map! do |segment|
- PositionPrefixParser.call(segment).last.tr("-", "_")
+ PriorityPrefixParser.call(segment).last.tr("-", "_")
end
to_path(stripped_segments)
end
@@ -38,9 +38,15 @@
Rails.application.root.to_s == path.to_s
end
def strip_slashes(path)
path.to_s.gsub(/\A\/|\/\z/, "")
+ end
+
+ def determine_full_path(rel_path, search_dirs = [])
+ base_path = search_dirs.detect { |p| Dir["#{p}/#{rel_path}"].first }
+ path = Dir["#{base_path}/#{rel_path}"].first
+ Pathname(path) if path
end
end
end
end