方法
- N
- R
- T
常量
DIRECTORIES | = | [ %w(Controllers app/controllers), %w(Helpers app/helpers), %w(Jobs app/jobs), %w(Models app/models), %w(Mailers app/mailers), %w(Mailboxes app/mailboxes), %w(Channels app/channels), %w(Views app/views), %w(JavaScripts app/assets/javascripts), %w(Stylesheets app/assets/stylesheets), %w(JavaScript app/javascript), %w(Libraries lib/), %w(APIs app/apis), %w(Controller\ tests test/controllers), %w(Helper\ tests test/helpers), %w(Job\ tests test/jobs), %w(Model\ tests test/models), %w(Mailer\ tests test/mailers), %w(Mailbox\ tests test/mailboxes), %w(Channel\ tests test/channels), %w(Integration\ tests test/integration), %w(System\ tests test/system), ] |
HEADERS | = | { lines: " 行数", code_lines: " 代码行", classes: " 类", methods: " 方法" } |
TEST_TYPES | = | ["控制器测试", "辅助方法测试", "模型测试", "邮件发送器测试", "邮箱测试", "频道测试", "作业测试", "集成测试", "系统测试"] |
类 公共方法
new(*pairs) 链接
源代码: 显示 | 在 GitHub 上查看
# File railties/lib/rails/code_statistics.rb, line 60 def initialize(*pairs) @pairs = pairs @statistics = calculate_statistics @total = calculate_total if pairs.length > 1 end
register_directory(label, path, test_directory: false) 链接
将目录添加到 `bin/rails stats` 命令的输出中。
Rails::CodeStatistics.register_directory("My Directory", "path/to/dir")
对于包含测试代码的目录,将 `test_directory` 参数设置为 `true`。
Rails::CodeStatistics.register_directory("Model specs", "spec/models", test_directory: true)
源代码: 显示 | 在 GitHub 上查看
# File railties/lib/rails/code_statistics.rb, line 55 def self.register_directory(label, path, test_directory: false) self.directories << [label, path] self.test_types << label if test_directory end
实例 公共方法
to_s() 链接
源代码: 显示 | 在 GitHub 上查看
# File railties/lib/rails/code_statistics.rb, line 66 def to_s print_header @pairs.each { |pair| print_line(pair.first, @statistics[pair.first]) } print_splitter if @total print_line("Total", @total) print_splitter end print_code_test_stats end