mt_tool 0.1.3 → 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.
- checksums.yaml +4 -4
- data/Gemfile +6 -1
- data/README.md +74 -10
- data/Rakefile +14 -1
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/mt_tool/commands.rb +43 -229
- data/lib/mt_tool/module/module.rb +275 -0
- data/lib/mt_tool/module/template/swift/Entity.swift +15 -0
- data/lib/mt_tool/module/template/swift/Interactor.swift +16 -0
- data/lib/mt_tool/module/template/swift/Presenter.swift +28 -0
- data/lib/mt_tool/module/template/swift/Router.swift +50 -0
- data/lib/mt_tool/module/template/swift/ViewController.swift +97 -0
- data/lib/mt_tool/version.rb +1 -1
- data/mt_tool.gemspec +23 -26
- metadata +81 -111
- data/.MTModuleFilesConfig.yml +0 -5
- data/.idea/.gitignore +0 -8
- data/.idea/misc.xml +0 -4
- data/.idea/modules.xml +0 -8
- data/.idea/mt_tool.iml +0 -45
- data/.idea/vcs.xml +0 -7
- data/Gemfile.lock +0 -134
- data/lib/mt_tool/analyze.rb +0 -126
- data/lib/mt_tool/template/objc/Bundle.h +0 -21
- data/lib/mt_tool/template/objc/Bundle.m +0 -28
- data/lib/mt_tool/template/objc/CategoryHeader.h +0 -15
- data/lib/mt_tool/template/objc/PrefixHeader.pch +0 -36
- data/lib/mt_tool/template/objc/RouterDefine.h +0 -14
- data/lib/mt_tool/template/objc/RouterRegister.h +0 -16
- data/lib/mt_tool/template/objc/RouterRegister.m +0 -33
- data/lib/mt_tool/template/objc/ServiceProtocol.h +0 -15
- data/lib/mt_tool/template/objc/ServiceRegister.h +0 -16
- data/lib/mt_tool/template/objc/ServiceRegister.m +0 -25
- data/lib/mt_tool/template/objc/ToolsHeader.h +0 -13
- data/lib/mt_tool/template/objc/VendorHeader.h +0 -13
- data/lib/mt_tool/template/objc/demo/DemoViewController.h +0 -17
- data/lib/mt_tool/template/objc/demo/DemoViewController.m +0 -28
- data/lib/mt_tool/template/objc/demo/DemoViewModel.h +0 -14
- data/lib/mt_tool/template/objc/demo/DemoViewModel.m +0 -19
- data/sig/mt_tool.rbs +0 -4
- /data/lib/mt_tool/{template → module/template}/swift/RouterDefine.swift +0 -0
| @@ -0,0 +1,275 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            require 'colored'
         | 
| 3 | 
            +
            require 'fileutils'
         | 
| 4 | 
            +
            require 'psych'
         | 
| 5 | 
            +
            require 'yaml'
         | 
| 6 | 
            +
            require 'thor/actions'
         | 
| 7 | 
            +
            require 'colored2'
         | 
| 8 | 
            +
            require 'fileutils'
         | 
| 9 | 
            +
            require 'psych'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
             | 
| 12 | 
            +
            module MtTool
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              CONFIG_FILE = '.MTModuleFilesConfig.yml'.freeze
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              class Module < Thor
         | 
| 17 | 
            +
                include Thor::Actions
         | 
| 18 | 
            +
                no_commands do
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def initialize(args = [], options = {}, config = {})
         | 
| 21 | 
            +
                    super
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def generate(path = nil, name, lang, class_prefix, author)
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    @name = name
         | 
| 28 | 
            +
                    @module = @name
         | 
| 29 | 
            +
                    @lang = lang
         | 
| 30 | 
            +
                    @class_prefix = class_prefix
         | 
| 31 | 
            +
                    @final_path = "#{path}/#{@name}"
         | 
| 32 | 
            +
                    @author = author
         | 
| 33 | 
            +
                    @prefixed_module = @class_prefix + @module
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    say "generating file in path:#{@final_path}", :green
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    if File.exist?(@final_path.to_s)
         | 
| 38 | 
            +
                      say "#{@final_path} 已存在:", :red
         | 
| 39 | 
            +
                    else
         | 
| 40 | 
            +
                      prepare_folder
         | 
| 41 | 
            +
                      if File.exist?("#{@final_path}/configure")
         | 
| 42 | 
            +
                        system("#{@final_path}/configure", @name, @lang, @class_prefix, *@additional_args)
         | 
| 43 | 
            +
                      else
         | 
| 44 | 
            +
                        say 'Template does not have a configure file', :red
         | 
| 45 | 
            +
                      end
         | 
| 46 | 
            +
                      yk_module_folders
         | 
| 47 | 
            +
                      yk_template_files
         | 
| 48 | 
            +
                    end
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  def create(path = nil)
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                    path = Dir.pwd if path.nil?
         | 
| 54 | 
            +
                    say '模块名:', :green
         | 
| 55 | 
            +
                    config_file_path = "#{path}/#{CONFIG_FILE}"
         | 
| 56 | 
            +
                    config = File.exist?(config_file_path) ? YAML.load_file(config_file_path) : {}
         | 
| 57 | 
            +
                    input_name = ask("Project name [#{config[:project]}] ?")
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    if input_name != ''
         | 
| 60 | 
            +
                      @name = input_name
         | 
| 61 | 
            +
                      config[:project] = input_name if input_name != config[:project]
         | 
| 62 | 
            +
                    else
         | 
| 63 | 
            +
                      @name = config[:project]
         | 
| 64 | 
            +
                    end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                    File.open(config_file_path, 'w') do |f|
         | 
| 67 | 
            +
                      f.write config.to_yaml
         | 
| 68 | 
            +
                    end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                    @final_path = "#{path}/#{@name}"
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                    if File.exist?(@final_path.to_s)
         | 
| 73 | 
            +
                      say "#{@final_path} 已存在:", :red
         | 
| 74 | 
            +
                    else
         | 
| 75 | 
            +
                      prepare_folder
         | 
| 76 | 
            +
                      read_config(path)
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                      if File.exist?("#{@final_path}/configure")
         | 
| 79 | 
            +
                        system("#{@final_path}/configure", @name, @lang, @class_prefix, *@additional_args)
         | 
| 80 | 
            +
                      else
         | 
| 81 | 
            +
                        say 'Template does not have a configure file', :red
         | 
| 82 | 
            +
                      end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                      yk_module_folders
         | 
| 85 | 
            +
                      yk_template_files
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                    end
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
             | 
| 91 | 
            +
                  def read_config(path)
         | 
| 92 | 
            +
                    config_file_path = "#{path}/#{CONFIG_FILE}"
         | 
| 93 | 
            +
                    config = File.exist?(config_file_path) ? YAML.load_file(config_file_path) : {}
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                    project = @name
         | 
| 96 | 
            +
                    say '语言:', :green
         | 
| 97 | 
            +
                    language = ask("Project language [#{config[:language]}] ?", limited_to: ['objc', 'swift', ''])
         | 
| 98 | 
            +
                    say '类名前缀:', :green
         | 
| 99 | 
            +
                    class_prefix = ask("Class prefix [#{config[:class_prefix]}] ?")
         | 
| 100 | 
            +
                    say '文件作者:', :green
         | 
| 101 | 
            +
                    author = ask("Author [#{config[:author]}] ?")
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                    config[:project] = project.empty? ? config[:project] || '' : project
         | 
| 104 | 
            +
                    config[:language] = language.empty? ? config[:language] || 'objc' : language
         | 
| 105 | 
            +
                    config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
         | 
| 106 | 
            +
                    config[:author] = author.empty? ? config[:author] || '' : author
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                    File.open(config_file_path, 'w') do |f|
         | 
| 109 | 
            +
                      f.write config.to_yaml
         | 
| 110 | 
            +
                      # f.write YAML.to_yaml(config)
         | 
| 111 | 
            +
                    end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                    @module = @name
         | 
| 114 | 
            +
                    @class_prefix = config[:class_prefix]
         | 
| 115 | 
            +
                    @prefixed_module = config[:class_prefix] + @module
         | 
| 116 | 
            +
                    @project = config[:project]
         | 
| 117 | 
            +
                    @author = config[:author]
         | 
| 118 | 
            +
                    @date = Time.now.strftime('%d/%m/%y')
         | 
| 119 | 
            +
                    @lang = config[:language]
         | 
| 120 | 
            +
                  end
         | 
| 121 | 
            +
                  def prepare_folder
         | 
| 122 | 
            +
                    host_a = 'yeah'
         | 
| 123 | 
            +
                    host_b = 'ka'
         | 
| 124 | 
            +
                    template_repo_url = "https://github.com/lyleLH/tom-pod-template"
         | 
| 125 | 
            +
                    system("git clone #{template_repo_url} #{@final_path}")
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                    # FileUtils.remove_dir(@final_path, true)
         | 
| 128 | 
            +
                    # FileUtils.cp_r('/Users/imacn24/Documents/dev/YKProjectTemplate', @final_path)
         | 
| 129 | 
            +
                    # FileUtils.remove_dir("#{@final_path}/.git", true)
         | 
| 130 | 
            +
                  end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                  def create_viper_module(path = nil, name, lang, class_prefix, author)
         | 
| 133 | 
            +
                    @name = name
         | 
| 134 | 
            +
                    @module = @name
         | 
| 135 | 
            +
                    @lang = lang
         | 
| 136 | 
            +
                    @class_prefix = class_prefix
         | 
| 137 | 
            +
                    @final_path = "#{path}/#{@name}"
         | 
| 138 | 
            +
                    @author = author
         | 
| 139 | 
            +
                    @prefixed_module = @class_prefix + @module
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                    say "generating file in path:#{@final_path}", :green
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                    if File.exist?(@final_path.to_s)
         | 
| 144 | 
            +
                      say "#{@final_path} 已存在:", :red
         | 
| 145 | 
            +
                    else
         | 
| 146 | 
            +
                      mt_viper_module
         | 
| 147 | 
            +
                    end
         | 
| 148 | 
            +
                  end
         | 
| 149 | 
            +
             | 
| 150 | 
            +
             | 
| 151 | 
            +
                  def mt_viper_module
         | 
| 152 | 
            +
                    class_folder_path = "#{@final_path}"
         | 
| 153 | 
            +
                    class_folder_files= {
         | 
| 154 | 
            +
                      'Entity.swift' => 'Entity',
         | 
| 155 | 
            +
                      'Interactor.swift' => 'Entity',
         | 
| 156 | 
            +
                      'Presenter.swift' => 'Entity',
         | 
| 157 | 
            +
                      'Router.swift' => 'Entity',
         | 
| 158 | 
            +
                      'ViewController.swift' => 'Entity',
         | 
| 159 | 
            +
                    }
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                    class_folder_files.each do |file_name, _folder|
         | 
| 162 | 
            +
                      final_file = "#{class_folder_path}/#{@prefixed_module}#{file_name}"
         | 
| 163 | 
            +
                      template "#{__dir__}/template/swift/#{file_name}", final_file
         | 
| 164 | 
            +
                    end
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                  end
         | 
| 167 | 
            +
             | 
| 168 | 
            +
             | 
| 169 | 
            +
                  def yk_module_folders
         | 
| 170 | 
            +
                    class_folder_path = "#{@final_path}/#{@name}/Classes"
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                    first_level_folders = %w[Public Private]
         | 
| 173 | 
            +
             | 
| 174 | 
            +
                    # public_level_folders = ['Register']
         | 
| 175 | 
            +
                    # public_level_folders.each do |folder|
         | 
| 176 | 
            +
                    #   path = "#{class_folder_path}/Public/#{folder}"
         | 
| 177 | 
            +
                    #   empty_directory path
         | 
| 178 | 
            +
                    # end
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                    private_level_folders = %w[Business Category Vendor Tools]
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                    first_level_folders.each do |folder|
         | 
| 183 | 
            +
                      path = "#{class_folder_path}/#{folder}"
         | 
| 184 | 
            +
                      empty_directory path
         | 
| 185 | 
            +
                    end
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                    private_level_folders.each do |folder|
         | 
| 188 | 
            +
                      path = "#{class_folder_path}/Private/#{folder}"
         | 
| 189 | 
            +
                      empty_directory path
         | 
| 190 | 
            +
                    end
         | 
| 191 | 
            +
                  end
         | 
| 192 | 
            +
             | 
| 193 | 
            +
             | 
| 194 | 
            +
                  MtTool::Module.source_root(File.dirname(__FILE__))
         | 
| 195 | 
            +
                  def yk_template_files
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                    register_path = "#{@final_path}/#{@name}/Classes/Private/Register"
         | 
| 198 | 
            +
                    registger = {
         | 
| 199 | 
            +
                      'RouterRegister.h' => 'RouterRegister',
         | 
| 200 | 
            +
                      'RouterRegister.m' => 'RouterRegister',
         | 
| 201 | 
            +
                      'ServiceRegister.h' => 'ServiceRegister',
         | 
| 202 | 
            +
                      'ServiceRegister.m' => 'ServiceRegister'
         | 
| 203 | 
            +
                    }
         | 
| 204 | 
            +
             | 
| 205 | 
            +
                    registger.each do |file_name, _folder|
         | 
| 206 | 
            +
                      final_file = "#{register_path}/#{@prefixed_module}#{file_name}"
         | 
| 207 | 
            +
                      template "#{__dir__}/template/objc/#{file_name}", final_file
         | 
| 208 | 
            +
                    end
         | 
| 209 | 
            +
             | 
| 210 | 
            +
                    public_folder_path = "#{@final_path}/#{@name}/Classes/Public"
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                    template_code_filename = ['ServiceProtocol.h', 'RouterDefine.h']
         | 
| 213 | 
            +
                    template_code_filename.each do |file_name|
         | 
| 214 | 
            +
                      final_file = "#{public_folder_path}/#{@prefixed_module}#{file_name}"
         | 
| 215 | 
            +
                      source = "#{__dir__}/template/objc/#{file_name}"
         | 
| 216 | 
            +
                      template source, final_file
         | 
| 217 | 
            +
                    end
         | 
| 218 | 
            +
             | 
| 219 | 
            +
                    swift_template_code_filename = ['RouterDefine.swift']
         | 
| 220 | 
            +
                    swift_template_code_filename.each do |file_name|
         | 
| 221 | 
            +
                      final_file = "#{public_folder_path}/#{@prefixed_module}_Swift_#{file_name}"
         | 
| 222 | 
            +
                      source = "#{__dir__}/template/swift/#{file_name}"
         | 
| 223 | 
            +
                      template source, final_file
         | 
| 224 | 
            +
                    end
         | 
| 225 | 
            +
             | 
| 226 | 
            +
                    private_folder_path = "#{@final_path}/#{@name}/Classes/Private"
         | 
| 227 | 
            +
                    #pch file
         | 
| 228 | 
            +
                    # pch_file_name = "PrefixHeader.pch"
         | 
| 229 | 
            +
                    # final_file = "#{private_folder_path}/#{@prefixed_module}#{pch_file_name}"
         | 
| 230 | 
            +
                    # source = "#{__dir__}/template/objc/#{pch_file_name}"
         | 
| 231 | 
            +
                    # template source, final_file
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                    private_level_folder_files = {
         | 
| 234 | 
            +
                      'PrefixHeader.pch' => 'Business',
         | 
| 235 | 
            +
                      'CategoryHeader.h' => 'Category',
         | 
| 236 | 
            +
                      'ToolsHeader.h' => 'Tools',
         | 
| 237 | 
            +
                      'vendorHeader.h' => 'Vendor'
         | 
| 238 | 
            +
                    }
         | 
| 239 | 
            +
             | 
| 240 | 
            +
                    private_level_folder_files.each do |file_name, folder|
         | 
| 241 | 
            +
                      final_prefix = @prefixed_module
         | 
| 242 | 
            +
                      if file_name == 'PrefixHeader.pch'
         | 
| 243 | 
            +
                        final_prefix = @module
         | 
| 244 | 
            +
                      end
         | 
| 245 | 
            +
             | 
| 246 | 
            +
                      final_file = "#{private_folder_path}/#{folder}/#{final_prefix}#{file_name}"
         | 
| 247 | 
            +
                      source = "#{__dir__}/template/objc/#{file_name}"
         | 
| 248 | 
            +
                      template source, final_file
         | 
| 249 | 
            +
                    end
         | 
| 250 | 
            +
             | 
| 251 | 
            +
                    tools_files_path = "#{@final_path}/#{@name}/Classes/Private/Tools"
         | 
| 252 | 
            +
             | 
| 253 | 
            +
                    tool_files = ['Bundle.h','Bundle.m']
         | 
| 254 | 
            +
                    tool_files.each do |file_name|
         | 
| 255 | 
            +
                      final_file = "#{tools_files_path}/#{@prefixed_module}#{file_name}"
         | 
| 256 | 
            +
                      source = "#{__dir__}/template/objc/#{file_name}"
         | 
| 257 | 
            +
                      template source, final_file
         | 
| 258 | 
            +
                    end
         | 
| 259 | 
            +
             | 
| 260 | 
            +
                    business_demo_path = "#{@final_path}/#{@name}/Classes/Private/Business"
         | 
| 261 | 
            +
                    demo_replace_file = ['DemoViewController.h', 'DemoViewController.m', 'DemoViewModel.h', 'DemoViewModel.m']
         | 
| 262 | 
            +
                    demo_replace_file.each do |file_name|
         | 
| 263 | 
            +
                      final_file = "#{business_demo_path}/Demo/#{@prefixed_module}#{file_name}"
         | 
| 264 | 
            +
                      source = "#{__dir__}/template/objc/demo/#{file_name}"
         | 
| 265 | 
            +
                      template source, final_file
         | 
| 266 | 
            +
                    end
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                    Dir.chdir("#{@final_path}/Example") do
         | 
| 269 | 
            +
                      system 'pod install'
         | 
| 270 | 
            +
                      system "open './#{@name}.xcworkspace'"
         | 
| 271 | 
            +
                    end
         | 
| 272 | 
            +
                  end
         | 
| 273 | 
            +
                end
         | 
| 274 | 
            +
              end
         | 
| 275 | 
            +
            end
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            //
         | 
| 2 | 
            +
            //  <%= @prefixed_module %>Interactor.swift
         | 
| 3 | 
            +
            //  <%= @project %>
         | 
| 4 | 
            +
            //
         | 
| 5 | 
            +
            //  Created by <%= @author %> on <%= @date %>.
         | 
| 6 | 
            +
            //
         | 
| 7 | 
            +
            //
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            import Foundation
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            protocol <%= @prefixed_module %>InteractorProtocol {
         | 
| 12 | 
            +
            }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            class <%= @prefixed_module %>Interactor: <%= @prefixed_module %>InteractorProtocol {
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            }
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            //
         | 
| 2 | 
            +
            //  <%= @prefixed_module %>Presenter.swift
         | 
| 3 | 
            +
            //  <%= @project %>
         | 
| 4 | 
            +
            //
         | 
| 5 | 
            +
            //  Created by <%= @author %> on <%= @date %>.
         | 
| 6 | 
            +
            //
         | 
| 7 | 
            +
            //
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            import Foundation
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            protocol <%= @prefixed_module %>PresenterProtocol: AnyObject {
         | 
| 12 | 
            +
                func notifySignInTapped()
         | 
| 13 | 
            +
                func notifySignUpTapped()
         | 
| 14 | 
            +
            }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            class <%= @prefixed_module %>Presenter: <%= @prefixed_module %>PresenterProtocol {
         | 
| 17 | 
            +
                weak var view: <%= @prefixed_module %>ViewProtocol?
         | 
| 18 | 
            +
                var router: <%= @prefixed_module %>RouterProtocol?
         | 
| 19 | 
            +
                var interactor: <%= @prefixed_module %>InteractorProtocol?
         | 
| 20 | 
            +
                
         | 
| 21 | 
            +
                func notifySignInTapped() {
         | 
| 22 | 
            +
                    router?.routeToSignIn(view as! <%= @prefixed_module %>ViewController)
         | 
| 23 | 
            +
                }
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                func notifySignUpTapped() {
         | 
| 26 | 
            +
                    router?.routeToSignUp(view as! <%= @prefixed_module %>ViewController)
         | 
| 27 | 
            +
                }
         | 
| 28 | 
            +
            }
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            //
         | 
| 2 | 
            +
            //  <%= @prefixed_module %>Router.swift
         | 
| 3 | 
            +
            //  <%= @project %>
         | 
| 4 | 
            +
            //
         | 
| 5 | 
            +
            //  Created by <%= @author %> on <%= @date %>.
         | 
| 6 | 
            +
            //
         | 
| 7 | 
            +
            //
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            import UIKit
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            typealias <%= @prefixed_module %>Entry = <%= @prefixed_module %>ViewProtocol & UIViewController
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            protocol <%= @prefixed_module %>RouterProtocol {
         | 
| 14 | 
            +
                var entry: <%= @prefixed_module %>Entry? { get set }
         | 
| 15 | 
            +
                func routeToSignIn(_ view: <%= @prefixed_module %>ViewProtocol)
         | 
| 16 | 
            +
                func routeToSignUp(_ view: <%= @prefixed_module %>ViewProtocol)
         | 
| 17 | 
            +
            }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            class <%= @prefixed_module %>Router: <%= @prefixed_module %>RouterProtocol {
         | 
| 20 | 
            +
                
         | 
| 21 | 
            +
                var entry: <%= @prefixed_module %>Entry?
         | 
| 22 | 
            +
                
         | 
| 23 | 
            +
                static func createModule() -> <%= @prefixed_module %>RouterProtocol {
         | 
| 24 | 
            +
                    let view = <%= @prefixed_module %>ViewController()
         | 
| 25 | 
            +
                    let interactor = <%= @prefixed_module %>Interactor()
         | 
| 26 | 
            +
                    let presenter = <%= @prefixed_module %>Presenter()
         | 
| 27 | 
            +
                    let router = <%= @prefixed_module %>Router()
         | 
| 28 | 
            +
                    
         | 
| 29 | 
            +
                    view.presenter = presenter
         | 
| 30 | 
            +
                    interactor.presenter = presenter
         | 
| 31 | 
            +
                    presenter.view = view
         | 
| 32 | 
            +
                    presenter.router = router
         | 
| 33 | 
            +
                    presenter.interactor = interactor
         | 
| 34 | 
            +
                    router.entry = view
         | 
| 35 | 
            +
                    
         | 
| 36 | 
            +
                    return router
         | 
| 37 | 
            +
                }
         | 
| 38 | 
            +
                
         | 
| 39 | 
            +
                func routeToSignIn(_ view: <%= @prefixed_module %>ViewProtocol) {
         | 
| 40 | 
            +
                    let signInVC = SignInRouter.createModule()
         | 
| 41 | 
            +
                    guard let view = view as? UIViewController else { return }
         | 
| 42 | 
            +
                    view.navigationController?.pushViewController(signInVC, animated: true)
         | 
| 43 | 
            +
                }
         | 
| 44 | 
            +
                
         | 
| 45 | 
            +
                func routeToSignUp(_ view: <%= @prefixed_module %>ViewProtocol) {
         | 
| 46 | 
            +
                    let signUpVC = SignUpRouter.createModule()
         | 
| 47 | 
            +
                    guard let view = view as? UIViewController else { return }
         | 
| 48 | 
            +
                    view.navigationController?.pushViewController(signUpVC, animated: true)
         | 
| 49 | 
            +
                }
         | 
| 50 | 
            +
            }
         | 
| @@ -0,0 +1,97 @@ | |
| 1 | 
            +
            //
         | 
| 2 | 
            +
            //  <%= @prefixed_module %>ViewController.swift
         | 
| 3 | 
            +
            //  <%= @project %>
         | 
| 4 | 
            +
            //
         | 
| 5 | 
            +
            //  Created by <%= @author %> on <%= @date %>.
         | 
| 6 | 
            +
            //
         | 
| 7 | 
            +
            //
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            import UIKit
         | 
| 10 | 
            +
            protocol <%= @prefixed_module %>ViewProtocol: AnyObject {
         | 
| 11 | 
            +
                
         | 
| 12 | 
            +
            }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            class <%= @prefixed_module %>ViewController: UIViewController, <%= @prefixed_module %>ViewProtocol {
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                var presenter: <%= @prefixed_module %>PresenterProtocol?
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                lazy var button1: UIButton = {
         | 
| 19 | 
            +
                        let button = UIButton(type: .system)
         | 
| 20 | 
            +
                        button.setTitle("button 1", for: .normal)
         | 
| 21 | 
            +
                        button.addTarget(self, action: #selector(sampleButton1Tapped), for: .touchUpInside)
         | 
| 22 | 
            +
                        return button
         | 
| 23 | 
            +
                    }()
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    lazy var button2: UIButton = {
         | 
| 26 | 
            +
                        let button = UIButton(type: .system)
         | 
| 27 | 
            +
                        button.setTitle("button 2", for: .normal)
         | 
| 28 | 
            +
                        button.addTarget(self, action: #selector(sampleButton2Tapped), for: .touchUpInside)
         | 
| 29 | 
            +
                        return button
         | 
| 30 | 
            +
                    }()
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    //MARK: - View LifeCycle
         | 
| 33 | 
            +
                    override func viewDidLoad() {
         | 
| 34 | 
            +
                        super.viewDidLoad()
         | 
| 35 | 
            +
                        configureUI()
         | 
| 36 | 
            +
                        navigationItem.title = "Sample ViewController"
         | 
| 37 | 
            +
                    }
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    override func viewWillAppear(_ animated: Bool) {
         | 
| 40 | 
            +
                        super.viewWillAppear(animated)
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    }
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    override func viewWillDisappear(_ animated: Bool) {
         | 
| 45 | 
            +
                        super.viewWillDisappear(animated)
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                    }
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                    override func viewDidLayoutSubviews() {
         | 
| 50 | 
            +
                        super.viewDidLayoutSubviews()
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                    }
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    //MARK: - View Configurations
         | 
| 55 | 
            +
                    private func configureUI() {
         | 
| 56 | 
            +
                        view.backgroundColor = .white
         | 
| 57 | 
            +
                        embedViewController(containerView: view, controller: PeaceCometsViewController(), previous: nil)
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                        view.addSubview(button1)
         | 
| 60 | 
            +
                        view.addSubview(button2)
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                        button1.backgroundColor = UIColor.purple.withAlphaComponent(0.5)
         | 
| 63 | 
            +
                        button2.backgroundColor = UIColor.red.withAlphaComponent(0.5)
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                        setupConstraints()
         | 
| 66 | 
            +
                    }
         | 
| 67 | 
            +
             | 
| 68 | 
            +
             | 
| 69 | 
            +
                    func setupConstraints() {
         | 
| 70 | 
            +
                        button1.snp.makeConstraints { make in
         | 
| 71 | 
            +
                            make.centerX.equalToSuperview()
         | 
| 72 | 
            +
                            make.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(100)
         | 
| 73 | 
            +
                            make.width.equalTo(200)
         | 
| 74 | 
            +
                            make.height.equalTo(50)
         | 
| 75 | 
            +
                        }
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                        button2.snp.makeConstraints { make in
         | 
| 78 | 
            +
                            make.centerX.equalToSuperview()
         | 
| 79 | 
            +
                            make.top.equalTo(button1.snp.bottom).offset(20)
         | 
| 80 | 
            +
                            make.width.equalTo(200)
         | 
| 81 | 
            +
                            make.height.equalTo(50)
         | 
| 82 | 
            +
                        }
         | 
| 83 | 
            +
                    }
         | 
| 84 | 
            +
             | 
| 85 | 
            +
             | 
| 86 | 
            +
                    @objc func sampleButton1Tapped() {
         | 
| 87 | 
            +
                        print("sample button 1 tapped")
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                    }
         | 
| 90 | 
            +
             | 
| 91 | 
            +
             | 
| 92 | 
            +
                    @objc func sampleButton2Tapped() {
         | 
| 93 | 
            +
                        print("sample button 2 tapped")
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                    }
         | 
| 96 | 
            +
            }
         | 
| 97 | 
            +
             | 
    
        data/lib/mt_tool/version.rb
    CHANGED
    
    
    
        data/mt_tool.gemspec
    CHANGED
    
    | @@ -13,37 +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 | 
            -
               | 
| 19 | 
            -
             | 
| 20 | 
            -
                 | 
| 21 | 
            -
             | 
| 22 | 
            -
                 | 
| 23 | 
            -
             | 
| 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 | 
            -
              #  | 
| 31 | 
            -
               | 
| 32 | 
            -
              spec.add_development_dependency ' | 
| 33 | 
            -
              spec.add_development_dependency ' | 
| 34 | 
            -
              spec.add_development_dependency ' | 
| 35 | 
            -
              spec.add_development_dependency ' | 
| 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 'pathname'
         | 
| 46 | 
            -
             | 
| 47 | 
            -
              # For more information and examples about making a new gem, check out our
         | 
| 48 | 
            -
              # 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'
         | 
| 49 46 | 
             
            end
         |