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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b4acc54af2714a06b66697813c810f1b3bcf5ca851dc81e138d5188740ac2f9
4
- data.tar.gz: 1993c8062c6e70f2a9d7c8b035e29a998eccd0a5e639af1269f1f890ddddcfca
3
+ metadata.gz: d39ab21ff4227e324816580ed8b0f7ae04da79961bd117e145cc8e0f62223e0e
4
+ data.tar.gz: 36ea5a963b803db9f14a2ea6ac1c09e12cdf2edd413bcfd7b9b0106e4cb60c06
5
5
  SHA512:
6
- metadata.gz: a6a5c7cb029e90dcaa91725d2aec7ffcbf3eedbe36dd66cd3c5333b3f840dd4b776b1a24116b84a0d89ad40063a2b79dfc59883e7529f43a16f18672f9f467af
7
- data.tar.gz: a2e533d961513ea1c51ce7458ed70eb418973e7c9c254c8031181ae2bd995e69b379da8d6f4f26b5f87b1c3f8e88272b00ad73e58fb993679ae643df52386005
6
+ metadata.gz: 60dafd60cb71a5543ce38c6533be49cecdca20fa507f35ad37437caa3d6684e1133cd7a2f51dffc6bf7f4b376a5e59a5c8d35f33fc8321490c7dddeb0e100423
7
+ data.tar.gz: e582dfc21639a60c7976f1eef89ecad4ce6aca0c27f75585c7a9e057765df6825a9dd2918c992bddb7bb9d2ccab1c4e8f2b28e01ea78428e84a9d17fdd4bf9b5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itools (0.2.2)
4
+ itools (0.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
@@ -2,4 +2,5 @@ require "itools/version"
2
2
  require "itools/link_map"
3
3
  require "itools/string_searcher"
4
4
  require "itools/find_unuse_img"
5
- require "itools/get_size"
5
+ require "itools/get_size"
6
+ require "itools/file_handle"
@@ -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 = File.size(path)
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
@@ -1,3 +1,3 @@
1
1
  module Itools
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
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.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-12 00:00:00.000000000 Z
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