mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Initialize breakdown hash
This commit is contained in:
@@ -6,7 +6,7 @@ We use this library at GitHub to detect blob languages, highlight code, ignore b
|
|||||||
|
|
||||||
### Language detection
|
### Language detection
|
||||||
|
|
||||||
Linguist defines the list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). In order for a file to be highlighted, a language and lexer must be defined there.
|
Linguist defines a list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). In order for a file to be highlighted, a language and lexer must be defined there.
|
||||||
|
|
||||||
Most languages are detected by their file extension. This is the fastest and most common situation.
|
Most languages are detected by their file extension. This is the fastest and most common situation.
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ module Linguist
|
|||||||
@computed_stats = false
|
@computed_stats = false
|
||||||
@language = @size = nil
|
@language = @size = nil
|
||||||
@sizes = Hash.new { 0 }
|
@sizes = Hash.new { 0 }
|
||||||
@file_breakdown = {}
|
@file_breakdown = Hash.new { |h,k| h[k] = Array.new }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Returns a breakdown of language stats.
|
# Public: Returns a breakdown of language stats.
|
||||||
@@ -83,12 +83,8 @@ module Linguist
|
|||||||
# Only include programming languages and acceptable markup languages
|
# Only include programming languages and acceptable markup languages
|
||||||
if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name)
|
if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name)
|
||||||
|
|
||||||
# Build up the per-file breakdown stats if asked
|
# Build up the per-file breakdown stats
|
||||||
if @file_breakdown[blob.language.group.name]
|
@file_breakdown[blob.language.group.name] << blob.name
|
||||||
@file_breakdown[blob.language.group.name] << blob.name
|
|
||||||
else
|
|
||||||
@file_breakdown[blob.language.group.name] = [blob.name]
|
|
||||||
end
|
|
||||||
|
|
||||||
@sizes[blob.language.group] += blob.size
|
@sizes[blob.language.group] += blob.size
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user