Add helper method to retrieve languages by type

This commit is contained in:
Garen Torikian
2013-12-08 16:12:03 -08:00
parent a825a013d6
commit ee519aeb4b
2 changed files with 13 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ module Linguist
@primary_extension_index = {}
# Valid Languages types
TYPES = [:data, :markup, :programming]
TYPES = [:data, :markup, :programming, :prose]
# Names of non-programming languages that we will still detect
#
@@ -35,6 +35,15 @@ module Linguist
["CSS", "Less", "Sass", "TeX"]
end
# Detect languages by a specific type
#
# type - A symbol that exists within TYPES
#
# Returns an array
def self.by_type(type)
all.select { |h| h.type == type }
end
# Internal: Create a new Language object
#
# attributes - A hash of attributes