-
Notifications
You must be signed in to change notification settings - Fork 95
The Ohloh source code line counter with Ragel
License
korsakov/ohcount
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
= Ohcount The Ohloh source code line counter This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation. Ohcount is specifically licensed under GPL v2.0, and no later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. == Overview Ohcount is a library for counting lines of source code. It was originally developed at Ohloh, and is used to generate the reports at www.ohloh.net. Ohcount supports multiple languages within a single file: for example, a complex HTML document might include regions of both CSS and JavaScript. Ohcount has two main components: a detector which determines the primary language family used by a particular source file, and a parser which provides a line-by-line breakdown of the contents of a source file. Ohcount includes a command line tool that allows you to count individual files or whole directory trees. It also allows you to find source code files by language family, or to create a detailed annotation of an individual source file. Ohcount includes a Ruby binding which allows you to directly access its language detection features from a Ruby application. == System Requirements Ohcount is supported on Mac OS X 10.4 and Ubuntu 6.06 LTS. Other Linux environments should also work, but your mileage may vary. Ohcount does not support Windows. Ohcount targets Ruby 1.8.6. The build script targets Rake 0.7.3. You will also require a C compiler to build the native extensions. Ohcount requires Ragel (http://research.cs.queensu.ca/~thurston/ragel/) Unfortunately, Ragel 6.2 is not recent enough so you will need the latest version in SVN: svn://mambo.cs.queensu.ca/ragel/trunk/. == Download The source code for ohcount is available as a tarball: http://labs.ohloh.net/download/ohcount-1.0.2.tgz You can also download the source code as a Git repository: git clone http://git.ohloh.net/git/ohcount.git == Installation Ohcount is packaged as a RubyGem. To build and install the gem (you will need root priveleges for the install): $ rake install To uninstall the RubyGem: $ gem uninstall ohcount If you do not want to install the gem, you can simply build and run it like this: $ rake $ bin/ohcount == First Steps To measure the lines of code, simply pass filenames or directory names to the +ohcount+ script: $ ohcount helloworld.c Directories will be probed recursively. If you do not pass any parameters, the current directory tree will be counted. You can use the ohcount +detect+ option to simply determine the language family of each source file. The files will not be parsed or counted. For example, to find all of the ruby files in the current directory tree: $ ohcount --detect | grep ^ruby The +annotate+ option presents a line-by-line accounting of the languages used in a source code file. For example: $ ohcount --annotate ./test/src_dir/php1.php == Loading ohcount from Ruby If you have installed ohcount as a gem, you can load it like this: require 'rubygems' require 'ohcount' If you have not installed the gem, you'll have to make sure that ohcount is on your ruby load path and then require: require 'ohcount' The <tt>bin/ohcount</tt> script shows examples of calling the ohcount libraries from Ruby. == How to Add a New Language These are the steps required to add a new language to ohcount: * Update Ohcount::Detector to identify files that use the new language. * Update Ohcount::DetectorTest to confirm the Detector changes. * Follow the detailed instructions in PARSER_DOC. * 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 For more information visit the Ohloh website: http://labs.ohloh.net You can reach Ohloh via email at: [email protected]
About
The Ohloh source code line counter with Ragel
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- Other 43.0%
- Ruby 18.6%
- JavaScript 8.7%
- Perl 8.2%
- C 7.7%
- Visual Basic .NET 1.4%
- Other 12.4%