mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
* origin/master: (165 commits) Add F# and GLSL samples. Add Forth and GLSL extension .fs. Add heuristic to disambiguate between F#, Forth, and GLSL. byebug requires ruby 2.0 Remove test for removed extension Fix typo in test add rake interpreter add python3 interpreter Remove old wrong_shebang.rb sample Add byebug Link to Lightshow in CONTRIBUTING.md Switch to a better F# grammar Bump Rugged again Checkout the master for testing Rugged 0.22.0b3 Reordering Bump version to 4.0.3 Add some docs for tm_scope Change NONE to none Checking other case for Chart.jS Test that all languages have grammars Fix RHTML's tm_scope ... Conflicts: lib/linguist/language.rb
21 lines
608 B
Ruby
21 lines
608 B
Ruby
module Linguist
|
|
module Strategy
|
|
# Detects language based on filename and/or extension
|
|
class Filename
|
|
def self.call(blob, _)
|
|
name = blob.name.to_s
|
|
|
|
# A bit of an elegant hack. If the file is executable but extensionless,
|
|
# append a "magic" extension so it can be classified with other
|
|
# languages that have shebang scripts.
|
|
extensions = FileBlob.new(name).extensions
|
|
if extensions.empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05
|
|
name += ".script!"
|
|
end
|
|
|
|
Language.find_by_filename(name)
|
|
end
|
|
end
|
|
end
|
|
end
|