diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 1cdf8c7b..04562dc2 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -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 diff --git a/test/test_language.rb b/test/test_language.rb index c4830691..e93cbd5d 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -368,6 +368,9 @@ class TestLanguage < Test::Unit::TestCase assert !Language['Ruby'].eql?(Language['Python']) end + def test_by_type + assert_equal 6, Language.by_type(:prose).length + end def test_colorize assert_equal <<-HTML.chomp, Language['Ruby'].colorize("def foo\n 'foo'\nend\n")