mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Adding all_extensions method to Language
This commit is contained in:
		@@ -427,6 +427,11 @@ module Linguist
 | 
				
			|||||||
    # Returns the extensions Array
 | 
					    # Returns the extensions Array
 | 
				
			||||||
    attr_reader :filenames
 | 
					    attr_reader :filenames
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    # Public: Return all possible extensions for language
 | 
				
			||||||
 | 
					    def all_extensions
 | 
				
			||||||
 | 
					      (extensions + [primary_extension]).uniq
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Public: Get URL escaped name.
 | 
					    # Public: Get URL escaped name.
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    # Examples
 | 
					    # Examples
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,10 +39,7 @@ class TestSamples < Test::Unit::TestCase
 | 
				
			|||||||
  # If a language extension isn't globally unique then make sure there are samples
 | 
					  # If a language extension isn't globally unique then make sure there are samples
 | 
				
			||||||
  def test_presence
 | 
					  def test_presence
 | 
				
			||||||
    Linguist::Language.all.each do |language|
 | 
					    Linguist::Language.all.each do |language|
 | 
				
			||||||
      # TODO - feels like there should be a better way to do this.
 | 
					      language.all_extensions.each do |extension|
 | 
				
			||||||
      extensions = [language.primary_extension] + language.extensions
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      extensions.uniq.each do |extension|
 | 
					 | 
				
			||||||
        language_matches = Language.find_by_filename("foo.#{extension}")
 | 
					        language_matches = Language.find_by_filename("foo.#{extension}")
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        # If there is more than one language match for a given extension
 | 
					        # If there is more than one language match for a given extension
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user