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
42038856
Commit
42038856
authored
Jul 29, 2013
by
Daniel Mendler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve table generator
parent
66c3c660
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
lib/mimemagic/tables.rb
+0
-0
script/generate-mime.rb
+13
-3
No files found.
lib/mimemagic/tables.rb
View file @
42038856
This source diff could not be displayed because it is too large. You can
view the blob
instead.
script/generate-mime.rb
View file @
42038856
#!/usr/bin/ruby
gem
'nokogiri'
,
'>= 0'
require
'nokogiri'
class
String
alias
inspect_old
inspect
def
inspect
x
=
b
.
inspect_old
.
gsub
(
/\\x([0-9a-f]{2})/i
)
do
'\\%03o'
%
$1
.
to_i
(
16
)
end
x
=~
/[\\']/
?
x
:
x
.
gsub
(
'"'
,
'\''
)
end
end
def
str2int
(
s
)
return
s
.
to_i
(
16
)
if
s
[
0
..
1
].
downcase
==
'0x'
return
s
.
to_i
(
8
)
if
s
[
0
..
0
].
downcase
==
'0'
...
...
@@ -61,7 +71,7 @@ extensions = {}
types
=
{}
magics
=
[]
(
doc
/
'mime-info/mime-type'
).
each
do
|
mime
|
comments
=
Hash
[
*
(
mime
/
'comment'
).
map
{
|
comment
|
[
comment
[
'lang'
],
comment
.
inner_text
]
}.
flatten
]
comments
=
Hash
[
*
(
mime
/
'comment'
).
map
{
|
comment
|
[
comment
[
'
xml:
lang'
],
comment
.
inner_text
]
}.
flatten
]
type
=
mime
[
'type'
]
subclass
=
(
mime
/
'sub-class-of'
).
map
{
|
x
|
x
[
'type'
]}
exts
=
(
mime
/
'glob'
).
map
{
|
x
|
x
[
'pattern'
]
=~
/^\*\.([^\[\]]+)$/
?
$1
.
downcase
:
nil
}.
compact
...
...
@@ -97,7 +107,7 @@ types.keys.sort.each do |key|
end
puts
" }"
puts
" MAGIC = ["
magics
.
each
do
|
type
,
matches
|
magics
.
sort
.
each
do
|
type
,
matches
|
puts
" ['
#{
type
}
',
#{
matches
.
inspect
}
],"
end
puts
" ]"
...
...
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