mt_tool 0.1.5 → 1.0.0

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -1
  3. data/README.md +69 -16
  4. data/Rakefile +14 -1
  5. data/bin/console +15 -0
  6. data/bin/setup +8 -0
  7. data/lib/mt_tool/commands.rb +43 -36
  8. data/lib/mt_tool/module/module.rb +1 -1
  9. data/lib/mt_tool/module/template/swift/Interactor.swift +1 -1
  10. data/lib/mt_tool/version.rb +1 -1
  11. data/mt_tool.gemspec +23 -28
  12. metadata +72 -165
  13. data/.MTModuleFilesConfig.yml +0 -5
  14. data/.idea/.gitignore +0 -8
  15. data/.idea/misc.xml +0 -4
  16. data/.idea/modules.xml +0 -8
  17. data/.idea/mt_tool.iml +0 -95
  18. data/.idea/sonarlint/issuestore/4/7/4745e92ab1b53af3e65026337909045741e13bea +0 -0
  19. data/.idea/sonarlint/issuestore/5/2/5283f86f6adbda087dceb47c69b64e141dfb1e93 +0 -0
  20. data/.idea/sonarlint/issuestore/7/0/70213f721c971c9a12d0f46060f7ee2a087b4a96 +0 -0
  21. data/.idea/sonarlint/issuestore/b/5/b53eec12e0ab8df9876dbc7fe65915bb985c4f72 +0 -0
  22. data/.idea/sonarlint/issuestore/e/8/e84cc700d4480c1d3ca7dcc158063e40a25cee12 +0 -0
  23. data/.idea/sonarlint/issuestore/f/8/f80e2edcdaf9ddf9362d26f7fa5d19df422f29c7 +0 -0
  24. data/.idea/sonarlint/issuestore/index.pb +0 -13
  25. data/.idea/vcs.xml +0 -7
  26. data/Gemfile.lock +0 -138
  27. data/img/69786f8e2a527b8c26f2c1311e230e5f.webp.png +0 -0
  28. data/img/SCR-20240619-msnz.png +0 -0
  29. data/lib/mt_tool/module/template/objc/Bundle.h +0 -21
  30. data/lib/mt_tool/module/template/objc/Bundle.m +0 -28
  31. data/lib/mt_tool/module/template/objc/CategoryHeader.h +0 -15
  32. data/lib/mt_tool/module/template/objc/PrefixHeader.pch +0 -36
  33. data/lib/mt_tool/module/template/objc/RouterDefine.h +0 -14
  34. data/lib/mt_tool/module/template/objc/RouterRegister.h +0 -16
  35. data/lib/mt_tool/module/template/objc/RouterRegister.m +0 -33
  36. data/lib/mt_tool/module/template/objc/ServiceProtocol.h +0 -15
  37. data/lib/mt_tool/module/template/objc/ServiceRegister.h +0 -16
  38. data/lib/mt_tool/module/template/objc/ServiceRegister.m +0 -25
  39. data/lib/mt_tool/module/template/objc/ToolsHeader.h +0 -13
  40. data/lib/mt_tool/module/template/objc/VendorHeader.h +0 -13
  41. data/lib/mt_tool/module/template/objc/demo/DemoViewController.h +0 -17
  42. data/lib/mt_tool/module/template/objc/demo/DemoViewController.m +0 -28
  43. data/lib/mt_tool/module/template/objc/demo/DemoViewModel.h +0 -14
  44. data/lib/mt_tool/module/template/objc/demo/DemoViewModel.m +0 -19
  45. data/lib/mt_tool/oc_model/main.rb +0 -112
  46. data/lib/mt_tool/oc_model/oc_model.rb +0 -235
  47. data/lib/mt_tool/oc_model/sample.json +0 -11
  48. data/lib/mt_tool/short_hand/objc_generate_from_shorthand.rb +0 -182
  49. data/lib/mt_tool/short_hand/objc_header.mustache +0 -41
  50. data/lib/mt_tool/short_hand/objc_implementation.mustache +0 -99
  51. data/lib/mt_tool/short_hand/objc_shorthand.rb +0 -64
  52. data/sig/mt_tool.rbs +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eeca6fee7bb5bc02cf6b281ce04c8da18558905941f1a7513d6856e95b32196
4
- data.tar.gz: 24c54d8d84e44111c10c59c6c4fa6b8dc310d4d7476f783f7cf4ffcaa2081af9
3
+ metadata.gz: 2671c087892b569fe4925329354c5211b46cc409879167a4a20e6e3b7548380a
4
+ data.tar.gz: 2999d07e97a347e65513bb01c9e1a8ca675c36c71a26b2581d4f7cb5cdc01db6
5
5
  SHA512:
6
- metadata.gz: fb3f3a03a6164a4741ad8287063855f8f660dfc51d7cbe688a3123d36f52c3880ab7c6ed1894aa08b2fd9ad386ea39b114758cb16cffd659dbcde2ba307edc6f
7
- data.tar.gz: dc821d39412af58a762319d7e1aa378f58a478a09a440cc4b8d4ec7cd353694e6b23c911d1938d4304e95c39562039c76d730aac892d20b62cea8584970936bd
6
+ metadata.gz: 3caa9622bf7aec720a073aa9d24322adb8744a6451936ed931b25c3cfa25f543392627b1414fb439c978bc799c65c08201615e1e61919c3b5a2d05721aedf772
7
+ data.tar.gz: 4afa9862815131168293066842634a4435de43ca46da56c9399b5fc952ae10ce01005d0c3d7ff458437ca519f870b99dcfa02712e04905efe40746838c846964
data/Gemfile CHANGED
@@ -5,4 +5,9 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in mt_tool.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ # Development dependencies are specified in gemspec
9
+ group :development do
10
+ gem "rake", "~> 13.0"
11
+ gem "pry"
12
+ gem "pry-byebug"
13
+ end
data/README.md CHANGED
@@ -1,40 +1,93 @@
1
1
  # MtTool
2
2
 
3
- Generate OC/Swift files for project or module.
3
+ A Ruby gem for generating VIPER architecture modules for iOS projects. Supports both Swift and Objective-C.
4
4
 
5
5
  <img src="img/69786f8e2a527b8c26f2c1311e230e5f.webp.png" alt="Module File Generator" height="150" width="150">
6
6
 
7
+ ## Features
7
8
 
8
- Free your time, focus on real coding things.
9
+ - Generate complete VIPER module structure
10
+ - Support for both Swift and Objective-C
11
+ - Customizable templates
12
+ - Command-line interface
13
+ - Detailed logging for debugging
9
14
 
10
- ## Usage
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
11
18
 
12
- For viper module
19
+ ```ruby
20
+ gem 'mt_tool'
21
+ ```
13
22
 
14
- `mt_tool generateViperModule Canvas Tom.Liu ./`
23
+ And then execute:
24
+ ```bash
25
+ $ bundle install
26
+ ```
15
27
 
16
- <img src="img/SCR-20240619-msnz.png" alt="Module File Generator">
28
+ Or install it yourself as:
29
+ ```bash
30
+ $ gem install mt_tool
31
+ ```
17
32
 
18
- ## Debug
33
+ ## Usage
19
34
 
20
- ![config](https://github.com/lyleLH/image-repo/blob/master/images/SCR-20240619-mpdx.png?raw=true)
35
+ ### Generating a VIPER Module
21
36
 
22
- ## Installation
37
+ ```bash
38
+ # Generate a VIPER module
39
+ mt_tool vmod -n ModuleName -a "Author Name" -p ./path/to/module
40
+
41
+ # Example
42
+ mt_tool vmod -n HomeScreen -a "Tom Liu" -p ./Modules
43
+ ```
23
44
 
24
- Install the gem and add to the application's Gemfile by executing:
45
+ ### Command Options
25
46
 
26
- $ bundle add mt_tool
47
+ - `-n, --name`: Module name (required)
48
+ - `-a, --author`: Author name (required)
49
+ - `-p, --path`: Target path for generation (required)
27
50
 
28
- If bundler is not being used to manage dependencies, install the gem by executing:
51
+ ### Generated Structure
29
52
 
30
- $ gem install mt_tool
53
+ ```
54
+ ModuleName/
55
+ ├── ModuleNameEntity.swift
56
+ ├── ModuleNameInteractor.swift
57
+ ├── ModuleNamePresenter.swift
58
+ ├── ModuleNameRouter.swift
59
+ └── ModuleNameViewController.swift
60
+ ```
31
61
 
32
62
  ## Development
33
63
 
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.
64
+ After checking out the repo, run `bundle install` to install dependencies.
35
65
 
36
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+ To run the test suite:
67
+ ```bash
68
+ bundle exec rake test
69
+ ```
70
+
71
+ To install this gem onto your local machine:
72
+ ```bash
73
+ bundle exec rake install
74
+ ```
37
75
 
38
76
  ## Contributing
39
77
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/lylelh/mt_tool.
78
+ 1. Fork it
79
+ 2. Create your feature branch (`git checkout -b feature/my-new-feature`)
80
+ 3. Add tests for your changes
81
+ 4. Make your changes
82
+ 5. Run the tests (`bundle exec rake test`)
83
+ 6. Commit your changes (`git commit -am 'Add some feature'`)
84
+ 7. Push to the branch (`git push origin feature/my-new-feature`)
85
+ 8. Create new Pull Request
86
+
87
+ ## License
88
+
89
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
90
+
91
+ ## Code of Conduct
92
+
93
+ Everyone interacting in the MtTool project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/lylelh/mt_tool/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,4 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- task default: %i[]
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :clean do
9
+ FileUtils.rm_rf('pkg')
10
+ FileUtils.rm_rf('test_output')
11
+ end
12
+
13
+ task :build => :clean
14
+
15
+ task :test => [:clean, :spec]
16
+
17
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "mt_tool"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,50 +1,57 @@
1
-
2
1
  require 'thor'
3
2
  require 'mt_tool/module/module'
4
- require 'mt_tool/oc_model/oc_model'
3
+ require 'logger'
5
4
 
6
5
  module MtTool
7
6
  class CLI < Thor
8
7
  include Thor::Actions
9
8
 
10
-
11
- desc 'generate <Path> <Module Name> <Language> <Prefix - 前缀> <Author - 作者>', '直接生成项目 例子: yk_command generate . HomeModule oc MT Tom.Liu '
12
- method_option :generate, aliases: '-g'
13
-
14
- def generate(path = nil, name, lang, class_prefix, author)
15
- Module.new(self .args,self .options).generate(path, name, lang, class_prefix, author)
9
+ def initialize(*args)
10
+ super
11
+ @logger = Logger.new(STDOUT)
12
+ @logger.level = Logger::DEBUG
13
+ @logger.formatter = proc do |severity, datetime, progname, msg|
14
+ "[#{severity}][#{datetime.strftime('%Y-%m-%d %H:%M:%S.%L')}] #{msg}\n"
15
+ end
16
16
  end
17
17
 
18
- desc 'create <Path>', '在某个路径下交互式生成项目'
19
- method_option :create, aliases: '-c'
20
-
21
- def create(path = nil)
22
- Module.new(self .args,self .options ).create(path)
23
-
18
+ def self.exit_on_failure?
19
+ true
24
20
  end
25
21
 
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)
22
+ desc 'vmod', '生成viper模块文件'
23
+ method_option :name, aliases: '-n', desc: 'Module name', required: true
24
+ method_option :author, aliases: '-a', desc: 'Author name', required: true
25
+ method_option :path, aliases: '-p', desc: 'Target path', required: true
26
+ def vmod
27
+ name = options[:name]
28
+ author = options[:author]
29
+ path = options[:path]
30
+
31
+ @logger.debug "====== VIPER Module Generation Started ======"
32
+ @logger.debug "Command Parameters:"
33
+ @logger.debug " - Module name: #{name}"
34
+ @logger.debug " - Author: #{author}"
35
+ @logger.debug " - Path: #{path}"
36
+ @logger.debug "Thor Options: #{options.inspect}"
37
+ @logger.debug "Thor Arguments: #{args.inspect}"
38
+
39
+ begin
40
+ @logger.debug "Creating new Module instance..."
41
+ module_instance = Module.new(self.args, self.options)
42
+
43
+ @logger.debug "Calling create_viper_module..."
44
+ module_instance.create_viper_module(path, name, "swift", "", author)
45
+
46
+ @logger.info "Successfully generated VIPER module: #{name}"
47
+ @logger.debug "====== VIPER Module Generation Completed ======"
48
+ rescue => e
49
+ @logger.error "Failed to generate VIPER module: #{e.message}"
50
+ @logger.debug "Error backtrace:"
51
+ @logger.debug e.backtrace.join("\n")
52
+ @logger.debug "====== VIPER Module Generation Failed ======"
53
+ raise e
54
+ end
31
55
  end
32
-
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)
37
-
38
- end
39
-
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)
44
-
45
- end
46
-
47
-
48
-
49
56
  end
50
57
  end
@@ -121,7 +121,7 @@ module MtTool
121
121
  def prepare_folder
122
122
  host_a = 'yeah'
123
123
  host_b = 'ka'
124
- template_repo_url = "http://gitlab.#{host_a}#{host_b}.com/App/iOS/YKComponents/YKProjectTemplate.git"
124
+ template_repo_url = "https://github.com/lyleLH/tom-pod-template"
125
125
  system("git clone #{template_repo_url} #{@final_path}")
126
126
 
127
127
  # FileUtils.remove_dir(@final_path, true)
@@ -12,5 +12,5 @@ protocol <%= @prefixed_module %>InteractorProtocol {
12
12
  }
13
13
 
14
14
  class <%= @prefixed_module %>Interactor: <%= @prefixed_module %>InteractorProtocol {
15
- weak var presenter: <%= @prefixed_module %>PresenterProtocol?
15
+
16
16
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MtTool
4
- VERSION = "0.1.5"
4
+ VERSION = "1.0.0"
5
5
  end
data/mt_tool.gemspec CHANGED
@@ -13,39 +13,34 @@ Gem::Specification.new do |spec|
13
13
  spec.required_ruby_version = ">= 2.6.0"
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
15
  spec.metadata["source_code_uri"] = "https://github.com/lyleLH/mt_tool"
16
+ spec.license = "MIT"
16
17
 
17
18
  # Specify which files should be added to the gem when it is released.
18
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
- spec.files = Dir.chdir(__dir__) do
20
- `git ls-files -z`.split("\x0").reject do |f|
21
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
22
- end
23
- end
19
+ spec.files = Dir[
20
+ "lib/**/*",
21
+ "bin/*",
22
+ "*.gemspec",
23
+ "README.md",
24
+ "Gemfile",
25
+ "Rakefile"
26
+ ]
24
27
  spec.bindir = "bin"
25
- # spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
26
28
  spec.executables << 'mt_tool'
27
29
  spec.require_paths = ["lib"]
28
30
 
31
+ # Runtime dependencies
32
+ spec.add_dependency 'thor', '~> 1.2'
33
+ spec.add_dependency 'xcodeproj', '~> 1.22'
34
+ spec.add_dependency 'colored', '~> 1.2'
35
+ spec.add_dependency 'colored2', '~> 3.1'
36
+ spec.add_dependency 'pathname', '~> 0.2'
37
+ spec.add_dependency 'mustache', '~> 1.1'
38
+ spec.add_dependency 'activesupport', '~> 7.0'
29
39
 
30
- # Uncomment to register a new dependency of your gem
31
- # spec.add_dependency "example-gem", "~> 1.0"
32
- spec.add_development_dependency 'bundler'
33
- spec.add_development_dependency 'thor'
34
- spec.add_development_dependency 'colored'
35
- spec.add_development_dependency 'colored2'
36
- spec.add_development_dependency 'rspec', '~> 3.2'
37
- spec.add_development_dependency 'xcodeproj'
38
- spec.add_development_dependency 'cocoapods'
39
- spec.add_development_dependency 'cocoapods-core'
40
-
41
- spec.add_dependency 'bundler'
42
- spec.add_dependency 'thor'
43
- spec.add_dependency 'xcodeproj'
44
- spec.add_dependency 'colored'
45
- spec.add_dependency 'colored2'
46
- spec.add_dependency 'pathname'
47
- spec.add_dependency 'mustache'
48
- spec.add_dependency 'activesupport'
49
- # For more information and examples about making a new gem, check out our
50
- # guide at: https://bundler.io/guides/creating_gem.html
40
+ # Development dependencies
41
+ spec.add_development_dependency 'bundler', '~> 2.3'
42
+ spec.add_development_dependency 'rake', '~> 13.0'
43
+ spec.add_development_dependency 'rspec', '~> 3.12'
44
+ spec.add_development_dependency 'pry', '~> 0.14'
45
+ spec.add_development_dependency 'pry-byebug', '~> 3.10'
51
46
  end