Sha256: ce2b814158f1407af1c527385e075059a0172985c502be1a263f919d33f56fc0

Contents?: true

Size: 1.31 KB

Versions: 22

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8
#
module Picky

  # Gathers various statistics.
  #
  class Statistics # :nodoc:all

    def initialize
      @indexes = ["\033[1mIndexes analysis\033[m:"]
    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 object
      object.each_category do |category|
        @indexes << <<-ANALYSIS
  #{"#{category.index_name}".indented_to_s}\n
  #{"#{category.name}".indented_to_s(4)}\n
  #{"exact\n#{Analyzer.new.analyze(category.indexed_exact).indented_to_s}".indented_to_s(6)}\n
  #{"partial\n#{Analyzer.new.analyze(category.indexed_partial).indented_to_s}".indented_to_s(6)}
  ANALYSIS
      end
    end

    # Outputs all gathered statistics.
    #
    def to_s
      <<-STATS

  Picky Configuration:

  #{[@preamble, @application, @indexes.join("\n")].compact.join("\n")}
  STATS
    end

    # Internal methods.
    #

    def lines_of_code text
      text.scan(/^\s*[^#\s].*$/).size
    end

  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
picky-3.2.0 lib/picky/statistics.rb
picky-3.1.13 lib/picky/statistics.rb
picky-3.1.12 lib/picky/statistics.rb
picky-3.1.11 lib/picky/statistics.rb
picky-3.1.10 lib/picky/statistics.rb
picky-3.1.9 lib/picky/statistics.rb
picky-3.1.8 lib/picky/statistics.rb
picky-3.1.7 lib/picky/statistics.rb
picky-3.1.6 lib/picky/statistics.rb
picky-3.1.5 lib/picky/statistics.rb
picky-3.1.4 lib/picky/statistics.rb
picky-3.1.3 lib/picky/statistics.rb
picky-3.1.2 lib/picky/statistics.rb
picky-3.1.1 lib/picky/statistics.rb
picky-3.1.0 lib/picky/statistics.rb
picky-3.0.1 lib/picky/statistics.rb
picky-3.0.0 lib/picky/statistics.rb
picky-3.0.0.pre5 lib/picky/statistics.rb
picky-3.0.0.pre4 lib/picky/statistics.rb
picky-3.0.0.pre3 lib/picky/statistics.rb