mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Makes it possible to detect the language of a snippet of code without having an actual file on disk Will allow github-markup to use Linguist without restricting its API
37 lines
925 B
Ruby
37 lines
925 B
Ruby
require "bundler/setup"
|
|
require "minitest/autorun"
|
|
require "mocha/setup"
|
|
require "linguist"
|
|
require 'color-proximity'
|
|
require "linguist/memory_blob"
|
|
|
|
def fixtures_path
|
|
File.expand_path("../fixtures", __FILE__)
|
|
end
|
|
|
|
def fixture_blob(name)
|
|
filepath = (name =~ /^\//)? name : File.join(fixtures_path, name)
|
|
Linguist::FileBlob.new(filepath, fixtures_path)
|
|
end
|
|
|
|
def fixture_blob_memory(name)
|
|
filepath = (name =~ /^\//)? name : File.join(fixtures_path, name)
|
|
content = File.read(filepath)
|
|
Linguist::MemoryBlob.new(name, content)
|
|
end
|
|
|
|
def samples_path
|
|
File.expand_path("../../samples", __FILE__)
|
|
end
|
|
|
|
def sample_blob(name)
|
|
filepath = (name =~ /^\//)? name : File.join(samples_path, name)
|
|
Linguist::FileBlob.new(filepath, samples_path)
|
|
end
|
|
|
|
def sample_blob_memory(name)
|
|
filepath = (name =~ /^\//)? name : File.join(samples_path, name)
|
|
content = File.read(filepath)
|
|
Linguist::MemoryBlob.new(name, content)
|
|
end
|