Changeset 2261256d076e9c65629ee11392c649b90bb74a18

Show
Ignore:
Timestamp:
06/12/2008 11:12:18 AM (2 months ago)
Author:
mitchell <mitchell@frost.(none)>
git-committer:
mitchell <mitchell@frost.(none)> 1213294338 -0400
git-parent:

[069dddc59c195676361a8943bc9c92c2cb26c09a]

git-author:
mitchell <mitchell@frost.(none)> 1213294338 -0400
Message:

Ohcount -e flag does a bit better than dumping entities to screen.
It now counts entity occurances for each language and puts them in a hash for
printing.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bin/ohcount

    r069dddc r2261256  
    7272 
    7373  # Entities 
    74   # TODO: do more fun stuff rather than print entities and positions 
    7574  def entities 
     75    langs = Hash.new 
    7676    files.each do |file| 
    7777      sfc = Ohcount::SimpleFileContext.new(file, files) 
     
    7979      if polyglot 
    8080        Ohcount::parse_entities(sfc.contents, polyglot) do |language, entity, s, e| 
    81           puts "#{language}\t#{entity}\t#{s}\t#{e}" 
    82         end 
    83       end 
    84     end 
     81          unless langs.include? language 
     82            langs[language] = Hash.new 
     83            langs[language].default = 0 
     84          end 
     85          langs[language][entity] += 1 
     86        end 
     87      end 
     88    end 
     89    p langs # TODO: pretty print 
    8590  end 
    8691 
     
    114119-e, --entities 
    115120 
    116    For now, simply prints the positions of entities parsed in all 
    117    source files found within the given paths. 
     121   Prints the number of entities found for each language parsed. 
    118122 
    119123-h, --help                      Display this message 
     
    267271    when '-e', '--entities' 
    268272      self.subcommand = :entities 
     273    #when /-n([\w_]+)/ 
     274    # @entities ||= [] 
     275    # @entities << $1.to_sym 
     276    # self.subcommand = :entities unless @subcommand 
    269277    when '-?', '-h', '--help' 
    270278      self.subcommand = :help