Sha256: 2e5e582b87ea17394b46fe65972a24db9ad76da17d2d98da6d313aa6e68692be

Contents?: true

Size: 961 Bytes

Versions: 27

Compression:

Stored size: 961 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 "  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

27 entries across 27 versions & 3 rubygems

Version Path
ol-github-linguist-2.4.2.5 bin/linguist
github-linguist-2.8.9 bin/linguist
github-linguist-2.8.8 bin/linguist
github-linguist-2.8.7 bin/linguist
github-linguist-2.8.6 bin/linguist
github-linguist-2.8.5 bin/linguist
github-linguist-2.8.4 bin/linguist
github-linguist-2.8.3 bin/linguist
github-linguist-2.8.2 bin/linguist
github-linguist-2.8.1 bin/linguist
github-linguist-2.8.0 bin/linguist
github-linguist-2.7.0 bin/linguist
geothird-linguist-2.6.8 bin/linguist
geothird-linguist-2.6.1 bin/linguist
github-linguist-2.6.7 bin/linguist
github-linguist-2.6.6 bin/linguist
github-linguist-2.6.5 bin/linguist
github-linguist-2.6.3 bin/linguist
github-linguist-2.6.2 bin/linguist
github-linguist-2.6.1 bin/linguist