Add Blob#loc and Blob#sloc

This commit is contained in:
Joshua Peek
2011-05-13 15:12:40 -05:00
parent d8ee0dc9d5
commit 74b26fdfc9
2 changed files with 28 additions and 4 deletions

View File

@@ -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