mt_tool 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/mt_tool.iml +77 -27
  3. data/.idea/sonarlint/issuestore/4/7/4745e92ab1b53af3e65026337909045741e13bea +0 -0
  4. data/.idea/sonarlint/issuestore/5/2/5283f86f6adbda087dceb47c69b64e141dfb1e93 +0 -0
  5. data/.idea/sonarlint/issuestore/7/0/70213f721c971c9a12d0f46060f7ee2a087b4a96 +0 -0
  6. data/.idea/sonarlint/issuestore/b/5/b53eec12e0ab8df9876dbc7fe65915bb985c4f72 +0 -0
  7. data/.idea/sonarlint/issuestore/e/8/e84cc700d4480c1d3ca7dcc158063e40a25cee12 +0 -0
  8. data/.idea/sonarlint/issuestore/f/8/f80e2edcdaf9ddf9362d26f7fa5d19df422f29c7 +0 -0
  9. data/.idea/sonarlint/issuestore/index.pb +13 -0
  10. data/Gemfile.lock +7 -3
  11. data/README.md +18 -7
  12. data/img/69786f8e2a527b8c26f2c1311e230e5f.webp.png +0 -0
  13. data/img/SCR-20240619-msnz.png +0 -0
  14. data/lib/mt_tool/commands.rb +23 -216
  15. data/lib/mt_tool/module/module.rb +275 -0
  16. data/lib/mt_tool/module/template/swift/Entity.swift +15 -0
  17. data/lib/mt_tool/module/template/swift/Interactor.swift +16 -0
  18. data/lib/mt_tool/module/template/swift/Presenter.swift +28 -0
  19. data/lib/mt_tool/module/template/swift/Router.swift +50 -0
  20. data/lib/mt_tool/module/template/swift/ViewController.swift +97 -0
  21. data/lib/mt_tool/oc_model/main.rb +112 -0
  22. data/lib/mt_tool/oc_model/oc_model.rb +235 -0
  23. data/lib/mt_tool/oc_model/sample.json +11 -0
  24. data/lib/mt_tool/short_hand/objc_generate_from_shorthand.rb +182 -0
  25. data/lib/mt_tool/short_hand/objc_header.mustache +41 -0
  26. data/lib/mt_tool/short_hand/objc_implementation.mustache +99 -0
  27. data/lib/mt_tool/short_hand/objc_shorthand.rb +64 -0
  28. data/lib/mt_tool/version.rb +1 -1
  29. data/mt_tool.gemspec +3 -1
  30. metadata +84 -21
  31. data/lib/mt_tool/analyze.rb +0 -126
  32. /data/lib/mt_tool/{template → module/template}/objc/Bundle.h +0 -0
  33. /data/lib/mt_tool/{template → module/template}/objc/Bundle.m +0 -0
  34. /data/lib/mt_tool/{template → module/template}/objc/CategoryHeader.h +0 -0
  35. /data/lib/mt_tool/{template → module/template}/objc/PrefixHeader.pch +0 -0
  36. /data/lib/mt_tool/{template → module/template}/objc/RouterDefine.h +0 -0
  37. /data/lib/mt_tool/{template → module/template}/objc/RouterRegister.h +0 -0
  38. /data/lib/mt_tool/{template → module/template}/objc/RouterRegister.m +0 -0
  39. /data/lib/mt_tool/{template → module/template}/objc/ServiceProtocol.h +0 -0
  40. /data/lib/mt_tool/{template → module/template}/objc/ServiceRegister.h +0 -0
  41. /data/lib/mt_tool/{template → module/template}/objc/ServiceRegister.m +0 -0
  42. /data/lib/mt_tool/{template → module/template}/objc/ToolsHeader.h +0 -0
  43. /data/lib/mt_tool/{template → module/template}/objc/VendorHeader.h +0 -0
  44. /data/lib/mt_tool/{template → module/template}/objc/demo/DemoViewController.h +0 -0
  45. /data/lib/mt_tool/{template → module/template}/objc/demo/DemoViewController.m +0 -0
  46. /data/lib/mt_tool/{template → module/template}/objc/demo/DemoViewModel.h +0 -0
  47. /data/lib/mt_tool/{template → module/template}/objc/demo/DemoViewModel.m +0 -0
  48. /data/lib/mt_tool/{template → module/template}/swift/RouterDefine.swift +0 -0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mt_tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - LyleLH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-23 00:00:00.000000000 Z
11
+ date: 2024-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: colored2
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: pathname
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +206,34 @@ dependencies:
192
206
  - - ">="
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: mustache
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: activesupport
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
195
237
  description: 常用工具 -- 快速创建模版代码.
196
238
  email:
197
239
  - v2top1lyle@gmail.com
@@ -205,32 +247,53 @@ files:
205
247
  - ".idea/misc.xml"
206
248
  - ".idea/modules.xml"
207
249
  - ".idea/mt_tool.iml"
250
+ - ".idea/sonarlint/issuestore/4/7/4745e92ab1b53af3e65026337909045741e13bea"
251
+ - ".idea/sonarlint/issuestore/5/2/5283f86f6adbda087dceb47c69b64e141dfb1e93"
252
+ - ".idea/sonarlint/issuestore/7/0/70213f721c971c9a12d0f46060f7ee2a087b4a96"
253
+ - ".idea/sonarlint/issuestore/b/5/b53eec12e0ab8df9876dbc7fe65915bb985c4f72"
254
+ - ".idea/sonarlint/issuestore/e/8/e84cc700d4480c1d3ca7dcc158063e40a25cee12"
255
+ - ".idea/sonarlint/issuestore/f/8/f80e2edcdaf9ddf9362d26f7fa5d19df422f29c7"
256
+ - ".idea/sonarlint/issuestore/index.pb"
208
257
  - ".idea/vcs.xml"
209
258
  - Gemfile
210
259
  - Gemfile.lock
211
260
  - README.md
212
261
  - Rakefile
213
262
  - bin/mt_tool
263
+ - img/69786f8e2a527b8c26f2c1311e230e5f.webp.png
264
+ - img/SCR-20240619-msnz.png
214
265
  - lib/mt_tool.rb
215
- - lib/mt_tool/analyze.rb
216
266
  - lib/mt_tool/commands.rb
217
- - lib/mt_tool/template/objc/Bundle.h
218
- - lib/mt_tool/template/objc/Bundle.m
219
- - lib/mt_tool/template/objc/CategoryHeader.h
220
- - lib/mt_tool/template/objc/PrefixHeader.pch
221
- - lib/mt_tool/template/objc/RouterDefine.h
222
- - lib/mt_tool/template/objc/RouterRegister.h
223
- - lib/mt_tool/template/objc/RouterRegister.m
224
- - lib/mt_tool/template/objc/ServiceProtocol.h
225
- - lib/mt_tool/template/objc/ServiceRegister.h
226
- - lib/mt_tool/template/objc/ServiceRegister.m
227
- - lib/mt_tool/template/objc/ToolsHeader.h
228
- - lib/mt_tool/template/objc/VendorHeader.h
229
- - lib/mt_tool/template/objc/demo/DemoViewController.h
230
- - lib/mt_tool/template/objc/demo/DemoViewController.m
231
- - lib/mt_tool/template/objc/demo/DemoViewModel.h
232
- - lib/mt_tool/template/objc/demo/DemoViewModel.m
233
- - lib/mt_tool/template/swift/RouterDefine.swift
267
+ - lib/mt_tool/module/module.rb
268
+ - lib/mt_tool/module/template/objc/Bundle.h
269
+ - lib/mt_tool/module/template/objc/Bundle.m
270
+ - lib/mt_tool/module/template/objc/CategoryHeader.h
271
+ - lib/mt_tool/module/template/objc/PrefixHeader.pch
272
+ - lib/mt_tool/module/template/objc/RouterDefine.h
273
+ - lib/mt_tool/module/template/objc/RouterRegister.h
274
+ - lib/mt_tool/module/template/objc/RouterRegister.m
275
+ - lib/mt_tool/module/template/objc/ServiceProtocol.h
276
+ - lib/mt_tool/module/template/objc/ServiceRegister.h
277
+ - lib/mt_tool/module/template/objc/ServiceRegister.m
278
+ - lib/mt_tool/module/template/objc/ToolsHeader.h
279
+ - lib/mt_tool/module/template/objc/VendorHeader.h
280
+ - lib/mt_tool/module/template/objc/demo/DemoViewController.h
281
+ - lib/mt_tool/module/template/objc/demo/DemoViewController.m
282
+ - lib/mt_tool/module/template/objc/demo/DemoViewModel.h
283
+ - lib/mt_tool/module/template/objc/demo/DemoViewModel.m
284
+ - lib/mt_tool/module/template/swift/Entity.swift
285
+ - lib/mt_tool/module/template/swift/Interactor.swift
286
+ - lib/mt_tool/module/template/swift/Presenter.swift
287
+ - lib/mt_tool/module/template/swift/Router.swift
288
+ - lib/mt_tool/module/template/swift/RouterDefine.swift
289
+ - lib/mt_tool/module/template/swift/ViewController.swift
290
+ - lib/mt_tool/oc_model/main.rb
291
+ - lib/mt_tool/oc_model/oc_model.rb
292
+ - lib/mt_tool/oc_model/sample.json
293
+ - lib/mt_tool/short_hand/objc_generate_from_shorthand.rb
294
+ - lib/mt_tool/short_hand/objc_header.mustache
295
+ - lib/mt_tool/short_hand/objc_implementation.mustache
296
+ - lib/mt_tool/short_hand/objc_shorthand.rb
234
297
  - lib/mt_tool/version.rb
235
298
  - mt_tool.gemspec
236
299
  - sig/mt_tool.rbs
@@ -254,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
317
  - !ruby/object:Gem::Version
255
318
  version: '0'
256
319
  requirements: []
257
- rubygems_version: 3.1.4
320
+ rubygems_version: 3.3.3
258
321
  signing_key:
259
322
  specification_version: 4
260
323
  summary: 常用工具.
@@ -1,126 +0,0 @@
1
- require 'cocoapods'
2
- require 'pathname'
3
-
4
- require 'pp'
5
-
6
- require 'tmpdir'
7
-
8
- module MtTool
9
- #
10
- # Analyze the project using cocoapods
11
- #
12
- class Analyzer
13
- def analyze(podfile_dir_path)
14
-
15
- @path = Pathname.new(podfile_dir_path)
16
- @podFile = Pod::Podfile.from_file(@path + 'Podfile')
17
- @podLock = Pod::Lockfile.from_file(@path + 'Podfile.lock')
18
-
19
-
20
- raise 'absolute path is needed' unless @path.absolute?
21
-
22
- Dir.chdir(podfile_dir_path) do
23
- analyze_with_podfile
24
- end
25
- end
26
-
27
-
28
-
29
- def analyze_with_podfile
30
- # if @path
31
- # sandbox = Dir.mktmpdir
32
- # else
33
- # sandbox = Dir.pwd + '/Pods'
34
- # end
35
- #
36
-
37
- sandbox = Dir.pwd + '/Pods'
38
-
39
- analyzer = Pod::Installer::Analyzer.new(
40
- Pod::Sandbox.new(sandbox),
41
- @podFile,
42
- # @podLock
43
- )
44
-
45
- specifications = analyzer.analyze.specifications.map(&:root).uniq
46
-
47
- podfile_dependency = podfile_dependencies(@podFile)
48
-
49
- map = {}
50
- specifications.each do |s|
51
- map[s.name] = if s.default_subspecs.count > 0
52
- subspecs_with_name(s, s.default_subspecs) + s.dependencies
53
- else
54
- s.subspecs + s.dependencies
55
- end
56
-
57
- subspecs_in_podfile = podfile_dependency.select { |pd|
58
- pd.split('/')[0] == s.name
59
- }
60
- sp = subspecs_in_podfile.map { |sip|
61
- s.subspecs.find { |ss|
62
- ss.name == sip
63
- }
64
- }.compact
65
-
66
- map[s.name] = sp if sp.count != 0
67
- s.subspecs.each do |ss|
68
- map[ss.name] = ss.dependencies
69
- end
70
-
71
- end
72
-
73
- # for performance
74
- dependencies_map = {}
75
- specifications.each do |s|
76
- dependencies_map[s.name] = s
77
- end
78
-
79
- new_map = {}
80
- specifications.each do |s|
81
- new_map[s.name] = find_dependencies(s.name, map, [], dependencies_map, s.name).uniq.sort
82
- end
83
-
84
- new_map
85
- end
86
-
87
- def podfile_dependencies(podfile)
88
- res = []
89
- podfile.root_target_definitions.each do |td|
90
- children_definitions = td.recursive_children
91
- children_definitions.each do |cd|
92
- dependencies_hash_array = cd.send(:get_hash_value, 'dependencies')
93
- next if dependencies_hash_array.nil? || dependencies_hash_array.count.zero?
94
-
95
- dependencies_hash_array.each do |item|
96
- next if item.class.name != 'Hash'
97
-
98
- item.each do |name, _|
99
- res.push name
100
- end
101
- end
102
- end
103
- end
104
- res
105
- end
106
-
107
- def find_dependencies(name, map, res, dependencies_map, root_name)
108
- return unless map[name]
109
-
110
- map[name].each do |k|
111
- find_dependencies(k.name, map, res, dependencies_map, root_name)
112
- dependency = dependencies_map[k.name.split('/')[0]]
113
- res.push dependency.name if dependency && dependency.name != root_name
114
- end
115
- res
116
- end
117
-
118
- def subspecs_with_name(spec, subspecs_short_names)
119
- subspecs_short_names.map do |name|
120
- spec.subspecs.find { |ss| ss.name.include? name }
121
- end
122
- end
123
-
124
-
125
- end
126
- end