Initialize breakdown hash

This commit is contained in:
Ted Nyman
2013-12-29 02:54:15 -08:00
parent 9dc7329601
commit cdf6fb4a22
2 changed files with 4 additions and 8 deletions

View File

@@ -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.

View File

@@ -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