Write a small script to the latest statistics the number of lines of code to write

sponsored links
class CodeLineStat
        attr_reader :code_lines

        def initialize
                @code_lines = 0

        def stat(path)
                Dir.foreach(path) do |file|
                        if file != "." && file != ".." then 
                                filePath = path + "/" + file
                                if File.directory? filePath then
                                elsif file =~ /(\.java|\.js|\.jsp)$/ then
                                        @code_lines += file_code_line(filePath);        

        def file_code_line(filePath)
                lines = 0
                File.open(filePath,"r") do |file|
                        in_comment = false;
                        file.each_line do |line|
                                if line.index("/*") then
                                        in_comment = true 
                                elsif line.index("*/") then
                                        in_comment = false
                                elsif !line.empty? && !in_comment && !line.index("//") then
                                        lines += 1
                puts "#{filePath} : #{lines}"

cl = CodeLineStat.new
puts cl.code_lines
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Write a small script to the latest statistics the number of lines of code to write

  • fck pages

    <% @ Page contentType = "text / html; charset = UTF-8"%> <% @ Include file = "/ commons / taglibs.jsp"%> <% @ Taglib uri = "/ FCKeditor" prefix = "FCK"%> <script language = "javascript

  • Msxml2.XMLHTTP version problem

    Projects with an import feature prototype.js of Ajax functionality to update the prompt, the code is very simple, do not have the framework of the background on a jsp to output Text, future use of timers and to update the page Ajax.request encountere ...

  • JS after ajax request return of the problem can not be implemented

    1: Send ajax request, in the onComplete, if back when the html contains a javascript, then these javascrip and will not be realized, it does not mean not to implement. This problem has troubled me for a long time, behind the hair and then put this kn ...

  • The company first entered the company I would like to Optimize SQL project

    I was a time not long into the company of people, but also a person to be graduated, but immediately entered the project team, involved in the development. The project is to make a China Telecom Operation System, is a big system. My so-called develop ...

  • Use Ext JS to read the JsonReader complex object json

    Today was how to resolve the following complex json object to the difficult living over a long time .. did not find documentation how to read JsonReader Ways json object (possibly also because of their limited level of E the text did not correctly underst

  • js page Jump implementation of a number of ways

    The first is: <script language="javascript" type="text/javascript"> window.location.href = "login.jsp? backurl =" + window.location.href; </ script> The second: <script language="javascript"> alert

  • hibernate (jpa) composite primary key annotation statement Ways

    In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,

  • RoR explained

    ROR is Ruby on Rails. Ruby is a well-known has been very good dynamic language It's dynamic language. Simple and easy. Dynamic languages are interpreted, but the performance may make a discount, but not absolute, because the application is complex, th

  • Some interview questions java

    The first is the company give you a chance to meet, it is necessary to know to meet from time to equal the interview, and have a lot of companies to see you at the first time will give you a ready point of doing something trivial, these questions, althoug

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries