Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Last active August 29, 2015 13:56
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save emad-elsaid/9227878 to your computer and use it in GitHub Desktop.
Save emad-elsaid/9227878 to your computer and use it in GitHub Desktop.
Project files analytics script, could work even on PHP, python projects ;)
directory = ARGV.shift || Dir.pwd
$dont_get_into = ['.','..']
$allowed = {
'Ruby' => '.rb',
'Ruby HTML Templates' => '.html.erb',
'YAML' => '.yml',
'RDoc' => '.rdoc',
'HTML' => '.html',
'Javascript' => '.js',
'CSS' => '.css',
'Sass' => '.scss',
'CofeeScript' => '.coffee'
}
$analytics = {}
def analyze(dir)
Dir.new(dir).each do |file_name|
if (! $dont_get_into.include? file_name) and
File.directory? dir + File::SEPARATOR + file_name
analyze dir + File::SEPARATOR + file_name
end
$allowed.each do |file, extension|
if file_name.end_with? extension
$analytics[file] ||= 0
$analytics[file] += 1
break
end
end
end
end
analyze directory
puts 'No files found that matches your creteria.' if $analytics.empty?
puts $analytics.map { |k,v| "#{k} : #{v} Files" }.join "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment