lib/spandex/page.rb in spandex-0.0.3 vs lib/spandex/page.rb in spandex-0.0.4
- old
+ new
@@ -22,12 +22,12 @@
paths = Pathname.glob(File.join(base_path, "#{path}.*"))
pathname = paths.select{|path| registered?(path)}.first
end
def self.path_from_file(pathname, base_path)
- pathname = pathify(pathname)
- pathname.relative_path_from(pathify(base_path)).sub_ext('')
+ pathname = pathify pathname
+ pathify pathname.relative_path_from(pathify(base_path)).sub_ext('')
end
def self.registered?(pathname)
pathname = pathify(pathname)
Tilt.registered?(pathname.extname.sub(/^./, ''))
@@ -81,11 +81,11 @@
end
nil
end
def self.pathify(path_or_string)
- path_or_string.is_a?(String) ? Pathname.new(fix_path path_or_string) : path_or_string
+ fix_path path_or_string.is_a?(String) ? Pathname.new(path_or_string) : path_or_string
end
def self.parse_file(filename)
def self.metadata?(text)
text.split("\n").first =~ /^[\w ]+:/
@@ -104,9 +104,10 @@
markup = metadata?(first_paragraph) ? remaining : contents
return metadata, markup
end
def self.fix_path(path)
+ path = "/#{path}" unless path.to_s.match(/^\//)
path.sub(/\/$/, '')
end
end
end