XCODE 脚本:项目行数统计
来源:互联网 发布:淘宝开店的货源怎么找 编辑:程序博客网 时间:2024/06/13 13:40
统计项目行数,从某方面也可以陶醉下自己项目规模。
暴力推荐无聊发呆时候使用。
这个从自己一个最早期Rails项目中剥离出来,虽然简单,不过勉强能用了。
使用方法:打开脚本编辑器。添加新脚本。拷贝代码,OutPut 选择 display in alert
暴力推荐无聊发呆时候使用。
这个从自己一个最早期Rails项目中剥离出来,虽然简单,不过勉强能用了。
使用方法:打开脚本编辑器。添加新脚本。拷贝代码,OutPut 选择 display in alert
That's all , Enjoy!
#!/usr/bin/env ruby # description: Count code lines in project# Copyright by [email]xhan87@gmail.com[/email]# Sep 15 , 2009 #### this is designed to calculate the total lines of codes in your project## version 2 @May 24, 2009## \- add file filter ,count specific file types add ## version 1 @october 8th,2008 module Enumerable # function to get total lines from a file def total_lines lines = 0 each_with_index {|content,lines|} return lines+1 endend class CheckLines require 'find' CheckType = %w{m h c cpp mm}.freeze def initialize(directory) @total_lines = 0 if File.directory?(directory) @directory = directory @contents = {} @content_type ={} CheckType.each {|ext| @content_type[ext.to_sym]=0} self.go else puts "#{directory} is not a directory! check it out!" and return end end def go if @directory Find.find @directory do |path| pathlite = path.gsub(@directory,'') if File.file?(path) && is_check_file(path) File.open path do |f| tmp_line = f.total_lines @contents.store(pathlite,tmp_line) @content_type[(path.sub(/.*\./,'').to_sym)] += tmp_line @total_lines += tmp_line end end end puts "Total Code Lines:#{@total_lines}" puts "Total Files #{@contents.keys.size}" @content_type.each_pair {|key,value| puts "#{key} : #{value}"} end end def is_check_file file_name CheckType.any? do |ext| !file_name.scan(/\.#{ext}$/).empty? end end def details @contents.each do |key,value| puts "#{key} file has lines of #{value}" end endend # s=CheckLines.new("/Users/xhan/Codes/plutocms") project_path = `%%%{PBXUtilityScriptsPath}%%%/AskUserForFolderDialog "Select A Project Home Folder"`#puts project_pathCheckLines.new(project_path[0..-2]) unless project_path.empty?
- XCODE 脚本:项目行数统计
- 统计Xcode项目代码行数
- 统计Xcode项目代码行数
- 统计Xcode项目代码行数
- Xcode统计项目代码行数
- Xcode项目代码行数统计
- 终端统计Xcode中项目总共行数
- Xcode代码行数统计
- Xcode代码行数统计
- xcode统计源代码行数
- xcode 统计代码行数
- xcode 代码行数统计
- xcode统计源代码行数
- xcode代码行数统计
- xcode统计源代码行数
- Xcode代码行数统计
- xcode 统计代码行数
- xcode 统计代码行数
- javascript 鼠标拖拉画图
- C++primer第三章:标准库类型
- Internet Explorer 编程简述(十三)调用IE隐藏的命令(续)
- XML第四课
- The Zen of Python(Python之禅)
- XCODE 脚本:项目行数统计
- Notification
- 树——二叉树遍历之非递归实现
- SMTP error: Failed to add recipient 451错误
- 9png
- “Device eth0 has different MAC address than expected, ignoring.”问题
- Maven命令使用及简介
- ubuntu 批量修改文件名 右键添加打开终端
- TCP/UDP/HTTP