itools 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9767a4dc31da86dba35eb36ff7c140518af6339eb176818520d7ee0aa51fd12a
4
- data.tar.gz: 4b0caef476cc596ae88813158e3a3a89a2c2410dd976fee46ae4ba3191dc2da9
3
+ metadata.gz: 0b172c6cbab9604e72a36f7303bf8eec0353afb84abf887b8f65e38610885bc5
4
+ data.tar.gz: d40afd6ca2603f7a2434ebf73aa84ca9b23212e4bdcd4e2e2a09b9703818e1b7
5
5
  SHA512:
6
- metadata.gz: d12af5520c72c8bb3067686e14726581cab1a30630ea0c96d45d0bbe29effa4ecf97b9701f67e82e002ededa7aee719105ae46b83c94f65d05cd413c73dc88dd
7
- data.tar.gz: cbd77f0e21354edc97de7e707dffd84a03be636600053de5897e6751c82602de5ce01dbc13f6b97d21cf033bff5de15e25c151d07f8baa84427ee66cfbdd1506
6
+ metadata.gz: 8286419537fc6bb35c6704bc011e49cf623e98a0db362b45b5c0ef3c7d61bcf0057f358e023c731a99d1870f7b806f9361515d5f2b17ce43af6b9a7fa3c29a89
7
+ data.tar.gz: 70e1d369dd7c8c600b29ab52ddafd0649d002979fc82f717ed5b8574feaac6f65d67892b516557104be86cf3f70a0705363e9b3eb101b910d938697f2be7e8db
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itools (0.2.4)
4
+ itools (0.2.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # itools
2
2
 
3
- 一个方便iOS开发的工具类。主要是使用Ruby编写,用于进行一些方便的处理,例如字符串查找,LinkMap解析等。
4
-
3
+ 一个方便iOS开发的工具类。主要是使用Ruby编写,用于进行一些方便的处理,例如字符串查找,LinkMap解析等。
5
4
  ## 安装
6
5
 
7
6
 
8
7
  ```ruby
9
8
  gem install itools
10
9
  ```
11
-
10
+ ## 说明
11
+ 该命令执行的时间与文件夹的大小以及文件多少有关。所以如果有执行停留问题,请耐心等待。
12
12
  ## 使用
13
13
  安装之后再终端执行itools,结果如下:
14
14
  ```shell
@@ -96,7 +96,8 @@ itools sizeFor /Users/zhanggui/zhanggui/my 1000
96
96
  or
97
97
  itools sizeFor /Users/zhanggui/zhanggui/my
98
98
  ```
99
- 计算sizeFor后面跟的参数内容所占内存大小,如果参数为文件路径,则计算文件大小,如果是文件夹,会遍历所有文件,然后计算大小。第二个参数为计算系数(这个系数为1MB = 1024KB中的1024;windows为1024,mac为1000,不传默认为1024
99
+ 计算sizeFor后面跟的参数内容所占内存大小,如果参数为文件路径,则计算文件大小,如果是文件夹,会遍历所有文件,然后计算大小。第二个参数为计算系数(这个系数为1MB = 1024KB中的1024;windows为1024,mac为1000,不传默认为1024)。
100
+ 在中途会提示你输入要查找的文件后缀,不输入任何则表示查找文件夹下的所有文件,输入后缀则会计算特定文件类型包含的大小,例如:png,jpg,gif,这样会计算出文件夹中三种类型格式的图片所占有内存的大小。
100
101
  ## Contributing
101
102
 
102
103
  Bug reports and pull requests are welcome on GitHub at https://github.com/ScottZg/itools. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
@@ -1,4 +1,5 @@
1
1
  require 'find'
2
+ require 'spreadsheet'
2
3
  module Itools
3
4
  class FileResult
4
5
  attr_accessor :keyword, :file_path, :file_name
@@ -16,16 +17,17 @@ module Itools
16
17
  @search_result = []
17
18
  end
18
19
  def search
19
- puts @files
20
+ puts "\033[32m开始查找...\033[0m"
20
21
  if File::directory?(@path)
21
22
  Find.find(@path) do |file|
22
23
  if File.file?(file)
23
24
  file_name = File.basename(file)
24
- if file_name.include?("ViewController.m")
25
+ if file_name.include?(@files)
25
26
  fr = FileResult.new(file,file_name)
26
27
  @search_result << fr
27
28
  end
28
-
29
+ else
30
+ # puts "查找#{file}..."
29
31
  end
30
32
  end
31
33
  else
@@ -40,15 +42,37 @@ module Itools
40
42
  puts "\033[31m参数异常,请传入两个参数,第一个为路径,第二个为要搜索的文件名\033[0m"
41
43
  return
42
44
  end
43
- temp_files = files.split(",")
44
- file_searcher = FileSearcher.new(path,temp_files)
45
+ # temp_files = files.split(",")
46
+ file_searcher = FileSearcher.new(path,files)
45
47
  file_searcher.search
48
+ if file_searcher.search_result.size == 0
49
+ puts "\033[32m没有找到符合条件的文件\033[0m"
50
+ return
51
+ end
46
52
  # 输出
47
- puts "\033[32m找到共#{file_searcher.search_result.size}个文件结果如下;\033[0m"
48
- file_searcher.search_result.each {|item|
49
- puts item.file_name + "-----"+item.file_path
50
- }
53
+ # 输出搜索的内容
54
+
55
+ Spreadsheet.client_encoding = 'utf-8'
56
+ book = Spreadsheet::Workbook.new
57
+ sheet1 = book.create_worksheet
58
+ sheet1.row(0)[0] = "序号"
59
+ sheet1.row(0)[1] = "文件名"
60
+ sheet1.row(0)[2] = "文件所在路径"
61
+
51
62
 
63
+ puts "\033[32m找到共#{file_searcher.search_result.size}个文件结果如下;\033[0m"
64
+ file_searcher.search_result.each_with_index {|item,i|
65
+ puts item.file_name
66
+ sheet1.row(i+1)[0] = i + 1
67
+ sheet1.row(i+1)[1] = item.file_name
68
+ sheet1.row(i+1)[2] = item.file_path
69
+ sheet1.row(i+1).height = 20
70
+ }
71
+ sheet1.column(0).width = 4
72
+ sheet1.column(1).width = 45
73
+ sheet1.column(2).width = 100
74
+ book.write "#{File.dirname(path)}/search_#{files}_result.xls"
75
+ puts "\033[32m查找成功,共#{file_searcher.search_result.size}个文件,内容已经保存到#{File.dirname(path)}/search_#{files}_result.xls,请点击查看\033[0m"
52
76
  end
53
77
  end
54
78
  end
@@ -1,3 +1,3 @@
1
1
  module Itools
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhanggui