mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Add Blob#loc and Blob#sloc
This commit is contained in:
@@ -12,10 +12,6 @@ module Linguist
|
||||
|
||||
attr_reader :name
|
||||
|
||||
def data
|
||||
@blob.data
|
||||
end
|
||||
|
||||
def mime_type
|
||||
Mime.lookup(name.extname)
|
||||
end
|
||||
@@ -29,10 +25,26 @@ module Linguist
|
||||
end
|
||||
end
|
||||
|
||||
def data
|
||||
@blob.data
|
||||
end
|
||||
|
||||
def lines
|
||||
@lines ||= data ? data.split("\n", -1) : []
|
||||
end
|
||||
|
||||
def size
|
||||
@blob.size
|
||||
end
|
||||
|
||||
def loc
|
||||
lines.size
|
||||
end
|
||||
|
||||
def sloc
|
||||
lines.grep(/\S/).size
|
||||
end
|
||||
|
||||
def submodule?
|
||||
defined?(Grit::Submodule) && @blob.kind_of?(Grit::Submodule)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user