惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
MyScale Blog
MyScale Blog
雷峰网
雷峰网
博客园 - 叶小钗
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
云风的 BLOG
云风的 BLOG
V
V2EX
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
N
Netflix TechBlog - Medium
Vercel News
Vercel News
美团技术团队
人人都是产品经理
人人都是产品经理
The Cloudflare Blog

博客园 - chensss2008

JavaScript 中的undefined and null 学习 html5 file upload and form data by ajax openresty + lua-resty-weedfs + weedfs + graphicsmagick动态生成缩略图(类似淘宝方案) ubuntu10.04 安装oracle server 版 笔记 windows xp + mysql5.5 + phpmyadmin insert 中文繁體 (原创)ubuntu 10.04+ruby1.9.2+rails3 安装记录 Ruby中如何复制对象 (deep clone)(转载) vi 常用命令使用說明 ruby1.9.2 +windowxp svn Server sent unexpected return value (403 Forbidden) in response to CHECKOUT ubuntu 14.04 安装svn server (subversionedge ) ubuntu 13.10 install wireshark Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具) mysql distinct field1,field2,field3, .... from table jsoup 使用总结4--高级用法之 script js 脚本 jsoup 使用总结3--高级用法之 not jsoup 使用总结2--高级用法之 :gt(n) jsoup 使用总结1--添加header require './ex25' can't load such file
ruby簡單的代碼行統計工具
chensss2008 · 2015-08-12 · via 博客园 - chensss2008

看代码

encoding: utf-8

class CodeLineStat
attr_reader :code_lines

def initialize
@code_lines = 0
end

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

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

cl = CodeLineStat.new
cl.stat(ARGV[0])
title = "總共有代碼行:".encode('big5')
puts cl.code_lines