Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mimemagic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
mimemagic
Commits
061caddb
Commit
061caddb
authored
Jan 23, 2011
by
minad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code cleanup
parent
bbe2490f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
lib/mimemagic.rb
+5
-5
No files found.
lib/mimemagic.rb
View file @
061caddb
...
@@ -36,7 +36,7 @@ class MimeMagic
...
@@ -36,7 +36,7 @@ class MimeMagic
# * <i>type</i>: The mime type to remove. All associated extensions and magic are removed too.
# * <i>type</i>: The mime type to remove. All associated extensions and magic are removed too.
def
self
.
remove
(
type
)
def
self
.
remove
(
type
)
EXTENSIONS
.
delete_if
{
|
ext
,
t
|
t
==
type
}
EXTENSIONS
.
delete_if
{
|
ext
,
t
|
t
==
type
}
MAGIC
.
delete_if
{
|
t
,
m
|
t
==
type
}
MAGIC
.
delete_if
{
|
t
,
m
|
t
==
type
}
TYPES
.
delete
(
type
)
TYPES
.
delete
(
type
)
end
end
...
@@ -50,7 +50,7 @@ class MimeMagic
...
@@ -50,7 +50,7 @@ class MimeMagic
# Returns true if type is child of parent type
# Returns true if type is child of parent type
def
child_of?
(
parent
)
def
child_of?
(
parent
)
child?
(
type
,
parent
)
MimeMagic
.
child?
(
type
,
parent
)
end
end
# Get string list of file extensions
# Get string list of file extensions
...
@@ -67,7 +67,7 @@ class MimeMagic
...
@@ -67,7 +67,7 @@ class MimeMagic
def
self
.
by_extension
(
ext
)
def
self
.
by_extension
(
ext
)
ext
=
ext
.
to_s
.
downcase
ext
=
ext
.
to_s
.
downcase
mime
=
ext
[
0
..
0
]
==
'.'
?
EXTENSIONS
[
ext
[
1
..-
1
]]
:
EXTENSIONS
[
ext
]
mime
=
ext
[
0
..
0
]
==
'.'
?
EXTENSIONS
[
ext
[
1
..-
1
]]
:
EXTENSIONS
[
ext
]
mime
?
new
(
mime
)
:
nil
mime
&&
new
(
mime
)
end
end
# Lookup mime type by filename
# Lookup mime type by filename
...
@@ -82,7 +82,7 @@ class MimeMagic
...
@@ -82,7 +82,7 @@ class MimeMagic
io
=
StringIO
.
new
(
io
.
to_s
,
'rb:binary'
)
io
=
StringIO
.
new
(
io
.
to_s
,
'rb:binary'
)
end
end
mime
=
MAGIC
.
find
{
|
type
,
matches
|
magic_match
(
io
,
matches
)
}
mime
=
MAGIC
.
find
{
|
type
,
matches
|
magic_match
(
io
,
matches
)
}
mime
?
new
(
mime
[
0
])
:
nil
mime
&&
new
(
mime
[
0
])
end
end
# Return type as string
# Return type as string
...
@@ -97,7 +97,7 @@ class MimeMagic
...
@@ -97,7 +97,7 @@ class MimeMagic
private
private
def
child?
(
child
,
parent
)
def
self
.
child?
(
child
,
parent
)
child
==
parent
||
TYPES
.
key?
(
child
)
&&
TYPES
[
child
][
1
].
any?
{
|
p
|
child?
(
p
,
parent
)
}
child
==
parent
||
TYPES
.
key?
(
child
)
&&
TYPES
[
child
][
1
].
any?
{
|
p
|
child?
(
p
,
parent
)
}
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment