Rakefile in mini_mime-0.1.3 vs Rakefile in mini_mime-0.1.4

- old
+ new

@@ -44,16 +44,13 @@ end buffer = [] index.each do |ext, list| - mime_type = nil - list.each do |type| - mime_type = type - break unless type.obsolete? - end - mime_type = list.first if mime_type.obsolete? + mime_type = list.detect { |t| !t.obsolete? } + mime_type ||= list.detect(&:registered) + mime_type ||= list.first buffer << [ext.dup, mime_type.content_type.dup, mime_type.encoding.dup] end pad(buffer) @@ -65,10 +62,24 @@ end end puts "#{buffer.count} rows written to lib/db/ext_mime.db" - buffer.sort!{|a,b| a[1] <=> b[1]} + buffer.sort!{|a,b| [a[1], a[0]] <=> [b[1], b[0]]} + + # strip cause we are going to re-pad + buffer.each do |row| + row.each do |col| + col.strip! + end + end + + # we got to confirm we pick the right extension for each type + buffer.each do |row| + row[0] = MIME::Types.type_for("xyz.#{row[0].strip}")[0].extensions[0].dup + end + + pad(buffer) File.open("lib/db/content_type_mime.db", File::CREAT|File::TRUNC|File::RDWR) do |f| last = nil count = 0 buffer.each do |row|