itools 0.2.2 → 0.2.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/itools +9 -0
- data/lib/itools.rb +2 -1
- data/lib/itools/file_handle.rb +54 -0
- data/lib/itools/find_unuse_img.rb +2 -2
- data/lib/itools/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d39ab21ff4227e324816580ed8b0f7ae04da79961bd117e145cc8e0f62223e0e
|
4
|
+
data.tar.gz: 36ea5a963b803db9f14a2ea6ac1c09e12cdf2edd413bcfd7b9b0106e4cb60c06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60dafd60cb71a5543ce38c6533be49cecdca20fa507f35ad37437caa3d6684e1133cd7a2f51dffc6bf7f4b376a5e59a5c8d35f33fc8321490c7dddeb0e100423
|
7
|
+
data.tar.gz: e582dfc21639a60c7976f1eef89ecad4ce6aca0c27f75585c7a9e057765df6825a9dd2918c992bddb7bb9d2ccab1c4e8f2b28e01ea78428e84a9d17fdd4bf9b5
|
data/Gemfile.lock
CHANGED
data/bin/itools
CHANGED
@@ -38,4 +38,13 @@ command :sizeFor do |c|
|
|
38
38
|
Itools::Memory.sizeFor(args)
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
# 查找文件
|
43
|
+
desc "search File in folder"
|
44
|
+
arg 'file name'
|
45
|
+
command :searchFile do |c|
|
46
|
+
c.action do |global_options, options, args|
|
47
|
+
Itools::FileSearcher.searchFile(args)
|
48
|
+
end
|
49
|
+
end
|
41
50
|
exit run(ARGV)
|
data/lib/itools.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'find'
|
2
|
+
module Itools
|
3
|
+
class FileResult
|
4
|
+
attr_accessor :keyword, :file_path, :file_name
|
5
|
+
def initialize(temp_path,temp_name)
|
6
|
+
@file_path = temp_path
|
7
|
+
@file_name = temp_name
|
8
|
+
end
|
9
|
+
end
|
10
|
+
class FileSearcher
|
11
|
+
# path:搜索的路径,files要搜索的文件,支持数组用逗号隔开即可。支持模糊搜索
|
12
|
+
attr_accessor :path ,:files, :search_result
|
13
|
+
def initialize(temp_path,temp_files)
|
14
|
+
@path = temp_path
|
15
|
+
@files = temp_files
|
16
|
+
@search_result = []
|
17
|
+
end
|
18
|
+
def search
|
19
|
+
puts @files
|
20
|
+
if File::directory?(@path)
|
21
|
+
Find.find(@path) do |file|
|
22
|
+
if File.file?(file)
|
23
|
+
file_name = File.basename(file)
|
24
|
+
if file_name.include?("ViewController.m")
|
25
|
+
fr = FileResult.new(file,file_name)
|
26
|
+
@search_result << fr
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
else
|
32
|
+
puts "\033[31m文件夹有误,请输入文件夹路径作为第一个参数\033[0m"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
# 对外暴露方法
|
36
|
+
def self.searchFile(args)
|
37
|
+
path = args[0]
|
38
|
+
files = args[1]
|
39
|
+
if path.nil? || files.nil?
|
40
|
+
puts "\033[31m参数异常,请传入两个参数,第一个为路径,第二个为要搜索的文件名\033[0m"
|
41
|
+
return
|
42
|
+
end
|
43
|
+
temp_files = files.split(",")
|
44
|
+
file_searcher = FileSearcher.new(path,temp_files)
|
45
|
+
file_searcher.search
|
46
|
+
# 输出
|
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
|
+
}
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -84,11 +84,11 @@ module Itools
|
|
84
84
|
sheet1.row(idx+1)[0] = item
|
85
85
|
path = imgFinder.get_image_path(item)
|
86
86
|
sheet1.row(idx+1)[1] = path
|
87
|
-
unuse_total_size = unuse_total_size
|
87
|
+
unuse_total_size = unuse_total_size + File.size(path)
|
88
88
|
puts item
|
89
89
|
}
|
90
90
|
book.write "#{imgFinder.find_path}/search_result.xls"
|
91
|
-
puts "\033[32m文件已经保存到#{imgFinder.find_path}/search_result.xls,无用图片大小:#{unuse_total_size}\033[0m"
|
91
|
+
puts "\033[32m文件已经保存到#{imgFinder.find_path}/search_result.xls,无用图片大小:#{unuse_total_size}B\033[0m"
|
92
92
|
puts "\033[32m内容仅供参考,具体还要自己通过结果查看一下\033[0m"
|
93
93
|
end
|
94
94
|
end
|
data/lib/itools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhanggui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- bin/itools
|
93
93
|
- itools.gemspec
|
94
94
|
- lib/itools.rb
|
95
|
+
- lib/itools/file_handle.rb
|
95
96
|
- lib/itools/find_unuse_img.rb
|
96
97
|
- lib/itools/get_size.rb
|
97
98
|
- lib/itools/link_map.rb
|