happy_day_plugin 0.1.0 → 0.1.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 +4 -4
- data/lib/happy_day_plugin.rb +106 -2
- data/lib/happy_day_plugin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0166f17787e42ac3fe59ff610acdcdba1c6c759549043c7a447b2f2360411b58
|
4
|
+
data.tar.gz: 0b89c226892dcd613f24f91fe5957a7fab963d0fdac419ec2d2b545e8801767d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f026b4a90d02accbe8dd738be76b46e4d30ada9c3ac84abaa2b73dba9bb15853115d9dd0ce8a15df0a331e89d692653b4a2b46fd77510e2c3189ca01bbeb112
|
7
|
+
data.tar.gz: 2876bc931dce589fd8cd2f6e1c8319204bd12fb5a8b3d04b6ff76c964b51ee7003673ef53fa779f1ebb97ff1d94d736bb13c3c6e8af54ef99172b68f69f32aa3
|
data/lib/happy_day_plugin.rb
CHANGED
@@ -3,7 +3,111 @@ require "happy_day_plugin/version"
|
|
3
3
|
module HappyDayPlugin
|
4
4
|
class Error < StandardError; end
|
5
5
|
# Your code goes here...
|
6
|
-
def self.hi
|
7
|
-
|
6
|
+
def self.hi(p)
|
7
|
+
cc = FindImage.new(p)
|
8
|
+
cc.find
|
8
9
|
end
|
10
|
+
|
11
|
+
# class CH
|
12
|
+
# def initialize(p)
|
13
|
+
# @v = p
|
14
|
+
# end
|
15
|
+
# def hello
|
16
|
+
# puts "hello" + @v
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
|
20
|
+
class FindImage
|
21
|
+
def initialize(dir)
|
22
|
+
@imgs = Array.new
|
23
|
+
@mFiles = Array.new
|
24
|
+
@dir = dir
|
25
|
+
end
|
26
|
+
|
27
|
+
# 获得文件夹内的所有图片
|
28
|
+
def findImageWithPathDir(pathDir)
|
29
|
+
|
30
|
+
Dir.foreach(pathDir) do |file|
|
31
|
+
|
32
|
+
if file != '.' && file != '..' && !file.eql?('Pods')
|
33
|
+
if File.directory? ("#{pathDir}/#{file}")
|
34
|
+
|
35
|
+
findImageWithPathDir("#{pathDir}/#{file}")
|
36
|
+
else
|
37
|
+
isPng = file.end_with? ".png"
|
38
|
+
isJpg = file.end_with? ".jpg"
|
39
|
+
if isPng || isJpg
|
40
|
+
@imgs.push("#{pathDir}/#{file}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# 获得文件夹内所有.m文件
|
48
|
+
def findMwithPathDir(pathDir)
|
49
|
+
Dir.foreach(pathDir) do |file|
|
50
|
+
|
51
|
+
if file != '.' && file != '..'
|
52
|
+
if File.directory? ("#{pathDir}/#{file}")
|
53
|
+
|
54
|
+
findMwithPathDir("#{pathDir}/#{file}")
|
55
|
+
else
|
56
|
+
isM = file.end_with? ".m"
|
57
|
+
isJson = file.end_with? ".json"
|
58
|
+
if isM || isJson
|
59
|
+
@mFiles.push("#{pathDir}/#{file}")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# 检查图片是否有被使用
|
67
|
+
def checkImageUsing
|
68
|
+
@imgs.each do |img|
|
69
|
+
_isUsed = false
|
70
|
+
@mFiles.each do |file|
|
71
|
+
# 在file中检查 img
|
72
|
+
content = File.read(file)
|
73
|
+
# puts content
|
74
|
+
is2 = content =~ /#{File.basename(img, '@2x.png')}(.*)/
|
75
|
+
is3 = content =~ /#{File.basename(img, '@3x.png')}(.*)/
|
76
|
+
if (is2 || is3)
|
77
|
+
_isUsed = true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
unless _isUsed
|
82
|
+
outFile = File.new("unused.txt", "a+")
|
83
|
+
if outFile
|
84
|
+
outFile.syswrite(img)
|
85
|
+
outFile.syswrite("\n")
|
86
|
+
end
|
87
|
+
puts img
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def find
|
93
|
+
puts "|--开始"
|
94
|
+
|
95
|
+
findImageWithPathDir(@dir)
|
96
|
+
findMwithPathDir(@dir)
|
97
|
+
puts "|--没有使用\n"
|
98
|
+
checkImageUsing
|
99
|
+
|
100
|
+
# @imgs.each do |img|
|
101
|
+
# puts img
|
102
|
+
# end
|
103
|
+
|
104
|
+
# @mFiles.each do |file|
|
105
|
+
# puts file
|
106
|
+
# end
|
107
|
+
|
108
|
+
puts "|--结束"
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
9
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: happy_day_plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 朱佳宝
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|