From c05717d15ce8fb7f9d8bfef5e1f101ef487bd0f3 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Fri, 28 Nov 2014 12:27:48 -0600 Subject: [PATCH] docs --- lib/linguist/shebang.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/linguist/shebang.rb b/lib/linguist/shebang.rb index 6181d98f..7fa021cc 100644 --- a/lib/linguist/shebang.rb +++ b/lib/linguist/shebang.rb @@ -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)