forked from github-linguist/linguist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.rb
45 lines (38 loc) · 1.02 KB
/
helper.rb
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require "bundler/setup"
require "minitest/autorun"
require "mocha/setup"
require "linguist"
require 'color-proximity'
require "linguist/blob"
require 'licensee'
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::Blob.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::Blob.new(name, content)
end
def silence_warnings
original_verbosity = $VERBOSE
$VERBOSE = nil
yield
ensure
$VERBOSE = original_verbosity
end