gwtools 0.0.16 → 0.0.17
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/gwtools/analysis/file_handler.rb +0 -18
- data/lib/gwtools/analysis/swift_parser.rb +21 -2
- data/lib/gwtools/generate/swift.rb +21 -2
- data/lib/gwtools/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: 70d808a737fd03e736ac1f86a7af6b840662f983598f6fa3055ef5e02413afb3
|
4
|
+
data.tar.gz: 38a8c1a3c3a3620fbd91e2067114bdb511c23e3ad813ea51d5aeabce3d21a799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08f5e834d9273fd23a5a62f86ce383c5e72a0f5f99c445272d33b64625e79015a743f152e6dd98e50e863485e7380630714de7eb12b0031ce43ae14a9d47d6cb'
|
7
|
+
data.tar.gz: 383d8c48e3a9964354d0e015827010f01e44bff50485e8d7551512a8e5186d4844ddc9e9f806005e109a755a3f0e91b6faf77151c60f6f93cefef4d080fbf987
|
@@ -66,24 +66,6 @@ module Gwtools
|
|
66
66
|
# end
|
67
67
|
end
|
68
68
|
|
69
|
-
# def createSwiftFile(dir_path)
|
70
|
-
# File.open("#{dir_path}.swift", "w") do |file|
|
71
|
-
# # write swift file content
|
72
|
-
# if index == 0
|
73
|
-
# file.write("extension AppAPI { \n")
|
74
|
-
# else
|
75
|
-
# file.write("extension AppAPI.#{dirs[0..index-1].join('.')} { \n")
|
76
|
-
# end
|
77
|
-
# file.write(" public struct #{dir} { } \n")
|
78
|
-
# file.write("}")
|
79
|
-
# end
|
80
|
-
#
|
81
|
-
#
|
82
|
-
# # File.open("#{dir_path}.swift", "w") do |file|
|
83
|
-
# #
|
84
|
-
# # end
|
85
|
-
# end
|
86
|
-
|
87
69
|
def getURL
|
88
70
|
match = /^URL = (.*)$/.match(@data_str)
|
89
71
|
if match
|
@@ -96,7 +96,7 @@ module Gwtools
|
|
96
96
|
|
97
97
|
def self.extract_enum_name(content)
|
98
98
|
# return content.scan(/^\w+\s+extension\s+(\w+)\s+\{/).flatten + content.scan(/^\w+\s+enum\s+(\w+)\s+\{/).flatten
|
99
|
-
return (content.scan(/enum\s+(\w+)\s+\{/).flatten + content.scan(/extension\s+(\w+)\s+\{/).flatten).first
|
99
|
+
return (content.scan(/enum\s+([\w.]+)\s+\{/).flatten + content.scan(/extension\s+([\w.]+)\s+\{/).flatten).first
|
100
100
|
end
|
101
101
|
|
102
102
|
# 根据括号匹配enums内容
|
@@ -127,6 +127,7 @@ module Gwtools
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def self.extract_enum(content, parent_enum = nil)
|
130
|
+
content.gsub!('`','')
|
130
131
|
level = parent_enum.nil? ? 0 : parent_enum.level
|
131
132
|
pre_name = parent_enum.nil? ? '' : "#{parent_enum.path}."
|
132
133
|
enum_codes = extract_enums_content(content)
|
@@ -194,13 +195,31 @@ module Gwtools
|
|
194
195
|
enum
|
195
196
|
end
|
196
197
|
|
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
|
+
|
197
216
|
def to_swift()
|
198
217
|
content_str = "public enum #{@enum_name} {\n"
|
199
218
|
@sub_enums.each do |key, value|
|
200
219
|
content_str += value.to_swift()
|
201
220
|
end
|
202
221
|
content_str += "}\n"
|
203
|
-
return content_str
|
222
|
+
return output_content(content_str)
|
204
223
|
end
|
205
224
|
|
206
225
|
def write_to_file(file_path)
|
@@ -68,6 +68,24 @@ public extension <%="#{@api_name}"%> {
|
|
68
68
|
ERB.new(template, nil, '>').result(binding)
|
69
69
|
end
|
70
70
|
|
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
|
+
|
81
|
+
def output_content(config_file)
|
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("."))
|
87
|
+
end
|
88
|
+
|
71
89
|
def initialize(file_path, api_name, httpmethod, prefixPath, modulePath, detailPath,
|
72
90
|
model_name, model_data, json_data_is_arr, readme)
|
73
91
|
@api_name = api_name
|
@@ -81,7 +99,8 @@ public extension <%="#{@api_name}"%> {
|
|
81
99
|
@readme = readme
|
82
100
|
puts "write to ==> #{file_path}"
|
83
101
|
File.open(file_path, 'w+') do |f|
|
84
|
-
|
102
|
+
puts output_content(config_file)
|
103
|
+
f.puts(output_content(config_file))
|
85
104
|
end
|
86
105
|
end
|
87
106
|
end
|
@@ -100,7 +119,7 @@ public extension <%="#{@api_name}"%> {
|
|
100
119
|
end
|
101
120
|
|
102
121
|
def self.getModulePath(dir_path, prefixPath)
|
103
|
-
modulePaths = %w[content community]
|
122
|
+
modulePaths = %w[content community complaintsComments technician]
|
104
123
|
dir_path = dir_path.gsub(/\A#{prefixPath}/, "").gsub(/^\/|\/$/, "")
|
105
124
|
|
106
125
|
modulePaths.each do |modulePath|
|
data/lib/gwtools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gwtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chenglq
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write a longer description or delete this line.
|
14
14
|
email:
|