16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/m2config/mimetype.rb', line 16
def self.populate_table(types=nil, ignoreDoubles=false)
raise RuntimeError, "Table must be empty" if db[:mimetype].count > 0
types ||= MIME::Types
rows = []
types.each {
|type|
next if not_dominant?(type)
type.extensions.each {
|ext|
ext = "."+ext
clashingType = M2Config::MimeType[extension:ext]
raise ArgumentError, "extension #{ext} is already covered by #{clashingType.mimetype} type" if clashingType
rows << [type.content_type, ext]
}
}
db.transaction {
db[:mimetype].import([:mimetype, :extension], rows)
}
remove_duplicates unless ignoreDoubles
end
|