从TextMate获取项目代码行数(LOC)?

5

我正在尝试寻找一种轻而易举的方式来估计我的Rails项目包括视图和CSS在内的代码行数(LOC)。

是否有一种使用TextMate实现此目的的方法?

如果没有,那么还有什么其他方法可以获得Rails的LOC估计值呢?

编辑

为了澄清,我正在寻求一种确定包括html和css在内的值的方法。

2个回答

8

在终端中输入rake stats。它将输出代码行数以及测试代码行数。


Ryan - 这个不会输出HTML/CSS,对吧? - sscirrus

0

看一下rake任务 - 添加视图不应该太难了:https://github.com/rails/rails/blob/master/railties/lib/rails/tasks/statistics.rake

STATS_DIRECTORIES = [
  %w(Controllers app/controllers),
  %w(Helpers app/helpers),
  %w(Models app/models),
  %w(Libraries lib/),
  %w(APIs app/apis),
  %w(Integration\ tests test/integration),
  %w(Functional\ tests test/functional),
  %w(Unit\ tests test/unit)
].collect { |name, dir| [ name, "#{Rails.root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }

desc "Report code statistics (KLOCs, etc) from the application"
task :stats do
  require 'rails/code_statistics'
  CodeStatistics.new(*STATS_DIRECTORIES).to_s
end

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接