gwtools 0.0.17 → 0.0.18
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d38d7819049120197657aaada9c96d48c0aec7519c35939e5fa5626a1835159
|
4
|
+
data.tar.gz: bc0c358a7491f712175631dd210aca21cc55fb3385428df4e6064d22297b74ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be161ff8c7e2f6e7912fd128894b238f396fe89e405889bb043bf316bc4831be2d99d5caa367f875d23bef8f2a31413a3e94ed3e1895a71f003bc65a655045ac
|
7
|
+
data.tar.gz: '069e6744aff50f322c59396abeacb7425938f7e2d80dfdf1bdc339c52570bc83f6b5d23381dd59052d57e7e072201dc7300e4daf84d3ce04917db1a6b3efe04e'
|
@@ -9,7 +9,6 @@ module Gwtools
|
|
9
9
|
def initialize(file_path, target_path = '')
|
10
10
|
@file_path = file_path || raise(ArgumentError, 'Missing required argument `file_path`')
|
11
11
|
@target_path = target_path
|
12
|
-
|
13
12
|
analyDataStr
|
14
13
|
end
|
15
14
|
|
@@ -63,7 +62,6 @@ module Gwtools
|
|
63
62
|
@body,
|
64
63
|
@responseJson
|
65
64
|
)
|
66
|
-
# end
|
67
65
|
end
|
68
66
|
|
69
67
|
def getURL
|
@@ -20,6 +20,24 @@ module Gwtools
|
|
20
20
|
# @ENUMS = enums
|
21
21
|
# end
|
22
22
|
|
23
|
+
def self.add_quotes(array1, array2)
|
24
|
+
array1.map do |element|
|
25
|
+
if array2.include?(element)
|
26
|
+
"`#{element}`"
|
27
|
+
else
|
28
|
+
element
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.output_content(config_file)
|
34
|
+
# 处理特殊字符
|
35
|
+
this_name = Parser.extract_enum_name(config_file)
|
36
|
+
array1 = this_name.split(".")
|
37
|
+
array2 = %w[enum struct class protocol extension self]
|
38
|
+
return config_file.gsub(this_name, add_quotes(array1, array2).join("."))
|
39
|
+
end
|
40
|
+
|
23
41
|
def self.read_file(file_path)
|
24
42
|
swift_file = File.open(file_path, "r")
|
25
43
|
file_content = swift_file.read.force_encoding("UTF-8")
|
@@ -195,31 +213,13 @@ module Gwtools
|
|
195
213
|
enum
|
196
214
|
end
|
197
215
|
|
198
|
-
def add_quotes(array1, array2)
|
199
|
-
array1.map do |element|
|
200
|
-
if array2.include?(element)
|
201
|
-
"#{element}_"
|
202
|
-
else
|
203
|
-
element
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def output_content(config_file)
|
209
|
-
# 处理特殊字符
|
210
|
-
this_name = Parser.extract_enum_name(config_file)
|
211
|
-
array1 = this_name.split(".")
|
212
|
-
array2 = %w[enum struct class protocol extension self]
|
213
|
-
return config_file.gsub(this_name, add_quotes(array1, array2).join("."))
|
214
|
-
end
|
215
|
-
|
216
216
|
def to_swift()
|
217
217
|
content_str = "public enum #{@enum_name} {\n"
|
218
218
|
@sub_enums.each do |key, value|
|
219
219
|
content_str += value.to_swift()
|
220
220
|
end
|
221
221
|
content_str += "}\n"
|
222
|
-
return output_content(content_str)
|
222
|
+
return Parser.output_content(content_str)
|
223
223
|
end
|
224
224
|
|
225
225
|
def write_to_file(file_path)
|
@@ -21,7 +21,11 @@ module Gwtools
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def run
|
24
|
-
FileHandler.new(@file_path, @target_path)
|
24
|
+
fh = FileHandler.new(@file_path, @target_path)
|
25
|
+
|
26
|
+
# File.rename("#{target_path + '/' + app_name}.swift_", "#{target_path + '/' + app_name}.swift")
|
27
|
+
# `swiftformat --swiftversion 5.0 "#{target_path + '/' + app_name}.swift",`
|
28
|
+
|
25
29
|
end
|
26
30
|
|
27
31
|
end
|
@@ -64,26 +64,10 @@ public extension <%="#{@api_name}"%> {
|
|
64
64
|
<% end %>
|
65
65
|
}
|
66
66
|
}
|
67
|
-
ERB
|
68
|
-
ERB.new(template, nil, '>').result(binding)
|
69
|
-
end
|
70
67
|
|
71
|
-
def add_quotes(array1, array2)
|
72
|
-
array1.map do |element|
|
73
|
-
if array2.include?(element)
|
74
|
-
"#{element}_"
|
75
|
-
else
|
76
|
-
element
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
68
|
|
81
|
-
|
82
|
-
|
83
|
-
this_name = Parser.extract_enum_name(config_file)
|
84
|
-
array1 = this_name.split(".")
|
85
|
-
array2 = %w[enum struct class protocol extension self]
|
86
|
-
return config_file.gsub(this_name, add_quotes(array1, array2).join("."))
|
69
|
+
ERB
|
70
|
+
ERB.new(template, nil, '>').result(binding)
|
87
71
|
end
|
88
72
|
|
89
73
|
def initialize(file_path, api_name, httpmethod, prefixPath, modulePath, detailPath,
|
@@ -99,8 +83,16 @@ public extension <%="#{@api_name}"%> {
|
|
99
83
|
@readme = readme
|
100
84
|
puts "write to ==> #{file_path}"
|
101
85
|
File.open(file_path, 'w+') do |f|
|
102
|
-
puts
|
103
|
-
f.puts(
|
86
|
+
# f.puts(Parser.output_content(config_file))
|
87
|
+
f.puts(config_file)
|
88
|
+
end
|
89
|
+
|
90
|
+
# 格式化
|
91
|
+
`swiftformat --swiftversion 5.0 #{file_path}`
|
92
|
+
# 替换内容,重新写入
|
93
|
+
replaced_content = File.read(file_path)
|
94
|
+
File.open(file_path, "w") do |new_file|
|
95
|
+
new_file.puts(Parser.output_content(replaced_content))
|
104
96
|
end
|
105
97
|
end
|
106
98
|
end
|
@@ -223,6 +215,8 @@ extension <##SomeViewModel##> {
|
|
223
215
|
.catchErrorJustReturn([])
|
224
216
|
}
|
225
217
|
}
|
218
|
+
|
219
|
+
public extension app_api.api.v1_0.complaintsComments.protocol.getProtocols {}
|
226
220
|
"""
|
227
221
|
|
228
222
|
ModelReqGenerateConfig.new(
|
@@ -237,11 +231,6 @@ extension <##SomeViewModel##> {
|
|
237
231
|
responseJson[root_path].is_a?(Array),
|
238
232
|
readme
|
239
233
|
)
|
240
|
-
|
241
|
-
`swiftformat --swiftversion 5.0 "#{target_path + '/' + app_name}.swift",`
|
242
|
-
|
243
|
-
# puts target_swift_file = "#{target_path}/#{app_name}.swift"
|
244
|
-
|
245
234
|
end
|
246
235
|
|
247
236
|
def self.capitalize_first_letter(str)
|
data/lib/gwtools/version.rb
CHANGED