From 338ef7cbc6c092d5abce7091de645f7eb53e42b6 Mon Sep 17 00:00:00 2001 From: Robin Luckey Date: Mon, 4 Feb 2008 13:01:53 -0800 Subject: [PATCH] [FIX] Haskell was missing a declaration for its nice_name. There should probably be a test for this, but I can't figure out how to get a list of all Monoglots at test time. Language nice_names and categories should probably be declared somewhere more obvious anyway. --- README | 2 ++ lib/ohcount/sloc_info.rb | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README b/README index 2756504..69eaac1 100644 --- a/README +++ b/README @@ -119,6 +119,8 @@ These are the steps required to add a new language to ohcount: * Update Ohcount::DetectorTest to confirm the Detector changes. * In Ohcount::Generator, instantiate a new Ohcount::Monoglot or Ohcount::Polyglot to parse the language. +* In Ohcount::SlocInfo, provide a "nice name" and category (procedural + code vs. markup) for the new language. * Create a new Ohcount::Test to verify the parser. == Contact Ohloh diff --git a/lib/ohcount/sloc_info.rb b/lib/ohcount/sloc_info.rb index 38efbdf..a938ef0 100644 --- a/lib/ohcount/sloc_info.rb +++ b/lib/ohcount/sloc_info.rb @@ -1,4 +1,9 @@ -# a DTO class to hold the sloc information +# A generic data object for returning parsing results from Ohcount to Ohloh. +# +# This class has the additional job of declaring a "nice" (human readable) name +# for each language, as well as the category (procedural code vs. markup) for each +# language. These features should probably live elsewhere, and are currently +# not covered by unit tests. class Ohcount::SlocInfo attr_reader :language attr_accessor :code_added, :code_removed, :comments_added, :comments_removed, :blanks_added, :blanks_removed @@ -70,13 +75,19 @@ class Ohcount::SlocInfo 'xmlschema' => {:nice_name => 'XML Schema' , :category => 1}, 'xslt' => {:nice_name => 'XSL Transformation',:category => 0}, 'dmd' => {:nice_name => 'D' , :category => 0}, - 'tex' => {:nice_name => 'TeX/LaTeX' , :category => 1} + 'tex' => {:nice_name => 'TeX/LaTeX' , :category => 1}, + 'haskell' => {:nice_name => 'Haskell' , :category => 0} } + # Returns the human readable name for a language. def language_nice_name @@lang_map[self.language][:nice_name] end + # Returns the category (procedural code vs. markup) for a language. + # + # Category 0 indicates procedural code (most languages). + # Category 1 indicates a markup file, such as XML. def language_category @@lang_map[self.language][:category] end -- 2.32.0.93.g670b81a890