mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
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
This commit is contained in:
@@ -3,14 +3,21 @@ 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)
|
||||
name = File.join(fixtures_path, name) unless name =~ /^\//
|
||||
Linguist::FileBlob.new(name, fixtures_path)
|
||||
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
|
||||
@@ -18,6 +25,12 @@ def samples_path
|
||||
end
|
||||
|
||||
def sample_blob(name)
|
||||
name = File.join(samples_path, name) unless name =~ /^\//
|
||||
Linguist::FileBlob.new(name, samples_path)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user