Skip to content

Commit f5c807f

Browse files
scopgabriel-vasile
authored andcommitted
ruby: add support
1 parent 9e0c823 commit f5c807f

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

internal/magic/text.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ var (
109109
[]byte("/usr/local/bin/python"),
110110
[]byte("/usr/bin/env python"),
111111
)
112+
// Ruby matches a Ruby programming language file.
113+
Ruby = shebang(
114+
[]byte("/usr/bin/ruby"),
115+
[]byte("/usr/local/bin/ruby"),
116+
[]byte("/usr/bin/env ruby"),
117+
)
112118
// Tcl matches a Tcl programming language file.
113119
Tcl = shebang(
114120
[]byte("/usr/bin/tcl"),

mimetype_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ a,"b`,
234234
{"py", "#!/usr/bin/python", "text/x-python", one},
235235
{"qcp", "RIFF\xc0\xcf\x00\x00QLCMf", "audio/qcelp", one},
236236
{"rar", "Rar!\x1a\x07\x01\x00", "application/x-rar-compressed", all},
237+
{"rb", "#!/usr/local/bin/ruby", "text/x-ruby", one},
237238
{"rmvb", ".RMF", "application/vnd.rn-realmedia-vbr", one},
238239
{"rpm", "\xed\xab\xee\xdb", "application/x-rpm", one},
239240
{"rss", "\x3c\x3f\x78\x6d\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\x30\x22\x20\x65\x6e\x63\x6f\x64\x69\x6e\x67\x3d\x22\x55\x54\x46\x2d\x38\x22\x3f\x3e\x0a\x3c\x72\x73\x73", "application/rss+xml", one},

supported_mimes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 183 Supported MIME types
1+
## 184 Supported MIME types
22
This file is automatically generated when running tests. Do not edit manually.
33

44
Extension | MIME type | Aliases
@@ -171,6 +171,7 @@ Extension | MIME type | Aliases
171171
**.lua** | text/x-lua | -
172172
**.pl** | text/x-perl | -
173173
**.py** | text/x-python | text/x-script.python, application/x-python
174+
**.rb** | text/x-ruby | application/x-ruby
174175
**.json** | application/json | -
175176
**.geojson** | application/geo+json | -
176177
**.har** | application/json | -

tree.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var (
8181
alias("application/x-ogg")
8282
oggAudio = newMIME("audio/ogg", ".oga", magic.OggAudio)
8383
oggVideo = newMIME("video/ogg", ".ogv", magic.OggVideo)
84-
text = newMIME("text/plain", ".txt", magic.Text, svg, html, xml, php, js, lua, perl, python, json, ndJSON, rtf, srt, tcl, csv, tsv, vCard, iCalendar, warc, vtt, shell)
84+
text = newMIME("text/plain", ".txt", magic.Text, svg, html, xml, php, js, lua, perl, python, ruby, json, ndJSON, rtf, srt, tcl, csv, tsv, vCard, iCalendar, warc, vtt, shell)
8585
xml = newMIME("text/xml", ".xml", magic.XML, rss, atom, x3d, kml, xliff, collada, gml, gpx, tcx, amf, threemf, xfdf, owl2, xhtml).
8686
alias("application/xml")
8787
xhtml = newMIME("application/xhtml+xml", ".html", magic.XHTML)
@@ -103,6 +103,8 @@ var (
103103
perl = newMIME("text/x-perl", ".pl", magic.Perl)
104104
python = newMIME("text/x-python", ".py", magic.Python).
105105
alias("text/x-script.python", "application/x-python")
106+
ruby = newMIME("text/x-ruby", ".rb", magic.Ruby).
107+
alias("application/x-ruby")
106108
shell = newMIME("text/x-shellscript", ".sh", magic.Shell).
107109
alias("text/x-sh", "application/x-shellscript", "application/x-sh")
108110
tcl = newMIME("text/x-tcl", ".tcl", magic.Tcl).

0 commit comments

Comments
 (0)