mt_tool 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/mt_tool.iml +5 -23
- data/Gemfile.lock +1 -1
- data/bin/mt_tool +7 -0
- data/lib/mt_tool/commands.rb +30 -24
- data/lib/mt_tool/template/objc/Bundle.h +21 -0
- data/lib/mt_tool/template/objc/Bundle.m +28 -0
- data/lib/mt_tool/template/objc/CategoryHeader.h +1 -0
- data/lib/mt_tool/template/objc/PrefixHeader.pch +6 -0
- data/lib/mt_tool/template/objc/ToolsHeader.h +1 -1
- data/lib/mt_tool/version.rb +1 -1
- data/mt_tool.gemspec +3 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca57bd0d4463ef855c164f414da4a25d00c535340e647d23001df1ad21273eec
|
4
|
+
data.tar.gz: 10037e4818e9a08eb3451d7afd3acf82d3053780ef742850029529540b50111b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73e7e99cf89c345b4c276be4bf73f3d1181aca067a11087a45f5253065f051d6d9c23f5b59999a3a91acdcce15588bb4aeea662a9384f020e28554bdc62d7d97
|
7
|
+
data.tar.gz: a9a42acdcb1c78cf115c2c6e62d2c3fac6e479f1ad9fcf407543d66b984fab36474990076be7279840db6e05bb1c7e796bd101bf667eef8493b0b02506bfe8c3
|
data/.idea/mt_tool.iml
CHANGED
@@ -12,24 +12,12 @@
|
|
12
12
|
<orderEntry type="inheritedJdk" />
|
13
13
|
<orderEntry type="sourceFolder" forTests="false" />
|
14
14
|
<orderEntry type="library" scope="PROVIDED" name="CFPropertyList (v3.0.5, RVM: ruby-2.7.2) [gem]" level="application" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.5, RVM: ruby-2.7.2) [gem]" level="application" />
|
16
15
|
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
17
16
|
<orderEntry type="library" scope="PROVIDED" name="algoliasearch (v1.27.5, RVM: ruby-2.7.2) [gem]" level="application" />
|
18
17
|
<orderEntry type="library" scope="PROVIDED" name="atomos (v0.1.3, RVM: ruby-2.7.2) [gem]" level="application" />
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.11, RVM: ruby-2.7.2) [gem]" level="application" />
|
20
18
|
<orderEntry type="library" scope="PROVIDED" name="claide (v1.1.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="cocoapods (v1.11.3, RVM: ruby-2.7.2) [gem]" level="application" />
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="cocoapods-core (v1.11.3, RVM: ruby-2.7.2) [gem]" level="application" />
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="cocoapods-deintegrate (v1.0.5, RVM: ruby-2.7.2) [gem]" level="application" />
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="cocoapods-downloader (v1.6.3, RVM: ruby-2.7.2) [gem]" level="application" />
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="cocoapods-plugins (v1.0.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="cocoapods-search (v1.0.1, RVM: ruby-2.7.2) [gem]" level="application" />
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="cocoapods-trunk (v1.6.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="cocoapods-try (v1.2.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
29
19
|
<orderEntry type="library" scope="PROVIDED" name="colored (v1.2, RVM: ruby-2.7.2) [gem]" level="application" />
|
30
20
|
<orderEntry type="library" scope="PROVIDED" name="colored2 (v3.1.2, RVM: ruby-2.7.2) [gem]" level="application" />
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, RVM: ruby-2.7.2) [gem]" level="application" />
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
33
21
|
<orderEntry type="library" scope="PROVIDED" name="escape (v0.0.4, RVM: ruby-2.7.2) [gem]" level="application" />
|
34
22
|
<orderEntry type="library" scope="PROVIDED" name="ethon (v0.15.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
35
23
|
<orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.5, RVM: ruby-2.7.2) [gem]" level="application" />
|
@@ -40,24 +28,18 @@
|
|
40
28
|
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
41
29
|
<orderEntry type="library" scope="PROVIDED" name="json (v2.6.1, RVM: ruby-2.7.2) [gem]" level="application" />
|
42
30
|
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
43
|
-
<orderEntry type="library" scope="PROVIDED" name="molinillo (v0.8.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
44
31
|
<orderEntry type="library" scope="PROVIDED" name="nanaimo (v0.3.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
45
32
|
<orderEntry type="library" scope="PROVIDED" name="nap (v1.1.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
46
33
|
<orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
47
|
-
<orderEntry type="library" scope="PROVIDED" name="pathname (v0.2.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
48
|
-
<orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.7, RVM: ruby-2.7.2) [gem]" level="application" />
|
49
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.2) [gem]" level="application" />
|
50
34
|
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-2.7.2) [gem]" level="application" />
|
51
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
52
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
53
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
54
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, RVM: ruby-2.7.2) [gem]" level="application" />
|
55
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
56
35
|
<orderEntry type="library" scope="PROVIDED" name="ruby-macho (v2.5.1, RVM: ruby-2.7.2) [gem]" level="application" />
|
57
36
|
<orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.2) [gem]" level="application" />
|
58
37
|
<orderEntry type="library" scope="PROVIDED" name="typhoeus (v1.4.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
59
|
-
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, RVM: ruby-2.7.2) [gem]" level="application" />
|
60
38
|
<orderEntry type="library" scope="PROVIDED" name="xcodeproj (v1.21.0, RVM: ruby-2.7.2) [gem]" level="application" />
|
61
|
-
|
39
|
+
</component>
|
40
|
+
<component name="RakeTasksCache">
|
41
|
+
<option name="myRootTask">
|
42
|
+
<RakeTaskImpl id="rake" />
|
43
|
+
</option>
|
62
44
|
</component>
|
63
45
|
</module>
|
data/Gemfile.lock
CHANGED
data/bin/mt_tool
ADDED
data/lib/mt_tool/commands.rb
CHANGED
@@ -12,7 +12,8 @@ module MtTool
|
|
12
12
|
|
13
13
|
desc 'generate <Path> <Module Name> <Language> <Prefix - 前缀> <Author - 作者>', '直接生成项目 例子: yk_command generate . HomeModule oc MT Tom.Liu '
|
14
14
|
method_option :generate, aliases: '-g'
|
15
|
-
|
15
|
+
|
16
|
+
def generate(path = nil, name, lang, class_prefix, author)
|
16
17
|
@name = name
|
17
18
|
@module = @name
|
18
19
|
@lang = lang
|
@@ -39,6 +40,7 @@ module MtTool
|
|
39
40
|
|
40
41
|
desc 'create <Path>', '在某个路径下交互式生成项目'
|
41
42
|
method_option :create, aliases: '-c'
|
43
|
+
|
42
44
|
def create(path = nil)
|
43
45
|
path = Dir.pwd if path.nil?
|
44
46
|
|
@@ -91,10 +93,10 @@ module MtTool
|
|
91
93
|
say '文件作者:', :green
|
92
94
|
author = ask("Author [#{config[:author]}] ?")
|
93
95
|
|
94
|
-
config[:project]
|
95
|
-
config[:language]
|
96
|
+
config[:project] = project.empty? ? config[:project] || '' : project
|
97
|
+
config[:language] = language.empty? ? config[:language] || 'objc' : language
|
96
98
|
config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
|
97
|
-
config[:author]
|
99
|
+
config[:author] = author.empty? ? config[:author] || '' : author
|
98
100
|
|
99
101
|
File.open(config_file_path, 'w') do |f|
|
100
102
|
f.write config.to_yaml
|
@@ -104,9 +106,9 @@ module MtTool
|
|
104
106
|
@module = @name
|
105
107
|
@class_prefix = config[:class_prefix]
|
106
108
|
@prefixed_module = config[:class_prefix] + @module
|
107
|
-
@project
|
108
|
-
@author
|
109
|
-
@date
|
109
|
+
@project = config[:project]
|
110
|
+
@author = config[:author]
|
111
|
+
@date = Time.now.strftime('%d/%m/%y')
|
110
112
|
@lang = config[:language]
|
111
113
|
end
|
112
114
|
|
@@ -138,8 +140,6 @@ module MtTool
|
|
138
140
|
empty_directory path
|
139
141
|
end
|
140
142
|
|
141
|
-
|
142
|
-
|
143
143
|
private_level_folders.each do |folder|
|
144
144
|
path = "#{class_folder_path}/Private/#{folder}"
|
145
145
|
empty_directory path
|
@@ -151,10 +151,10 @@ module MtTool
|
|
151
151
|
def yk_template_files
|
152
152
|
register_path = "#{@final_path}/#{@name}/Classes/Private/Register"
|
153
153
|
registger = {
|
154
|
-
'RouterRegister.h'
|
155
|
-
'RouterRegister.m'
|
156
|
-
'ServiceRegister.h'
|
157
|
-
'ServiceRegister.m'
|
154
|
+
'RouterRegister.h' => 'RouterRegister',
|
155
|
+
'RouterRegister.m' => 'RouterRegister',
|
156
|
+
'ServiceRegister.h' => 'ServiceRegister',
|
157
|
+
'ServiceRegister.m' => 'ServiceRegister'
|
158
158
|
}
|
159
159
|
|
160
160
|
registger.each do |file_name, _folder|
|
@@ -164,7 +164,7 @@ module MtTool
|
|
164
164
|
|
165
165
|
public_folder_path = "#{@final_path}/#{@name}/Classes/Public"
|
166
166
|
|
167
|
-
template_code_filename = ['ServiceProtocol.h','RouterDefine.h']
|
167
|
+
template_code_filename = ['ServiceProtocol.h', 'RouterDefine.h']
|
168
168
|
template_code_filename.each do |file_name|
|
169
169
|
final_file = "#{public_folder_path}/#{@prefixed_module}#{file_name}"
|
170
170
|
source = "#{__dir__}/template/objc/#{file_name}"
|
@@ -178,8 +178,6 @@ module MtTool
|
|
178
178
|
template source, final_file
|
179
179
|
end
|
180
180
|
|
181
|
-
|
182
|
-
|
183
181
|
private_folder_path = "#{@final_path}/#{@name}/Classes/Private"
|
184
182
|
#pch file
|
185
183
|
# pch_file_name = "PrefixHeader.pch"
|
@@ -188,10 +186,10 @@ module MtTool
|
|
188
186
|
# template source, final_file
|
189
187
|
|
190
188
|
private_level_folder_files = {
|
191
|
-
'PrefixHeader.pch'
|
192
|
-
'CategoryHeader.h'
|
193
|
-
'ToolsHeader.h'
|
194
|
-
'vendorHeader.h'
|
189
|
+
'PrefixHeader.pch' => 'Business',
|
190
|
+
'CategoryHeader.h' => 'Category',
|
191
|
+
'ToolsHeader.h' => 'Tools',
|
192
|
+
'vendorHeader.h' => 'Vendor'
|
195
193
|
}
|
196
194
|
|
197
195
|
private_level_folder_files.each do |file_name, folder|
|
@@ -205,16 +203,23 @@ module MtTool
|
|
205
203
|
template source, final_file
|
206
204
|
end
|
207
205
|
|
206
|
+
tools_files_path = "#{@final_path}/#{@name}/Classes/Private/Tools"
|
207
|
+
|
208
|
+
tool_files = ['Bundle.h','Bundle.m']
|
209
|
+
tool_files.each do |file_name|
|
210
|
+
final_file = "#{tools_files_path}/#{@prefixed_module}#{file_name}"
|
211
|
+
source = "#{__dir__}/template/objc/#{file_name}"
|
212
|
+
template source, final_file
|
213
|
+
end
|
214
|
+
|
208
215
|
business_demo_path = "#{@final_path}/#{@name}/Classes/Private/Business"
|
209
|
-
demo_replace_file = ['DemoViewController.h','DemoViewController.m','DemoViewModel.h','DemoViewModel.m']
|
216
|
+
demo_replace_file = ['DemoViewController.h', 'DemoViewController.m', 'DemoViewModel.h', 'DemoViewModel.m']
|
210
217
|
demo_replace_file.each do |file_name|
|
211
218
|
final_file = "#{business_demo_path}/Demo/#{@prefixed_module}#{file_name}"
|
212
219
|
source = "#{__dir__}/template/objc/demo/#{file_name}"
|
213
220
|
template source, final_file
|
214
221
|
end
|
215
222
|
|
216
|
-
|
217
|
-
|
218
223
|
Dir.chdir("#{@final_path}/Example") do
|
219
224
|
system 'pod install'
|
220
225
|
system "open './#{@name}.xcworkspace'"
|
@@ -225,8 +230,9 @@ module MtTool
|
|
225
230
|
|
226
231
|
desc 'dependency <Podfile.lock Path>', '解析Podfile.lock'
|
227
232
|
method_option :dependency, aliases: '-d'
|
233
|
+
|
228
234
|
def dependency(path = nil)
|
229
|
-
say 'start resolve dependency'
|
235
|
+
say 'start resolve dependency', :green
|
230
236
|
|
231
237
|
analyzer = Analyzer.new
|
232
238
|
result = analyzer.analyze(path)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
//
|
2
|
+
// <%= @prefixed_module %>Bundle.h
|
3
|
+
// <%= @project %>
|
4
|
+
//
|
5
|
+
// Created by <%= @author %> on <%= @date %>.
|
6
|
+
//
|
7
|
+
//
|
8
|
+
|
9
|
+
|
10
|
+
#import <Foundation/Foundation.h>
|
11
|
+
|
12
|
+
NS_ASSUME_NONNULL_BEGIN
|
13
|
+
|
14
|
+
@interface <%= @prefixed_module %>Bundle : NSObject
|
15
|
+
|
16
|
+
+ (UINib *)bundlerNib:(NSString *)nibName ;
|
17
|
+
+ (NSBundle *)currentBundle;
|
18
|
+
|
19
|
+
@end
|
20
|
+
|
21
|
+
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,28 @@
|
|
1
|
+
//
|
2
|
+
// <%= @prefixed_module %>Bundle.m
|
3
|
+
// <%= @project %>
|
4
|
+
//
|
5
|
+
// Created by <%= @author %> on <%= @date %>.
|
6
|
+
//
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "<%= @prefixed_module %>Bundle.h"
|
10
|
+
|
11
|
+
@implementation <%= @prefixed_module %>Bundle
|
12
|
+
|
13
|
+
+ (UINib *)bundlerNib:(NSString *)nibName {
|
14
|
+
return [UINib nibWithNibName:nibName bundle:[self currentBundle]];
|
15
|
+
}
|
16
|
+
|
17
|
+
+ (NSBundle *)currentBundle {
|
18
|
+
NSString *bundleName = @"<%= @project %>";
|
19
|
+
NSURL *associateBundleURL = [[NSBundle mainBundle] URLForResource:bundleName withExtension:@"bundle"];
|
20
|
+
if (!associateBundleURL) {
|
21
|
+
NSBundle *subBundle = [NSBundle bundleForClass:self];
|
22
|
+
associateBundleURL = [subBundle URLForResource:bundleName withExtension:@"bundle"];
|
23
|
+
}
|
24
|
+
NSBundle *bundle = [NSBundle bundleWithURL:associateBundleURL];
|
25
|
+
return bundle;
|
26
|
+
}
|
27
|
+
|
28
|
+
@end
|
@@ -22,6 +22,12 @@
|
|
22
22
|
#import "<%= @prefixed_module %>VendorHeader.h"
|
23
23
|
#import "<%= @prefixed_module %>ToolsHeader.h"
|
24
24
|
|
25
|
+
#import <MTBaseKit/MTBaseKitHeader.h>
|
26
|
+
#import <MTCategoryComponent/MTCategoryComponentHeader.h>
|
27
|
+
#import <MTLayoutUtilityComponent/MTLayoutUtilityComponentHeader.h>
|
28
|
+
#import <AssetModule/MTModuleImage.h>
|
29
|
+
#import <MJExtension/MJExtension.h>
|
30
|
+
|
25
31
|
#endif
|
26
32
|
|
27
33
|
|
data/lib/mt_tool/version.rb
CHANGED
data/mt_tool.gemspec
CHANGED
@@ -22,9 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
spec.bindir = "bin"
|
25
|
-
spec.executables = spec.files.grep(%r{\
|
25
|
+
# spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
26
|
+
spec.executables << 'mt_tool'
|
26
27
|
spec.require_paths = ["lib"]
|
27
28
|
|
29
|
+
|
28
30
|
# Uncomment to register a new dependency of your gem
|
29
31
|
# spec.add_dependency "example-gem", "~> 1.0"
|
30
32
|
spec.add_development_dependency 'bundler'
|
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.
|
4
|
+
version: 0.1.3
|
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-
|
11
|
+
date: 2022-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -195,7 +195,8 @@ dependencies:
|
|
195
195
|
description: 常用工具 -- 快速创建模版代码.
|
196
196
|
email:
|
197
197
|
- v2top1lyle@gmail.com
|
198
|
-
executables:
|
198
|
+
executables:
|
199
|
+
- mt_tool
|
199
200
|
extensions: []
|
200
201
|
extra_rdoc_files: []
|
201
202
|
files:
|
@@ -209,9 +210,12 @@ files:
|
|
209
210
|
- Gemfile.lock
|
210
211
|
- README.md
|
211
212
|
- Rakefile
|
213
|
+
- bin/mt_tool
|
212
214
|
- lib/mt_tool.rb
|
213
215
|
- lib/mt_tool/analyze.rb
|
214
216
|
- lib/mt_tool/commands.rb
|
217
|
+
- lib/mt_tool/template/objc/Bundle.h
|
218
|
+
- lib/mt_tool/template/objc/Bundle.m
|
215
219
|
- lib/mt_tool/template/objc/CategoryHeader.h
|
216
220
|
- lib/mt_tool/template/objc/PrefixHeader.pch
|
217
221
|
- lib/mt_tool/template/objc/RouterDefine.h
|
@@ -250,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
254
|
- !ruby/object:Gem::Version
|
251
255
|
version: '0'
|
252
256
|
requirements: []
|
253
|
-
rubygems_version: 3.
|
257
|
+
rubygems_version: 3.1.4
|
254
258
|
signing_key:
|
255
259
|
specification_version: 4
|
256
260
|
summary: 常用工具.
|