mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-01-23 01:35:33 +00:00
Change FileBlob to accept a base path
This commit is contained in:
@@ -4,8 +4,9 @@ module Linguist
|
||||
class FileBlob
|
||||
include BlobHelper
|
||||
|
||||
def initialize(path, name = path)
|
||||
@path, @name = path, name
|
||||
def initialize(path, base_path = nil)
|
||||
@path = path
|
||||
@name = base_path ? path.sub("#{base_path}/", '') : path
|
||||
end
|
||||
|
||||
attr_reader :name
|
||||
|
||||
@@ -10,8 +10,8 @@ module Linguist
|
||||
def self.from_directory(base_path)
|
||||
paths = Dir["#{base_path}/**/*"].inject({}) do |h, path|
|
||||
if File.file?(path)
|
||||
name = path.sub("#{base_path}/", '')
|
||||
h[name] = FileBlob.new(path, name)
|
||||
blob = FileBlob.new(path, base_path)
|
||||
h[blob.name] = blob
|
||||
end
|
||||
h
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user