Sha256: 986f622ed3be94225e68893011cc2eac902842b4d3ff4b6a630836b94b74d421

Contents?: true

Size: 1008 Bytes

Versions: 5

Compression:

Stored size: 1008 Bytes

Contents

#!/usr/bin/env ruby

require 'linguist/file_blob'
require 'linguist/repository'

path = ARGV[0] || Dir.pwd

if File.directory?(path)
  repo = Linguist::Repository.from_directory(path)
  repo.languages.sort_by { |_, size| size }.reverse.each do |language, size|
    percentage = ((size / repo.size.to_f) * 100).round
    puts "%-4s %s" % ["#{percentage}%", language]
  end
elsif File.file?(path)
  blob = Linguist::FileBlob.new(path, Dir.pwd)
  type = if blob.text?
    'Text'
  elsif blob.image?
    'Image'
  else
    'Binary'
  end

  puts "#{blob.name}: #{blob.loc} lines (#{blob.sloc} sloc)"
  puts "  type:      #{type}"
  puts "  extension: #{blob.pathname.extname}"
  puts "  mime type: #{blob.mime_type}"
  puts "  language:  #{blob.language}"

  if blob.large?
    puts "  blob is too large to be shown"
  end

  if blob.generated?
    puts "  appears to be generated source code"
  end

  if blob.vendored?
    puts "  appears to be a vendored file"
  end
else
  abort "usage: linguist <path>"
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
github-linguist-2.2.1 bin/linguist
github-linguist-2.2.0 bin/linguist
github-linguist-2.1.2 bin/linguist
github-linguist-2.1.1 bin/linguist
github-linguist-2.1.0 bin/linguist