From 6b283068a9171524bcbbe4a99b22d926ae269c4c Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Tue, 4 Aug 2015 12:20:15 +0100 Subject: [PATCH] Adding back R/Rebol heuristics --- lib/linguist/heuristics.rb | 8 ++++++++ test/test_heuristics.rb | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 66980945..a6346005 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -350,5 +350,13 @@ module Linguist Language["xBase"] end end + + disambiguate ".r", ".R" do |data| + if /\bRebol\b/i.match(data) + Language["Rebol"] + elsif data.include?("<-") + Language["R"] + end + end end end diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index 94418b3b..59041e7b 100644 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -179,4 +179,11 @@ class TestHeuristcs < Minitest::Test "xBase" => all_fixtures("xBase", ".ch") }) end + + def test_r_by_heuristics + assert_heuristics({ + "R" => all_fixtures("R", "*.r") + all_fixtures("R", "*.R"), + "Rebol" => all_fixtures("Rebol", "*.r") + }) + end end