Skip to content

Commit

Permalink
Make metadata lookup case insensitive.
Browse files Browse the repository at this point in the history
  • Loading branch information
gma committed Sep 12, 2011
1 parent 104c8ea commit 238a0a2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/nesta/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class FileModel

attr_reader :filename, :mtime

class CaseInsensitiveHash < Hash
def [](key)
super(key.to_s.downcase)
end
end

def self.model_path(basename = nil)
Nesta::Config.content_path(basename)
end
Expand Down Expand Up @@ -130,7 +136,7 @@ def parse_file
raise Sinatra::NotFound
else
first_paragraph, remaining = contents.split(/\r?\n\r?\n/, 2)
metadata = {}
metadata = CaseInsensitiveHash.new
if metadata?(first_paragraph)
first_paragraph.split("\n").each do |line|
key, value = line.split(/\s*:\s*/, 2)
Expand Down

0 comments on commit 238a0a2

Please sign in to comment.