File: similarity.rake

package info (click to toggle)
ruby-rouge 4.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,844 kB
  • sloc: ruby: 38,489; sed: 2,071; perl: 152; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def test_similarity(lexer_class)
  score, matches = Similarity.test(lexer_class)

  if score == 1
    puts "[none]"
  else
    puts "[#{score}] #{matches.map(&:tag).join(', ')}"
  end
end

namespace :check do
  desc "Test the similarity with existing lexers"
  task :similarity, [:lang] do |t, args|
    require "rouge"
    require "#{Rake.application.original_dir}/spec/support/similarity.rb"

    language = args.lang

    if language
      test_similarity Rouge::Lexer.find(language)
    else
      Rouge::Lexer.all.each do |lexer_class|
        print "#{lexer_class.tag}: "
        test_similarity lexer_class if lexer_class < Rouge::RegexLexer
      end
    end
  end
end