yptools 1.1.5 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5655449af16e78fedc89d6be8572069172fe5019d7d68d60ffb7cb96df11147
4
- data.tar.gz: e29a63a923289f717d1f603c14fcc4a11d82f1d711253e3be4c7be90e2df9188
3
+ metadata.gz: 6cadf211ff62cf593679a72de915fe9b7ca05311b86a2734014aea8a4edc5779
4
+ data.tar.gz: 071d3ffa79bacbfdb6715314d132be29b6493e60140cb926302344f87390d445
5
5
  SHA512:
6
- metadata.gz: 6ec94b8ade9d122af864ec142a639938a99f599ac36c47401f47cb4704b1507dd40b83301f3cef0202372e8a0c1dc6dceeb24e422b4ee3044fe05b11761839e9
7
- data.tar.gz: ce277188c065e04ad741c71a9ff6ae42c5429aea6b6105f57028ada0f0d1da29d0ee8010dbcc3a42514874404849ee108af7db6e1b9bcf973d79d603edf0e6b2
6
+ metadata.gz: a016a77f9a7196fd9af5c86435a5f0811c468a59e516860e4d9d751fc9f444c34115e392aa94951611356c9a09808b4e9a7a86b9bd1bd30e5486df64b3028110
7
+ data.tar.gz: '09107a47d3abd10c316a07b8324526234371c0ae1d7b6cbfb9f6c5ac10d23d359da4765467c887e724a398438bde0fe7b273b2e69624d3467907ffc3aba07eda'
@@ -894,7 +894,7 @@ class YPAutoCreate
894
894
  end
895
895
  }
896
896
 
897
- recordsNameTemp.push "key"
897
+ recordsNameTemp.push "@(key)"
898
898
 
899
899
  valueName = "(" + valueNameTemp.join(", ") + ")"
900
900
  recordsName = "(" + recordsNameTemp.join(", ") + ")"
@@ -19,6 +19,8 @@ class YPHelp
19
19
  xpj: use [yptools xpj ...] use xcodeproj api
20
20
  use [yptools xpj check] 检查当前目录项目文件是否存在引用的问题
21
21
 
22
+ png2jpeg: use [yptools png2jpeg ...] 将当前目录下面的png转为jpeg格式(目的可以用于减少文件大小,方便上传)
23
+
22
24
  🤖🤖🤖 - 智能聊天、绘画(OpenAI)
23
25
  chatgpt: use [yptools chatgpt] 创建会话列表与 chatgpt 聊天,会记录上下内容(科学上网)
24
26
  [yptools chatgpt ...] 快速与 chatgpt 沟通,不会记录上下内容
@@ -0,0 +1,45 @@
1
+ require 'colored'
2
+ require_relative '../log/yp_log'
3
+ require 'fileutils'
4
+
5
+ class YPPng2Jpeg
6
+ def self.png2jpeg(target_folder)
7
+ # 检查是否提供了目标文件夹名称作为参数
8
+ if target_folder.nil? || target_folder.empty?
9
+ puts '请提供目标文件夹名称作为参数'.red
10
+ exit(1)
11
+ end
12
+
13
+ # 检查目标文件夹是否存在
14
+ unless File.directory?(target_folder)
15
+ puts "目标文件夹不存在:#{target_folder}".red
16
+ exit(1)
17
+ end
18
+
19
+ # 创建新的文件夹(hah-jpeg)在同级目录下
20
+ output_root_folder = File.join(File.dirname(target_folder), "#{File.basename(target_folder)}-jpeg")
21
+ FileUtils.mkdir_p(output_root_folder)
22
+
23
+ # 遍历目标文件夹中的所有PNG文件
24
+ Dir.glob(File.join(target_folder, '**', '*.png')).each do |png_file|
25
+ # 获取文件路径、文件名(不含路径)和扩展名
26
+ file_path = File.dirname(png_file)
27
+ filename = File.basename(png_file)
28
+ extension = File.extname(filename)
29
+
30
+ # 创建目标文件的路径和名称,将扩展名从PNG更改为JPG
31
+ new_filename = File.basename(filename, '.*') + '.jpg'
32
+ output_folder = File.join(output_root_folder, File.basename(file_path))
33
+ FileUtils.mkdir_p(output_folder)
34
+ new_file = File.join(output_folder, new_filename)
35
+
36
+ # 使用sips命令将PNG转换为JPG
37
+ system("sips -s format jpeg '#{png_file}' --out '#{new_file}'")
38
+
39
+ # 输出转换结果
40
+ puts "已将 #{png_file} 转换为 #{new_file}".green
41
+ end
42
+
43
+ puts "转换完成,JPEG文件保存在 #{output_root_folder} 中".green
44
+ end
45
+ end
data/lib/yptools.rb CHANGED
@@ -15,6 +15,7 @@ require_relative 'yptools/portscan/yp_portscan'
15
15
  require_relative 'yptools/scanlocalips/yp_scanlocalips'
16
16
  require_relative 'yptools/dosattack/yp_dosattack'
17
17
  require_relative 'yptools/unziptools/yp_unziptools'
18
+ require_relative 'yptools/png2jpeg/yp_png2jpeg'
18
19
 
19
20
  class YPTools
20
21
 
@@ -77,12 +78,12 @@ class YPTools
77
78
  yp_log_fail "'yptools mgc ..' 参数缺失"
78
79
  self.help
79
80
  end
80
- when 'install'
81
+ when 'png2jpeg'
81
82
  if argvs.size > 1
82
83
  name = argvs[1]
83
- self.install name
84
+ self.png2jpeg name
84
85
  else
85
- yp_log_fail "'yptools install ..' 参数缺失"
86
+ yp_log_fail "'yptools png2jpeg ..' 参数缺失"
86
87
  self.help
87
88
  end
88
89
  when 'showipa'
@@ -198,6 +199,10 @@ class YPTools
198
199
  YPUnzipTools.unzip(argvs)
199
200
  end
200
201
 
202
+ def self.png2jpeg(path)
203
+ YPPng2Jpeg.png2jpeg(path)
204
+ end
205
+
201
206
  end
202
207
 
203
208
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yptools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - chenghengsheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2023-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,6 +142,7 @@ files:
142
142
  - lib/yptools/log/yp_log.rb
143
143
  - lib/yptools/mgc/yp_makegarbagecode.rb
144
144
  - lib/yptools/package/yp_package.rb
145
+ - lib/yptools/png2jpeg/yp_png2jpeg.rb
145
146
  - lib/yptools/portscan/yp_portscan.rb
146
147
  - lib/yptools/scanlocalips/yp_scanlocalips.rb
147
148
  - lib/yptools/unziptools/yp_unziptools.rb