diff --git a/lib/linguist/common.yml b/lib/linguist/common.yml new file mode 100644 index 00000000..8ea75897 --- /dev/null +++ b/lib/linguist/common.yml @@ -0,0 +1,60 @@ +# The languages which will appear on http://github.com/languages + +- Ada +- ActionScript +- Arc +- Assembly +- ASP +- Boo +- C +- "C#" +- C++ +- Clojure +- CoffeeScript +- ColdFusion +- Common Lisp +- D +- Delphi +- Dylan +- Eiffel +- Emacs Lisp +- Erlang +- "F#" +- Factor +- FORTRAN +- Go +- Groovy +- Haskell +- HaXe +- Io +- Java +- JavaScript +- Lua +- Max/MSP +- Mirah +- Nu +- Objective-C +- Objective-J +- OCaml +- ooc +- Perl +- PHP +- Pure Data +- Python +- R +- Racket +- Ruby +- Scala +- Scheme +- sclang +- Self +- Shell +- Smalltalk +- SuperCollider +- Tcl +- Vala +- Verilog +- VHDL +- VimL +- Visual Basic +- XQuery diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 17ba0878..b73522a1 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -57,6 +57,7 @@ module Linguist @lexer = Lexer.find_by_alias(@lexer_name) @extensions = attributes[:extensions] || [] @popular = attributes[:popular] || false + @common = attributes[:common] || false end attr_reader :name, :lexer_name, :lexer, :extensions @@ -77,6 +78,10 @@ module Linguist !popular? end + def common? + @common + end + def colorize(text) lexer.colorize(text) end @@ -95,6 +100,7 @@ module Linguist end popular = YAML.load_file(File.expand_path("../popular.yml", __FILE__)) + common = YAML.load_file(File.expand_path("../common.yml", __FILE__)) YAML.load_file(File.expand_path("../extensions.yml", __FILE__)).each do |name, options| Language.create( @@ -102,7 +108,8 @@ module Linguist :lexer_name => options[:lexer], :default_lexer => options[:default_lexer], :extensions => options[:ext], - :popular => popular.include?(name) + :popular => popular.include?(name), + :common => common.include?(name) ) end end diff --git a/test/test_language.rb b/test/test_language.rb index b21ee59d..50259569 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -96,6 +96,14 @@ class TestLanguage < Test::Unit::TestCase assert Language['Brainfuck'].unpopular? end + def test_common + assert Language['Perl'].common? + assert Language['Python'].common? + assert Language['Ruby'].common? + assert !Language['Brainfuck'].common? + assert !Language['Makefile'].common? + end + def test_colorize assert_equal <<-HTML, Language['Text'].colorize("Hello")
Hello