itools 0.2.0 → 0.2.1

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: 849b5873c368d8c600d7da741990a5ef8c722e836baab7b30edea0498e663fd9
4
- data.tar.gz: da3c25aa699dedd4c7faf5d3cdea06b2ecd74b798db38a1d02a37ef4788c8bb7
3
+ metadata.gz: 02f5e884b390172db80c0d1591554f1c10d05bfb9a9be92871ae10f5e8fe96b0
4
+ data.tar.gz: 1b998ffb957c6c9e08c020505180d0bc33fc17875557b9ef8bf42892751c5f4d
5
5
  SHA512:
6
- metadata.gz: 19034856514e71a9f6954eb375d6a08433f514681e1345568ace9cda529288127ecfb177a652c63da7151713d7d91956ebcd43c546a72514880d0c32818a7d26
7
- data.tar.gz: 617fe75c3006e159178df6f6598cbde74b7d0e539f788f87e1caf276c04c4be0947120e63fa6bdcd9edf58784d2bf87ed7dc237073d519c9a63844f7f2868d8d
6
+ metadata.gz: 2beedb55289f268a9595f63169f8780e093f8686985f54eebb4cfde52bda731c59fcebf3a40ae4a608ff99ffab452185b01c006fce0fe6fa528524c709b0b040
7
+ data.tar.gz: 4416ad45b191e7806b5f18b09a79d690b11b4a50d58758485af810308b2a8a79ce388322a5c4df7f654b7f6d0e37ae9cee817ca4685467661ef9f4eb9fafbdc7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itools (0.2.0)
4
+ itools (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,23 +1,40 @@
1
1
  require 'find'
2
2
  require 'spreadsheet'
3
3
  module Itools
4
+ class FindResult
5
+ attr_accessor :name , :path
6
+ def initialize(name,path)
7
+ @name = name
8
+ @path = path
9
+ end
10
+
11
+ end
12
+ # --------------------------------------------
4
13
  class ImgFinder
5
- attr_accessor :image_count, :image_names, :unuse_images,:find_path
14
+ #
15
+ attr_accessor :image_count, :images, :unuse_images,:find_path
6
16
  attr_accessor :search_files
7
17
  def initialize
8
18
  @image_count = 0
9
- @image_names = []
19
+ @images = []
10
20
  @search_files = []
11
21
  end
12
22
  # 得到所有图片名称字符
13
23
  def get_img_name_strs
14
24
  result_arr = []
15
- @image_names.each {|item|
16
- item_name = Image.get_image_name(File.basename(item, ".*"))
25
+ @images.each {|item|
26
+ item_name = Image.get_image_name(File.basename(item.name, ".*"))
17
27
  result_arr << item_name
18
28
  }
19
29
  return result_arr
20
30
  end
31
+ def get_image_path(image)
32
+ @images.each {|item|
33
+ if item.name.eql?(image)
34
+ return item.path
35
+ end
36
+ }
37
+ end
21
38
  # 查找
22
39
  def self.find(temp_find_dir)
23
40
  imgFinder = ImgFinder.new
@@ -29,21 +46,22 @@ module Itools
29
46
  # p File.basename(filename)
30
47
  # exit
31
48
  imgFinder.image_count = imgFinder.image_count + 1
32
- imgFinder.image_names << filename
49
+ imageResult = FindResult.new(Image.get_image_name(File.basename(filename,".*")),filename)
50
+ imgFinder.images << imageResult
33
51
  elsif File.extname(filename).eql?(".m")
34
52
  imgFinder.search_files << filename
35
53
  end
36
54
  end
37
55
  end
38
- if imgFinder.image_names.size == 0
56
+ if imgFinder.images.size == 0
39
57
  puts "\033[32m查找成功,未发现图片\033[0m"
40
58
  return
41
59
  else
42
- puts "\033[32m查找成功,共发现图片#{imgFinder.image_names.size}张\033[0m"
60
+ puts "\033[32m查找成功,共发现图片#{imgFinder.images.size}张\033[0m"
43
61
  end
44
62
  # 第二步:找到图片是否使用
45
63
  imags = imgFinder.get_img_name_strs.uniq #要查找的图片名称数组
46
-
64
+
47
65
  puts "\033[32m需要查找的图片有#{imags.size}张\033[0m"
48
66
  # imgFinder.search_files #要查找的文件
49
67
  imgFinder.search_files.each {|file|
@@ -60,8 +78,10 @@ module Itools
60
78
  book = Spreadsheet::Workbook.new
61
79
  sheet1 = book.create_worksheet
62
80
  sheet1.row(0)[0] = "文件名"
81
+ sheet1.row(0)[1] = "文件路径"
63
82
  imags.each_with_index {|item,idx|
64
83
  sheet1.row(idx+1)[0] = item
84
+ sheet1.row(idx+1)[1] = imgFinder.get_image_path(item)
65
85
  puts item
66
86
  }
67
87
  book.write "#{imgFinder.find_path}/search_result.xls"
@@ -81,6 +101,7 @@ module Itools
81
101
  return -1
82
102
  end
83
103
  end
104
+ # ----------------------------
84
105
  class Image
85
106
 
86
107
  # 是否是图片格式,这里只判断了jpg、png和gif
@@ -1,3 +1,3 @@
1
1
  module Itools
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhanggui