Files
linguist/test/helper.rb
Paul Chaignon 8917f1a91a MemoryBlob class: wrapper around the content of a file
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
2015-07-12 20:28:42 +02:00

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