yptools 1.0.12 → 1.0.14

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: '098816af79df22f9f807883a7beb32d93173ebeb30b24d04403d950d5e978ebd'
4
- data.tar.gz: aeb93d558104c3ec22cf0c289e378e57cb33d1003935669d043122b2bf6b4340
3
+ metadata.gz: f3c5473ec775d2207469ca880a82a6f519c56ec05f47025397427aa2ba829981
4
+ data.tar.gz: 33ae67ab59e2b4ccbb9797f882a34627058de7f01f92f9ad5dca2b71c6b6d021
5
5
  SHA512:
6
- metadata.gz: c27c68fa66faa6a457d8e463c9a6e3da7a4faa37635653136fe60240632333f5915198eb957720033ba1c9b23dd5466d7385d8b0f803505eba8e04fe992ddcf4
7
- data.tar.gz: f2402c1a385d2fa1d9253ad9d6b95508b5e5fcff1abdd1615cdedd0459f772050976f1a8fe654afe22cb3fe11c0b1a94d3696f6f3a88485b8eaa1de853cb2cad
6
+ metadata.gz: 865be63f0212e98c8bdec185e608fd1a3191f625ecbd9a2ea1fb1dbbe62024e5f96bea096a326f345e71e9b8eba4667facedc1f39e718d83721f90d33e877146
7
+ data.tar.gz: 76c379471377f5ff4cc8285d1a18491369e1a7ebb5a5673cb37ebe5137b6a39841f235f34ee485098600ba2ecb83c72313ba86421ffe5a9af7efe3c3fae64c31
@@ -0,0 +1,49 @@
1
+ require_relative '../log/yp_log'
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ class YPChatAI
6
+
7
+ def self.message(message)
8
+ yp_log_doing "你的问题:#{message}"
9
+ yp_log_msg "请求中,请等待..."
10
+ yp_chataiURL = 'https://api.openai.com/v1/completions'
11
+
12
+ # 开始发送网络请求
13
+ url = URI.parse(yp_chataiURL)
14
+ http = Net::HTTP.new(url.host, url.port)
15
+ http.use_ssl = true
16
+ # 设置请求头
17
+ headers = {
18
+ 'Content-Type' => 'application/json',
19
+ 'Authorization' => 'Bearer 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'
20
+ }
21
+ # 设置请body
22
+ data = {
23
+ 'model' => 'text-davinci-003', # 然后GPT-3模型会根据您的输入文本自动生成文本补全或摘要。
24
+ 'prompt' => message, # 问的问题
25
+ 'max_tokens' => 999, # 设置回答最多多少个字符
26
+ 'temperature' => 0.9, # 文本创意度,默认 1
27
+ }
28
+
29
+ request = Net::HTTP::Post.new(url.path, headers)
30
+ request.body = data.to_json
31
+ response = http.request(request)
32
+
33
+ yp_message_response = JSON(response.body)
34
+ if !yp_message_response["error"]
35
+ created = yp_message_response["created"]
36
+ choices = yp_message_response["choices"]
37
+ if !choices.empty?
38
+ text = choices.first["text"]
39
+ yp_log_success "chatGPT:" + text.gsub(/\n+/, "\n")
40
+ else
41
+ yp_log_fail "请求失败," + yp_message_response
42
+ end
43
+ else
44
+ message = yp_message_response["error"]["message"]
45
+ yp_log_fail "请求失败,请稍后再试!!!\n" + message
46
+ end
47
+ end
48
+
49
+ end
@@ -3,6 +3,8 @@ class YPHelp
3
3
  def self.message
4
4
  puts %q{
5
5
 
6
+ chatai: use [yptools chatai ...] 快速与 chatgpt 沟通(科学上网)
7
+
6
8
  autocre: use [yptools autocre ...] 自动化工具命令
7
9
  use [yptools autocre -objc ...] 根据 json 自动创建 Objective-C 数据库操作文件 .h|.m 文件。(依赖三方库 FMDB )
8
10
  use [yptools autocre -init] 构建数据库操作文件的json模板
@@ -58,54 +58,67 @@ class YPPackage
58
58
  end
59
59
 
60
60
  puts yp_infoPlistPath
61
- puts yp_mobileprovisionPath
62
61
 
63
- yp_mobileprovisionPlistPath = yp_resourceFile_app + "/" + "mobileprovision.plist"
64
- # 解析描述文件
65
- yp_mobileprovisionDatum = `security cms -D -i #{yp_mobileprovisionPath}`
66
-
67
- puts yp_mobileprovisionPlistPath
68
-
69
- yp_plistCreateFile = File.new(yp_mobileprovisionPlistPath,"w+")
70
- yp_plistCreateFile.syswrite(yp_mobileprovisionDatum)
71
- yp_plistCreateFile.close
72
-
73
- yp_log_success "============================================================"
74
-
75
- yp_plist = Plist.parse_xml(yp_mobileprovisionPlistPath)
76
-
77
- yp_appIDName = yp_plist["AppIDName"]
78
- yp_applicationIdentifierPrefix = yp_plist["ApplicationIdentifierPrefix"]
79
- yp_creationDate = yp_plist["CreationDate"]
80
- yp_platform = yp_plist["Platform"]
81
- yp_isXcodeManaged = yp_plist["IsXcodeManaged"]
82
- yp_developerCertificates = yp_plist["DeveloperCertificates"]
83
- yp_DER_Encoded_Profile = yp_plist["DER-Encoded-Profile"]
84
- yp_entitlements = yp_plist["Entitlements"]
85
- yp_expirationDate = yp_plist["ExpirationDate"]
86
- yp_name = yp_plist["Name"]
87
- yp_provisionsAllDevices = yp_plist["ProvisionsAllDevices"]
88
- yp_teamIdentifier = yp_plist["TeamIdentifier"]
89
- yp_teamName = yp_plist["TeamName"]
90
- yp_timeToLive = yp_plist["TimeToLive"]
91
- yp_uUID = yp_plist["UUID"]
92
- yp_version = yp_plist["Version"]
93
- yp_provisionedDevices = yp_plist["ProvisionedDevices"]
94
-
95
- yp_log_success " 输出描述文件embedded.mobileprovision"
96
- puts yp_mobileprovisionPlistPath
97
- puts ''
98
- yp_log_doing " 程序名称:\t#{yp_appIDName}"
99
- yp_log_doing " 团队名称:\t#{yp_teamName}"
100
- yp_log_doing " 创建时间:\t#{yp_creationDate}"
101
- yp_log_fail " 过期时间:\t#{yp_expirationDate}"
102
- yp_log_doing " 系统平台:\t#{yp_platform}"
103
-
104
- if yp_provisionedDevices.class == Array
105
- yp_log_doing " \n udids"
106
- for device in yp_provisionedDevices
107
- yp_log_doing " #{device}"
62
+ if yp_mobileprovisionPath.length > 0
63
+ puts yp_mobileprovisionPath
64
+ yp_mobileprovisionPlistPath = yp_resourceFile_app + "/" + "mobileprovision.plist"
65
+ # 解析描述文件
66
+ yp_mobileprovisionDatum = `security cms -D -i #{yp_mobileprovisionPath}`
67
+
68
+ puts yp_mobileprovisionPlistPath
69
+
70
+ yp_plistCreateFile = File.new(yp_mobileprovisionPlistPath,"w+")
71
+ yp_plistCreateFile.syswrite(yp_mobileprovisionDatum)
72
+ yp_plistCreateFile.close
73
+
74
+ yp_log_success "============================================================"
75
+
76
+ yp_plist = Plist.parse_xml(yp_mobileprovisionPlistPath)
77
+
78
+ if !yp_plist
79
+ yp_plist = {}
80
+ end
81
+
82
+ yp_appIDName = yp_plist["AppIDName"]
83
+ yp_applicationIdentifierPrefix = yp_plist["ApplicationIdentifierPrefix"]
84
+ yp_creationDate = yp_plist["CreationDate"]
85
+ yp_platform = yp_plist["Platform"]
86
+ yp_isXcodeManaged = yp_plist["IsXcodeManaged"]
87
+ yp_developerCertificates = yp_plist["DeveloperCertificates"]
88
+ yp_DER_Encoded_Profile = yp_plist["DER-Encoded-Profile"]
89
+ yp_entitlements = yp_plist["Entitlements"]
90
+ yp_expirationDate = yp_plist["ExpirationDate"]
91
+ yp_name = yp_plist["Name"]
92
+ yp_provisionsAllDevices = yp_plist["ProvisionsAllDevices"]
93
+ yp_teamIdentifier = yp_plist["TeamIdentifier"]
94
+ yp_teamName = yp_plist["TeamName"]
95
+ yp_timeToLive = yp_plist["TimeToLive"]
96
+ yp_uUID = yp_plist["UUID"]
97
+ yp_version = yp_plist["Version"]
98
+ yp_provisionedDevices = yp_plist["ProvisionedDevices"]
99
+
100
+ yp_log_success " 输出描述文件embedded.mobileprovision"
101
+ puts yp_mobileprovisionPlistPath
102
+ puts ''
103
+ yp_log_doing " 程序名称:\t#{yp_appIDName}"
104
+ yp_log_doing " 团队名称:\t#{yp_teamName}"
105
+ yp_log_doing " 创建时间:\t#{yp_creationDate}"
106
+ yp_log_fail " 过期时间:\t#{yp_expirationDate}"
107
+ yp_log_doing " 系统平台:\t#{yp_platform}"
108
+
109
+ if yp_provisionedDevices.class == Array
110
+ yp_log_doing " \n udids"
111
+ for device in yp_provisionedDevices
112
+ yp_log_doing " #{device}"
113
+ end
108
114
  end
115
+
116
+ puts ''
117
+
118
+ else
119
+ yp_log_success "============================================================"
120
+ yp_log_success "==================== 来自 AppStore 下载 ===================="
121
+
109
122
  end
110
123
 
111
124
  # yp_log_msg " 标识符🚀:\t#{yp_applicationIdentifierPrefix}"
@@ -118,7 +131,6 @@ class YPPackage
118
131
  # puts " 生存时间:\t#{yp_timeToLive}"
119
132
  # puts " uuid🚀🚀:\t#{yp_uUID}"
120
133
  # puts " 版本号🚀:\t#{yp_version}"
121
- puts ''
122
134
  yp_log_success "============================================================"
123
135
 
124
136
  # puts yp_infoPlistPath
data/lib/yptools.rb CHANGED
@@ -10,12 +10,22 @@ require_relative 'yptools/file/yp_updatecreatedate'
10
10
  require_relative 'yptools/package/yp_package'
11
11
  require_relative 'yptools/autocre/yp_autocre'
12
12
  require_relative 'yptools/autocre/yp_autoinit'
13
+ require_relative 'yptools/chatai/yp_chatai'
13
14
 
14
15
  class YPTools
15
16
 
16
17
  def self.cmd_dispatch(argvs)
17
18
  cmd = argvs[0]
18
19
  case cmd
20
+
21
+ when 'chatai'
22
+ if argvs.size > 1
23
+ name = argvs[1]
24
+ self.chatai name
25
+ else
26
+ yp_log_fail "'yptools chatai ..' 参数缺失"
27
+ self.help
28
+ end
19
29
  when 'autocre'
20
30
  if argvs.size > 1
21
31
  name = argvs[1]
@@ -94,6 +104,10 @@ class YPTools
94
104
  YPHelp.message
95
105
  end
96
106
 
107
+ def self.chatai(message)
108
+ YPChatAI.message(message)
109
+ end
110
+
97
111
  def self.ufct
98
112
  path = `pwd`
99
113
  path = path.sub("\n","")
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.0.12
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - chenghengsheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-01 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: net/http
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: Some useful tools make me happy
126
140
  email:
127
141
  - 2534550460@qq.com
@@ -134,6 +148,7 @@ files:
134
148
  - lib/yptools.rb
135
149
  - lib/yptools/autocre/yp_autocre.rb
136
150
  - lib/yptools/autocre/yp_autoinit.rb
151
+ - lib/yptools/chatai/yp_chatai.rb
137
152
  - lib/yptools/file/yp_updatecreatedate.rb
138
153
  - lib/yptools/help/yp_help.rb
139
154
  - lib/yptools/install/yp_install.rb