【发布时间】:2011-04-24 08:53:25
【问题描述】:
我正在尝试找到一种非常简单的方法来估算我的 Rails 项目的 LOC,包括视图和 CSS。
有没有办法使用 TextMate 做到这一点?
如果没有,还有什么方法可以得到 Rails 的total LOC 估计值?
编辑
为了澄清,我要求一种方法来确定 包含 html 和 css 的值。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 textmate lines-of-code
我正在尝试找到一种非常简单的方法来估算我的 Rails 项目的 LOC,包括视图和 CSS。
有没有办法使用 TextMate 做到这一点?
如果没有,还有什么方法可以得到 Rails 的total LOC 估计值?
为了澄清,我要求一种方法来确定 包含 html 和 css 的值。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 textmate lines-of-code
在终端中输入rake stats。它将输出 Code Lines of Code 以及 Test Lines of Code。
【讨论】:
看一下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
【讨论】: