remove trailing white-spaces from lib/redmine/mime_type.rb
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7406 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
03c6fb1b9d
commit
58563b4bcb
@ -1,16 +1,16 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -62,36 +62,36 @@ module Redmine
|
|||||||
'application/zip' => 'zip',
|
'application/zip' => 'zip',
|
||||||
'application/x-gzip' => 'gz',
|
'application/x-gzip' => 'gz',
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
|
EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
|
||||||
exts.split(',').each {|ext| map[ext.strip] = type}
|
exts.split(',').each {|ext| map[ext.strip] = type}
|
||||||
map
|
map
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns mime type for name or nil if unknown
|
# returns mime type for name or nil if unknown
|
||||||
def self.of(name)
|
def self.of(name)
|
||||||
return nil unless name
|
return nil unless name
|
||||||
m = name.to_s.match(/(^|\.)([^\.]+)$/)
|
m = name.to_s.match(/(^|\.)([^\.]+)$/)
|
||||||
EXTENSIONS[m[2].downcase] if m
|
EXTENSIONS[m[2].downcase] if m
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the css class associated to
|
# Returns the css class associated to
|
||||||
# the mime type of name
|
# the mime type of name
|
||||||
def self.css_class_of(name)
|
def self.css_class_of(name)
|
||||||
mime = of(name)
|
mime = of(name)
|
||||||
mime && mime.gsub('/', '-')
|
mime && mime.gsub('/', '-')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.main_mimetype_of(name)
|
def self.main_mimetype_of(name)
|
||||||
mimetype = of(name)
|
mimetype = of(name)
|
||||||
mimetype.split('/').first if mimetype
|
mimetype.split('/').first if mimetype
|
||||||
end
|
end
|
||||||
|
|
||||||
# return true if mime-type for name is type/*
|
# return true if mime-type for name is type/*
|
||||||
# otherwise false
|
# otherwise false
|
||||||
def self.is_type?(type, name)
|
def self.is_type?(type, name)
|
||||||
main_mimetype = main_mimetype_of(name)
|
main_mimetype = main_mimetype_of(name)
|
||||||
type.to_s == main_mimetype
|
type.to_s == main_mimetype
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user