Skip to content

Instantly share code, notes, and snippets.

@seanhenry
Created November 6, 2015 11:04

Revisions

  1. Sean Henry created this gist Nov 6, 2015.
    35 changes: 35 additions & 0 deletions SRPAnalyser.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # Dependencies: sudo gem install colorize
    # Usage: ruby SRPAnalyser.rb --hide-acceptable <Path to search>

    require 'colorize'

    def displayFileWithNumberOfLines (file, lines, hideAcceptable)
    message = "#{file} has #{lines} lines."
    maxLines = 250
    acceptableLines = 150
    if lines > maxLines
    puts message.red
    elsif lines > acceptableLines
    puts message.yellow
    elsif !hideAcceptable
    puts message.green
    end
    end

    directory = ARGV.last

    hideAcceptable = false
    ARGV.each do |a|
    if a == "--hide-acceptable"
    hideAcceptable = true
    end
    end

    filesString = `grep --include=*.swift --include=*.m --exclude-dir=*Tests --exclude-dir=*Spec --exclude-dir=Pods --exclude-dir=Carthage -rc '' #{directory}`
    files = filesString.split("\n")

    files.each do |file|
    values = file.split(":")
    fileName = values[0].split("/").last
    displayFileWithNumberOfLines fileName, values[1].to_i, hideAcceptable
    end