Sha256: 163346e87ebd87bdb349ee1d59c9798563183dbf10c1bd1120374ad38a9e885b
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
# encoding: utf-8 # # Gathers different statistics # when methods are called. # # Can be output using to_s. # class Statistics def self.instance @statistics ||= new end def preamble loc = lines_of_code File.open('app/application.rb').read @preamble ||= <<-PREAMBLE \033[1mApplication(s)\033[m Definition LOC: #{"%4d" % loc} Indexes defined: #{"%4d" % Indexes.size} PREAMBLE end # Gathers information about the application. # def application preamble @application = Application.apps.map &:indented_to_s end # Gathers information about the indexes. # def analyze preamble @indexes = ["\033[1mIndexes analysis\033[m:"] Indexes.analyze.each_pair do |name, index| @indexes << <<-ANALYSIS #{"#{name}:".indented_to_s}: #{"exact:\n#{index[:exact].indented_to_s}".indented_to_s(4)} #{"partial*:\n#{index[:partial].indented_to_s}".indented_to_s(4)} ANALYSIS end @indexes = @indexes.join "\n" end # Outputs all gathered statistics. # def to_s <<-STATS Picky Configuration: #{[@preamble, @application, @indexes].compact.join("\n")} STATS end # Internal methods. # def lines_of_code text text.scan(/^\s*[^#\s].*$/).size end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
picky-2.0.0.pre1 | lib/picky/statistics.rb |
picky-1.5.4 | lib/picky/statistics.rb |
picky-1.5.3 | lib/picky/statistics.rb |