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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca57bd0d4463ef855c164f414da4a25d00c535340e647d23001df1ad21273eec
4
- data.tar.gz: 10037e4818e9a08eb3451d7afd3acf82d3053780ef742850029529540b50111b
3
+ metadata.gz: 7eeca6fee7bb5bc02cf6b281ce04c8da18558905941f1a7513d6856e95b32196
4
+ data.tar.gz: 24c54d8d84e44111c10c59c6c4fa6b8dc310d4d7476f783f7cf4ffcaa2081af9
5
5
  SHA512:
6
- metadata.gz: 73e7e99cf89c345b4c276be4bf73f3d1181aca067a11087a45f5253065f051d6d9c23f5b59999a3a91acdcce15588bb4aeea662a9384f020e28554bdc62d7d97
7
- data.tar.gz: a9a42acdcb1c78cf115c2c6e62d2c3fac6e479f1ad9fcf407543d66b984fab36474990076be7279840db6e05bb1c7e796bd101bf667eef8493b0b02506bfe8c3
6
+ metadata.gz: fb3f3a03a6164a4741ad8287063855f8f660dfc51d7cbe688a3123d36f52c3880ab7c6ed1894aa08b2fd9ad386ea39b114758cb16cffd659dbcde2ba307edc6f
7
+ data.tar.gz: dc821d39412af58a762319d7e1aa378f58a478a09a440cc4b8d4ec7cd353694e6b23c911d1938d4304e95c39562039c76d730aac892d20b62cea8584970936bd
data/.idea/mt_tool.iml CHANGED
@@ -9,37 +9,87 @@
9
9
  <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
10
  <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
11
  </content>
12
- <orderEntry type="inheritedJdk" />
12
+ <orderEntry type="jdk" jdkName="ruby-3.1.0-p0" jdkType="RUBY_SDK" />
13
13
  <orderEntry type="sourceFolder" forTests="false" />
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="addressable (v2.8.0, RVM: ruby-2.7.2) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="algoliasearch (v1.27.5, RVM: ruby-2.7.2) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="atomos (v0.1.3, RVM: ruby-2.7.2) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="claide (v1.1.0, RVM: ruby-2.7.2) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="colored (v1.2, RVM: ruby-2.7.2) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="colored2 (v3.1.2, RVM: ruby-2.7.2) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="escape (v0.0.4, RVM: ruby-2.7.2) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="ethon (v0.15.0, RVM: ruby-2.7.2) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.5, RVM: ruby-2.7.2) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="fourflusher (v2.3.1, RVM: ruby-2.7.2) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="fuzzy_match (v2.0.4, RVM: ruby-2.7.2) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="gh_inspector (v1.1.3, RVM: ruby-2.7.2) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="httpclient (v2.8.3, RVM: ruby-2.7.2) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, RVM: ruby-2.7.2) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="json (v2.6.1, RVM: ruby-2.7.2) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, RVM: ruby-2.7.2) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="nanaimo (v0.3.0, RVM: ruby-2.7.2) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="nap (v1.1.0, RVM: ruby-2.7.2) [gem]" level="application" />
33
- <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-2.7.2) [gem]" level="application" />
34
- <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-2.7.2) [gem]" level="application" />
35
- <orderEntry type="library" scope="PROVIDED" name="ruby-macho (v2.5.1, RVM: ruby-2.7.2) [gem]" level="application" />
36
- <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.2) [gem]" level="application" />
37
- <orderEntry type="library" scope="PROVIDED" name="typhoeus (v1.4.0, RVM: ruby-2.7.2) [gem]" level="application" />
38
- <orderEntry type="library" scope="PROVIDED" name="xcodeproj (v1.21.0, RVM: ruby-2.7.2) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="CFPropertyList (v3.0.5, ruby-3.1.0-p0) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.6, ruby-3.1.0-p0) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, ruby-3.1.0-p0) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="algoliasearch (v1.27.5, ruby-3.1.0-p0) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="atomos (v0.1.3, ruby-3.1.0-p0) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.11, ruby-3.1.0-p0) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="claide (v1.1.0, ruby-3.1.0-p0) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods (v1.11.3, ruby-3.1.0-p0) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods-core (v1.11.3, ruby-3.1.0-p0) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods-deintegrate (v1.0.5, ruby-3.1.0-p0) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods-downloader (v1.6.3, ruby-3.1.0-p0) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods-plugins (v1.0.0, ruby-3.1.0-p0) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods-search (v1.0.1, ruby-3.1.0-p0) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods-trunk (v1.6.0, ruby-3.1.0-p0) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods-try (v1.2.0, ruby-3.1.0-p0) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="colored (v1.2, ruby-3.1.0-p0) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="colored2 (v3.1.2, ruby-3.1.0-p0) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, ruby-3.1.0-p0) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, ruby-3.1.0-p0) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="escape (v0.0.4, ruby-3.1.0-p0) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="ethon (v0.15.0, ruby-3.1.0-p0) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.5, ruby-3.1.0-p0) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="fourflusher (v2.3.1, ruby-3.1.0-p0) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="fuzzy_match (v2.0.4, ruby-3.1.0-p0) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="gh_inspector (v1.1.3, ruby-3.1.0-p0) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="httpclient (v2.8.3, ruby-3.1.0-p0) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, ruby-3.1.0-p0) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.6.2, ruby-3.1.0-p0) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, ruby-3.1.0-p0) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="molinillo (v0.8.0, ruby-3.1.0-p0) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="mustache (v1.1.1, ruby-3.1.0-p0) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="nanaimo (v0.3.0, ruby-3.1.0-p0) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="nap (v1.1.0, ruby-3.1.0-p0) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, ruby-3.1.0-p0) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.7, ruby-3.1.0-p0) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, ruby-3.1.0-p0) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, ruby-3.1.0-p0) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, ruby-3.1.0-p0) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, ruby-3.1.0-p0) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, ruby-3.1.0-p0) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, ruby-3.1.0-p0) [gem]" level="application" />
55
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, ruby-3.1.0-p0) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="ruby-macho (v2.5.1, ruby-3.1.0-p0) [gem]" level="application" />
57
+ <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, ruby-3.1.0-p0) [gem]" level="application" />
58
+ <orderEntry type="library" scope="PROVIDED" name="typhoeus (v1.4.0, ruby-3.1.0-p0) [gem]" level="application" />
59
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, ruby-3.1.0-p0) [gem]" level="application" />
60
+ <orderEntry type="library" scope="PROVIDED" name="xcodeproj (v1.21.0, ruby-3.1.0-p0) [gem]" level="application" />
61
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.4, ruby-3.1.0-p0) [gem]" level="application" />
39
62
  </component>
40
63
  <component name="RakeTasksCache">
41
64
  <option name="myRootTask">
42
- <RakeTaskImpl id="rake" />
65
+ <RakeTaskImpl id="rake">
66
+ <subtasks>
67
+ <RakeTaskImpl description="Build mt_tool-0.1.4.gem into the pkg directory" fullCommand="build" id="build" />
68
+ <RakeTaskImpl id="build">
69
+ <subtasks>
70
+ <RakeTaskImpl description="Generate SHA512 checksum if mt_tool-0.1.4.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
71
+ </subtasks>
72
+ </RakeTaskImpl>
73
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
74
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
75
+ <RakeTaskImpl description="Build and install mt_tool-0.1.4.gem into system gems" fullCommand="install" id="install" />
76
+ <RakeTaskImpl id="install">
77
+ <subtasks>
78
+ <RakeTaskImpl description="Build and install mt_tool-0.1.4.gem into system gems without network access" fullCommand="install:local" id="local" />
79
+ </subtasks>
80
+ </RakeTaskImpl>
81
+ <RakeTaskImpl description="Create tag v0.1.4 and build and push mt_tool-0.1.4.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
82
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
83
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
84
+ <RakeTaskImpl id="release">
85
+ <subtasks>
86
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
87
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
88
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
89
+ </subtasks>
90
+ </RakeTaskImpl>
91
+ </subtasks>
92
+ </RakeTaskImpl>
43
93
  </option>
44
94
  </component>
45
95
  </module>
@@ -0,0 +1,13 @@
1
+
2
+ >
3
+ lib/mt_tool.rb,b/5/b53eec12e0ab8df9876dbc7fe65915bb985c4f72
4
+ c
5
+ 3lib/mt_tool/short_hand/objc_implementation.mustache,5/2/5283f86f6adbda087dceb47c69b64e141dfb1e93
6
+ Y
7
+ )lib/mt_tool/module/template/objc/Bundle.h,f/8/f80e2edcdaf9ddf9362d26f7fa5d19df422f29c7
8
+ L
9
+ lib/mt_tool/module/module.rb,e/8/e84cc700d4480c1d3ca7dcc158063e40a25cee12
10
+ Y
11
+ )lib/mt_tool/module/template/objc/Bundle.m,7/0/70213f721c971c9a12d0f46060f7ee2a087b4a96
12
+ F
13
+ lib/mt_tool/version.rb,4/7/4745e92ab1b53af3e65026337909045741e13bea
data/Gemfile.lock CHANGED
@@ -1,9 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mt_tool (0.1.3)
4
+ mt_tool (0.1.4)
5
+ activesupport
5
6
  bundler
6
7
  colored
8
+ colored2
9
+ mustache
7
10
  pathname
8
11
  thor
9
12
  xcodeproj
@@ -13,7 +16,7 @@ GEM
13
16
  specs:
14
17
  CFPropertyList (3.0.5)
15
18
  rexml
16
- activesupport (6.1.5)
19
+ activesupport (6.1.6)
17
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
21
  i18n (>= 1.6, < 2)
19
22
  minitest (>= 5.1)
@@ -77,9 +80,10 @@ GEM
77
80
  httpclient (2.8.3)
78
81
  i18n (1.10.0)
79
82
  concurrent-ruby (~> 1.0)
80
- json (2.6.1)
83
+ json (2.6.2)
81
84
  minitest (5.15.0)
82
85
  molinillo (0.8.0)
86
+ mustache (1.1.1)
83
87
  nanaimo (0.3.0)
84
88
  nap (1.1.0)
85
89
  netrc (0.11.0)
data/README.md CHANGED
@@ -1,8 +1,23 @@
1
1
  # MtTool
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mt_tool`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Generate OC/Swift files for project or module.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ <img src="img/69786f8e2a527b8c26f2c1311e230e5f.webp.png" alt="Module File Generator" height="150" width="150">
6
+
7
+
8
+ Free your time, focus on real coding things.
9
+
10
+ ## Usage
11
+
12
+ For viper module
13
+
14
+ `mt_tool generateViperModule Canvas Tom.Liu ./`
15
+
16
+ <img src="img/SCR-20240619-msnz.png" alt="Module File Generator">
17
+
18
+ ## Debug
19
+
20
+ ![config](https://github.com/lyleLH/image-repo/blob/master/images/SCR-20240619-mpdx.png?raw=true)
6
21
 
7
22
  ## Installation
8
23
 
@@ -14,10 +29,6 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
29
 
15
30
  $ gem install mt_tool
16
31
 
17
- ## Usage
18
-
19
- TODO: Write usage instructions here
20
-
21
32
  ## Development
22
33
 
23
34
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -26,4 +37,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
26
37
 
27
38
  ## Contributing
28
39
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mt_tool.
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lylelh/mt_tool.
Binary file
@@ -1,243 +1,50 @@
1
- require 'colored2'
1
+
2
2
  require 'thor'
3
- require 'fileutils'
4
- require 'psych'
5
- require 'yaml'
6
- require 'mt_tool/analyze'
3
+ require 'mt_tool/module/module'
4
+ require 'mt_tool/oc_model/oc_model'
5
+
7
6
  module MtTool
8
7
  class CLI < Thor
9
8
  include Thor::Actions
10
9
 
11
- CONFIG_FILE = '.MTModuleFilesConfig.yml'.freeze
12
10
 
13
11
  desc 'generate <Path> <Module Name> <Language> <Prefix - 前缀> <Author - 作者>', '直接生成项目 例子: yk_command generate . HomeModule oc MT Tom.Liu '
14
12
  method_option :generate, aliases: '-g'
15
13
 
16
14
  def generate(path = nil, name, lang, class_prefix, author)
17
- @name = name
18
- @module = @name
19
- @lang = lang
20
- @class_prefix = class_prefix
21
- @final_path = "#{path}/#{@name}"
22
- @author = author
23
- @prefixed_module = @class_prefix + @module
24
-
25
- say "generating file in path:#{@final_path}", :green
26
-
27
- if File.exist?(@final_path.to_s)
28
- say "#{@final_path} 已存在:", :red
29
- else
30
- prepare_folder
31
- if File.exist?("#{@final_path}/configure")
32
- system("#{@final_path}/configure", @name, @lang, @class_prefix, *@additional_args)
33
- else
34
- say 'Template does not have a configure file', :red
35
- end
36
- yk_module_folders
37
- yk_template_files
38
- end
15
+ Module.new(self .args,self .options).generate(path, name, lang, class_prefix, author)
39
16
  end
40
17
 
41
18
  desc 'create <Path>', '在某个路径下交互式生成项目'
42
19
  method_option :create, aliases: '-c'
43
20
 
44
21
  def create(path = nil)
45
- path = Dir.pwd if path.nil?
46
-
47
- say '模块名:', :green
48
- config_file_path = "#{path}/#{CONFIG_FILE}"
49
- config = File.exist?(config_file_path) ? YAML.load_file(config_file_path) : {}
50
- input_name = ask("Project name [#{config[:project]}] ?")
51
-
52
- if input_name != ''
53
- @name = input_name
54
- config[:project] = input_name if input_name != config[:project]
55
- else
56
- @name = config[:project]
57
- end
58
-
59
- File.open(config_file_path, 'w') do |f|
60
- f.write config.to_yaml
61
- end
62
-
63
- @final_path = "#{path}/#{@name}"
64
-
65
- if File.exist?(@final_path.to_s)
66
- say "#{@final_path} 已存在:", :red
67
- else
68
- prepare_folder
69
- read_config(path)
70
-
71
- if File.exist?("#{@final_path}/configure")
72
- system("#{@final_path}/configure", @name, @lang, @class_prefix, *@additional_args)
73
- else
74
- say 'Template does not have a configure file', :red
75
- end
76
-
77
- yk_module_folders
78
- yk_template_files
79
-
80
- end
22
+ Module.new(self .args,self .options ).create(path)
23
+
81
24
  end
82
25
 
83
- no_commands do
84
- def read_config(path)
85
- config_file_path = "#{path}/#{CONFIG_FILE}"
86
- config = File.exist?(config_file_path) ? YAML.load_file(config_file_path) : {}
87
-
88
- project = @name
89
- say '语言:', :green
90
- language = ask("Project language [#{config[:language]}] ?", limited_to: ['objc', 'swift', ''])
91
- say '类名前缀:', :green
92
- class_prefix = ask("Class prefix [#{config[:class_prefix]}] ?")
93
- say '文件作者:', :green
94
- author = ask("Author [#{config[:author]}] ?")
95
-
96
- config[:project] = project.empty? ? config[:project] || '' : project
97
- config[:language] = language.empty? ? config[:language] || 'objc' : language
98
- config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
99
- config[:author] = author.empty? ? config[:author] || '' : author
100
-
101
- File.open(config_file_path, 'w') do |f|
102
- f.write config.to_yaml
103
- # f.write YAML.to_yaml(config)
104
- end
105
-
106
- @module = @name
107
- @class_prefix = config[:class_prefix]
108
- @prefixed_module = config[:class_prefix] + @module
109
- @project = config[:project]
110
- @author = config[:author]
111
- @date = Time.now.strftime('%d/%m/%y')
112
- @lang = config[:language]
113
- end
114
-
115
- def prepare_folder
116
-
117
- template_repo_url = 'https://github.com/lyleLH/MTTemplate.git'
118
- system("git clone #{template_repo_url} #{@final_path}")
119
-
120
- # FileUtils.remove_dir(@final_path, true)
121
- # FileUtils.cp_r('/Users/imacn24/Documents/dev/YKProjectTemplate', @final_path)
122
- # FileUtils.remove_dir("#{@final_path}/.git", true)
123
- end
124
-
125
- def yk_module_folders
126
- class_folder_path = "#{@final_path}/#{@name}/Classes"
127
-
128
- first_level_folders = %w[Public Private]
129
-
130
- # public_level_folders = ['Register']
131
- # public_level_folders.each do |folder|
132
- # path = "#{class_folder_path}/Public/#{folder}"
133
- # empty_directory path
134
- # end
135
-
136
- private_level_folders = %w[Business Category Vendor Tools]
137
-
138
- first_level_folders.each do |folder|
139
- path = "#{class_folder_path}/#{folder}"
140
- empty_directory path
141
- end
142
-
143
- private_level_folders.each do |folder|
144
- path = "#{class_folder_path}/Private/#{folder}"
145
- empty_directory path
146
- end
147
- end
148
-
149
- CLI.source_root(File.dirname(__FILE__))
150
-
151
- def yk_template_files
152
- register_path = "#{@final_path}/#{@name}/Classes/Private/Register"
153
- registger = {
154
- 'RouterRegister.h' => 'RouterRegister',
155
- 'RouterRegister.m' => 'RouterRegister',
156
- 'ServiceRegister.h' => 'ServiceRegister',
157
- 'ServiceRegister.m' => 'ServiceRegister'
158
- }
159
-
160
- registger.each do |file_name, _folder|
161
- final_file = "#{register_path}/#{@prefixed_module}#{file_name}"
162
- template "#{__dir__}/template/objc/#{file_name}", final_file
163
- end
164
-
165
- public_folder_path = "#{@final_path}/#{@name}/Classes/Public"
166
-
167
- template_code_filename = ['ServiceProtocol.h', 'RouterDefine.h']
168
- template_code_filename.each do |file_name|
169
- final_file = "#{public_folder_path}/#{@prefixed_module}#{file_name}"
170
- source = "#{__dir__}/template/objc/#{file_name}"
171
- template source, final_file
172
- end
173
-
174
- swift_template_code_filename = ['RouterDefine.swift']
175
- swift_template_code_filename.each do |file_name|
176
- final_file = "#{public_folder_path}/#{@prefixed_module}_Swift_#{file_name}"
177
- source = "#{__dir__}/template/swift/#{file_name}"
178
- template source, final_file
179
- end
180
-
181
- private_folder_path = "#{@final_path}/#{@name}/Classes/Private"
182
- #pch file
183
- # pch_file_name = "PrefixHeader.pch"
184
- # final_file = "#{private_folder_path}/#{@prefixed_module}#{pch_file_name}"
185
- # source = "#{__dir__}/template/objc/#{pch_file_name}"
186
- # template source, final_file
187
-
188
- private_level_folder_files = {
189
- 'PrefixHeader.pch' => 'Business',
190
- 'CategoryHeader.h' => 'Category',
191
- 'ToolsHeader.h' => 'Tools',
192
- 'vendorHeader.h' => 'Vendor'
193
- }
194
-
195
- private_level_folder_files.each do |file_name, folder|
196
- final_prefix = @prefixed_module
197
- if file_name == 'PrefixHeader.pch'
198
- final_prefix = @module
199
- end
200
-
201
- final_file = "#{private_folder_path}/#{folder}/#{final_prefix}#{file_name}"
202
- source = "#{__dir__}/template/objc/#{file_name}"
203
- template source, final_file
204
- end
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
-
215
- business_demo_path = "#{@final_path}/#{@name}/Classes/Private/Business"
216
- demo_replace_file = ['DemoViewController.h', 'DemoViewController.m', 'DemoViewModel.h', 'DemoViewModel.m']
217
- demo_replace_file.each do |file_name|
218
- final_file = "#{business_demo_path}/Demo/#{@prefixed_module}#{file_name}"
219
- source = "#{__dir__}/template/objc/demo/#{file_name}"
220
- template source, final_file
221
- end
222
-
223
- Dir.chdir("#{@final_path}/Example") do
224
- system 'pod install'
225
- system "open './#{@name}.xcworkspace'"
226
- end
227
- end
228
26
 
27
+ desc 'vmod <module name > <author> <path> ', '生成viper模块文件'
28
+ method_option :vmod, aliases: '-v'
29
+ def generateViperModule(name,author, path )
30
+ Module.new(self .args,self .options).create_viper_module(path, name, "swift","", author)
229
31
  end
230
32
 
231
- desc 'dependency <Podfile.lock Path>', '解析Podfile.lock'
232
- method_option :dependency, aliases: '-d'
33
+ desc 'model_class <prefix> <class name > <json file path> <output path>', '根据json文件生成模型类'
34
+ method_option :create, aliases: '-c'
35
+ def model_class(prefix,name, path ,output_path)
36
+ OcModel.new(self .args,self .options ).create(prefix,name ,path,output_path)
233
37
 
234
- def dependency(path = nil)
235
- say 'start resolve dependency', :green
38
+ end
236
39
 
237
- analyzer = Analyzer.new
238
- result = analyzer.analyze(path)
239
- pp result
40
+ desc 'qt_model_class <prefix> <class name > <json file path> <output path>', '使用quicktype根据json文件生成模型类'
41
+ method_option :create, aliases: '-c'
42
+ def qt_model_class(prefix,name, path ,output_path)
43
+ OcModel.new(self .args,self .options ).qt_create(prefix,name ,path,output_path)
240
44
 
241
45
  end
46
+
47
+
48
+
242
49
  end
243
50
  end