mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	docs
This commit is contained in:
		| @@ -1,10 +1,22 @@ | ||||
| module Linguist | ||||
|   # Check if there's a shebang line and use that as authoritative | ||||
|   class Shebang | ||||
|     def self.call(blob, _) | ||||
|     # Public: Use shebang to detect language of the blob. | ||||
|     # | ||||
|     # blob               - An object that quacks like a blob. | ||||
|     # | ||||
|     # Examples | ||||
|     # | ||||
|     #   Shebang.call(FileBlob.new("path/to/file")) | ||||
|     # | ||||
|     # Returns an Array with one Language if the blob has a shebang with a valid | ||||
|     # interpreter, or empty if there is no shebang. | ||||
|     def self.call(blob, _ = nil) | ||||
|       Language.find_by_interpreter interpreter(blob.data) | ||||
|     end | ||||
|  | ||||
|     # Public: Get the interpreter from the shebang | ||||
|     # | ||||
|     # Returns a String or nil | ||||
|     def self.interpreter(data) | ||||
|       lines = data.lines | ||||
|       return unless match = /^#! ?(.*)$/.match(lines.first) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user