MTViperFiles 0.1.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 (36) hide show
  1. checksums.yaml +7 -0
  2. data/.MTViperFiles.yml +5 -0
  3. data/.gitignore +9 -0
  4. data/Gemfile +6 -0
  5. data/LICENSE +21 -0
  6. data/License.txt +22 -0
  7. data/MTViperFiles.gemspec +21 -0
  8. data/README.md +37 -0
  9. data/bin/MTViperFiles +9 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/lib/MTViperFiles.rb +2 -0
  13. data/lib/MTViperFiles/commands.rb +103 -0
  14. data/lib/MTViperFiles/module/module.rb +111 -0
  15. data/lib/MTViperFiles/module/templates/objc/DataManager.h +16 -0
  16. data/lib/MTViperFiles/module/templates/objc/DataManager.m +13 -0
  17. data/lib/MTViperFiles/module/templates/objc/DependenciesBody.m +32 -0
  18. data/lib/MTViperFiles/module/templates/objc/DependenciesHead.m +4 -0
  19. data/lib/MTViperFiles/module/templates/objc/Interactor.h +24 -0
  20. data/lib/MTViperFiles/module/templates/objc/Interactor.m +13 -0
  21. data/lib/MTViperFiles/module/templates/objc/ModuleInterface.h +23 -0
  22. data/lib/MTViperFiles/module/templates/objc/Presenter.h +30 -0
  23. data/lib/MTViperFiles/module/templates/objc/Presenter.m +17 -0
  24. data/lib/MTViperFiles/module/templates/objc/ViewController.h +23 -0
  25. data/lib/MTViperFiles/module/templates/objc/ViewController.m +52 -0
  26. data/lib/MTViperFiles/module/templates/objc/ViewInterface.h +16 -0
  27. data/lib/MTViperFiles/module/templates/objc/Wireframe.h +27 -0
  28. data/lib/MTViperFiles/module/templates/objc/Wireframe.m +33 -0
  29. data/lib/MTViperFiles/templates/objc/AppDelegate.h +18 -0
  30. data/lib/MTViperFiles/templates/objc/AppDelegate.m +38 -0
  31. data/lib/MTViperFiles/templates/objc/AppDependencies.h +20 -0
  32. data/lib/MTViperFiles/templates/objc/AppDependencies.m +50 -0
  33. data/lib/MTViperFiles/templates/objc/RootWireframe.h +19 -0
  34. data/lib/MTViperFiles/templates/objc/RootWireframe.m +27 -0
  35. data/lib/MTViperFiles/version.rb +3 -0
  36. metadata +122 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2d2facc0c28e1594f3ccd93f3ba9d543682b45f3ed927ca91737f8d72c254023
4
+ data.tar.gz: 4e1781d337a2e83100373f9a0fcf1b26368bd7aba0773c990c6a49732e7cd626
5
+ SHA512:
6
+ metadata.gz: e40d7d390cb4b689f10a7ab3af7b68b82ef80cf0342a87c76af38bfeb0d1d679c385261e41f3d0a98da70cf97cb1eee1e035d02859f0b393d3c6733ebfd683c0
7
+ data.tar.gz: 9825198f3fbb724feb59bd86c513730728011cdd6c89bda0145b533f604f6083a90d4c2531f7a18f805b2f1efdff7fae8ae3bce2a623e47727557b0f277731c7
data/.MTViperFiles.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :project: TT
3
+ :language: objc
4
+ :class_prefix: MT
5
+ :author: Major Tom
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in MTViperFiles.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Nilesh Agrawal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/License.txt ADDED
@@ -0,0 +1,22 @@
1
+ copyright (c) 2014 Nilesh Agrawal
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "MTViperFiles/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "MTViperFiles"
8
+ spec.version = MTViperFiles::VERSION
9
+ spec.authors = ["MTTGCC"]
10
+ spec.email = ["xbwudi20092@gmail.com"]
11
+ spec.summary = %q{Generates Objective C files for Viper Module Initialization.}
12
+ spec.description = %q{Creates all the files and setup required for Viper Architecture in iOS.}
13
+ spec.homepage = "https://github.com/lyle92"
14
+ spec.licenses = "MIT"
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+ spec.add_development_dependency "bundler", "~> 1.15"
19
+ spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency "thor"
21
+ end
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # MTViperFiles
2
+ MTViperFiles is a automatic code generator for VIPER Architecture in iOS.
3
+ It helps in setting up intial project files and creating viper modules in objective C only.
4
+ Understand what Viper architecture is : https://medium.com/trendyol-tech/creating-an-ios-viper-module-step-by-step-guide-cd1f414b7dd3
5
+
6
+ ## Requirements
7
+ * Objective-C
8
+ * ruby
9
+
10
+ ## Installation
11
+
12
+ Install gem with:
13
+
14
+ $ gem install MTViperFiles
15
+
16
+
17
+ ## Usage
18
+
19
+ 1. Create an Xcode project
20
+ 2. Initialize basic VIPER structure with
21
+ ```
22
+ MTViperFiles init
23
+ ```
24
+ 3. Input Required
25
+
26
+ * your project name
27
+ * preferred language
28
+ * author
29
+ * class prefix
30
+ (these will be used in generated files). This input setting is stored in '.MTViperFiles.yml' file.
31
+ You can change these settings in `.MTViperFiles.yml`
32
+
33
+ 4. Create your module with
34
+ ```
35
+ MTViperFiles module create Example
36
+ ```
37
+ You can use saved configuration by just pressing enters.
data/bin/MTViperFiles ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
3
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
4
+
5
+ require 'rubygems'
6
+ require 'thor'
7
+ require 'MTViperFiles'
8
+
9
+ MTViperFiles::Commands.start
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "MTViperFiles"
5
+ require "thor"
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ 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
@@ -0,0 +1,2 @@
1
+ require 'MTViperFiles/version'
2
+ require 'MTViperFiles/commands'
@@ -0,0 +1,103 @@
1
+ require 'MTViperFiles/module/module'
2
+ require 'yaml'
3
+
4
+ module MTViperFiles
5
+ class Commands < Thor
6
+ include Thor::Actions
7
+
8
+ # ----
9
+ # register additional moduls
10
+ register(MTViperFiles::Module, 'module', 'module [COMMAND]', 'Managing modules.')
11
+ MTViperFiles::Commands.source_root(File.dirname(__FILE__))
12
+
13
+ # ----
14
+ # initialize VIPER hierarchy
15
+ BASE_FILES_OBJC = {
16
+ 'AppDelegate.h' => 'Classes',
17
+ 'AppDelegate.m' => 'Classes',
18
+ 'AppDependencies.h' => 'Classes',
19
+ 'AppDependencies.m' => 'Classes'
20
+ }
21
+
22
+ BASE_FILES_SWIFT = {
23
+ 'AppDelegate.swift' => 'Classes',
24
+ 'AppDependencies.swift' => 'Classes'
25
+ }
26
+
27
+ PROJECT_FILES_OBJC = {
28
+ 'RootWireframe.h' => 'Classes/Common/Wireframe',
29
+ 'RootWireframe.m' => 'Classes/Common/Wireframe'
30
+ }
31
+
32
+ PROJECT_FILES_SWIFT = {
33
+ 'RootWireframe.swift' => 'Classes/Common/Wireframe'
34
+ }
35
+
36
+ desc 'init', 'initializes VIPER project'
37
+ def init
38
+ config = invoke(:configure, [])
39
+
40
+ # Classes
41
+ empty_directory 'Classes'
42
+
43
+ # Classes/Common
44
+ empty_directory 'Classes/Common'
45
+ empty_directory 'Classes/Common/Categories'
46
+ empty_directory 'Classes/Common/Model'
47
+ empty_directory 'Classes/Common/Store'
48
+ empty_directory 'Classes/Common/Utils'
49
+ empty_directory 'Classes/Common/Wireframe'
50
+
51
+ # Classes/Modules
52
+ empty_directory 'Classes/Modules'
53
+
54
+ # Add config
55
+ @project = config[:project]
56
+ @author = config[:author]
57
+ @date = Time.now.strftime('%d/%m/%y')
58
+ lang = config[:language]
59
+
60
+ # Generate files
61
+ base_files = case lang
62
+ when 'objc' then BASE_FILES_OBJC
63
+ when 'swift' then BASE_FILES_SWIFT
64
+ end
65
+ base_files.each do |file_name, folder|
66
+ template "templates/#{lang}/#{file_name}", "#{folder}/#{@project}#{file_name}"
67
+ end
68
+
69
+ project_files = case lang
70
+ when 'objc' then PROJECT_FILES_OBJC
71
+ when 'swift' then PROJECT_FILES_SWIFT
72
+ end
73
+ project_files.each do |file_name, folder|
74
+ template "templates/#{lang}/#{file_name}", "#{folder}/#{file_name}"
75
+ end
76
+ end
77
+
78
+ # ----
79
+ # configuration
80
+ CONFIG_FILE = '.MTViperFiles.yml'
81
+
82
+ desc 'configure', 'configures project properties'
83
+ def configure
84
+ config = File.exists?(CONFIG_FILE) ? YAML.load_file(CONFIG_FILE) : {}
85
+
86
+ project = ask("Project name [#{config[:project]}] ?")
87
+ language = ask("Project language [#{config[:language]}] ?", :limited_to => ["objc", "swift", ""])
88
+ class_prefix = ask("Class prefix [#{config[:class_prefix]}] ?")
89
+ author = ask("Author [#{config[:author]}] ?")
90
+
91
+ config[:project] = project.empty? ? config[:project] || '' : project
92
+ config[:language] = language.empty? ? config[:language] || 'objc' : language
93
+ config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
94
+ config[:author] = author.empty? ? config[:author] || '' : author
95
+
96
+ File.open(CONFIG_FILE, 'w') do |f|
97
+ f.write config.to_yaml
98
+ end
99
+
100
+ config
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,111 @@
1
+ require 'tempfile'
2
+
3
+ module MTViperFiles
4
+ class Module < Thor
5
+ include Thor::Actions
6
+
7
+ BASE_PATH = 'Classes/Modules'
8
+
9
+ FILES_OBJC = {
10
+ 'DataManager.h' => 'DataManager',
11
+ 'DataManager.m' => 'DataManager',
12
+ 'Interactor.h' => 'Interactor',
13
+ 'Interactor.m' => 'Interactor',
14
+ 'ModuleInterface.h' => 'ModuleInterface',
15
+ 'Presenter.h' => 'Presenter',
16
+ 'Presenter.m' => 'Presenter',
17
+ 'ViewInterface.h' => 'View',
18
+ 'ViewController.h' => 'View',
19
+ 'ViewController.m' => 'View',
20
+ 'Wireframe.h' => 'Wireframe',
21
+ 'Wireframe.m' => 'Wireframe'
22
+ }
23
+
24
+
25
+ MTViperFiles::Module.source_root(File.dirname(__FILE__))
26
+
27
+ desc 'list', 'lists available VIPER modules'
28
+ def list
29
+ return unless File.exists? BASE_PATH
30
+
31
+ module_names = Dir.entries(BASE_PATH).reject { |d| d == '.' || d == '..' }
32
+ print_table module_names.map.with_index { |m, i| [i+1, m] }
33
+ end
34
+
35
+ desc 'create NAME', 'adds a new VIPER module with the specified name'
36
+ def create(module_name)
37
+ config = invoke(:configure, [])
38
+
39
+ @module = module_name
40
+ @prefixed_module = config[:class_prefix] + @module
41
+ @project = config[:project]
42
+ @author = config[:author]
43
+ @date = Time.now.strftime('%d/%m/%y')
44
+ lang = config[:language]
45
+
46
+ # copying template files
47
+ files = case lang
48
+ when 'objc' then FILES_OBJC
49
+ end
50
+ files.each do |file_name, folder|
51
+ template "templates/#{lang}/#{file_name}", "#{BASE_PATH}/#{@module}/#{folder}/#{@prefixed_module}#{file_name}"
52
+ end
53
+
54
+ # rendering dependencies head
55
+ path = Dir::Tmpname.create('dep') { |path| path }
56
+ case lang
57
+ when 'objc' then template('templates/objc/DependenciesHead.m', path)
58
+ end
59
+
60
+ say "\nAdd these lines to the AppDependencies imports:\n\n", :green
61
+ say File.open(path).read + "\n", :yellow
62
+
63
+ # rendering dependencies body
64
+ path = Dir::Tmpname.create('dep') { |path| path }
65
+ case lang
66
+ when 'objc' then template('templates/objc/DependenciesBody.m', path)
67
+ end
68
+
69
+ say "\nAdd these lines to the AppDependencies#configureDependencies:\n\n", :green
70
+ say File.open(path).read + "\n", :yellow
71
+ end
72
+
73
+ desc 'destroy NAME', 'destroys VIPER module with the specified name'
74
+ def destroy(module_name)
75
+ @module = module_name
76
+
77
+ module_path = "#{BASE_PATH}/#{@module}"
78
+
79
+ if File.exists? module_path
80
+ remove_dir module_path if yes?("Really destroy module: #{@module}? [y/N]")
81
+ else
82
+ say "No such module: #{@module}"
83
+ end
84
+ end
85
+
86
+ # ----
87
+ # configuration
88
+ CONFIG_FILE = '.MTViperFiles.yml'
89
+
90
+ desc 'configure', 'configures project properties'
91
+ def configure
92
+ config = File.exists?(CONFIG_FILE) ? YAML.load_file(CONFIG_FILE) : {}
93
+
94
+ project = ask("Project name [#{config[:project]}] ?")
95
+ language = ask("Project language [#{config[:language]}] ?", :limited_to => ["objc", "swift", ""])
96
+ class_prefix = ask("Class prefix [#{config[:class_prefix]}] ?")
97
+ author = ask("Author [#{config[:author]}] ?")
98
+
99
+ config[:project] = project.empty? ? config[:project] || '' : project
100
+ config[:language] = language.empty? ? config[:language] || 'objc' : language
101
+ config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
102
+ config[:author] = author.empty? ? config[:author] || '' : author
103
+
104
+ File.open(CONFIG_FILE, 'w') do |f|
105
+ f.write config.to_yaml
106
+ end
107
+
108
+ config
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,16 @@
1
+ //
2
+ // <%= @prefixed_module %>DataManager.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ /**
12
+ Data manager for the <%= @module %> module.
13
+ */
14
+ @interface <%= @prefixed_module %>DataManager : NSObject
15
+
16
+ @end
@@ -0,0 +1,13 @@
1
+ //
2
+ // <%= @prefixed_module %>DataManager.m
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import "<%= @prefixed_module %>DataManager.h"
10
+
11
+ @implementation <%= @prefixed_module %>DataManager
12
+
13
+ @end
@@ -0,0 +1,32 @@
1
+ // ------------------------------------------------------------------
2
+ // begin <%= @module %> module
3
+
4
+ // instantiate classes
5
+ <%= @prefixed_module %>Wireframe *<%= @module.downcase %>Wireframe = [<%= @prefixed_module %>Wireframe new];
6
+ <%= @prefixed_module %>Presenter *<%= @module.downcase %>Presenter = [<%= @prefixed_module %>Presenter new];
7
+ <%= @prefixed_module %>DataManager *<%= @module.downcase %>DataManager = [<%= @prefixed_module %>DataManager new];
8
+ <%= @prefixed_module %>Interactor *<%= @module.downcase %>Interactor = [<%= @prefixed_module %>Interactor new];
9
+
10
+ // presenter <-> wireframe
11
+ <%= @module.downcase %>Presenter.wireframe = <%= @module.downcase %>Wireframe;
12
+ <%= @module.downcase %>Wireframe.presenter = <%= @module.downcase %>Presenter;
13
+
14
+ // presenter <-> interactor
15
+ <%= @module.downcase %>Presenter.interactor = <%= @module.downcase %>Interactor;
16
+ <%= @module.downcase %>Interactor.presenter = <%= @module.downcase %>Presenter;
17
+
18
+ // interactor -> data_manager
19
+ <%= @module.downcase %>Interactor.dataManager = <%= @module.downcase %>DataManager;
20
+
21
+ // data_manager -> data_store
22
+ // *** connect datastore
23
+
24
+ // connect wireframes
25
+ <%= @module.downcase %>Wireframe.rootWireframe = rootWireframe;
26
+ // *** connect more wireframes
27
+
28
+ // configure delegate
29
+ // *** add delegate here if needed
30
+
31
+ // end <%= @module %> module
32
+ // ------------------------------------------------------------------
@@ -0,0 +1,4 @@
1
+ #import "<%= @prefixed_module %>Wireframe.h"
2
+ #import "<%= @prefixed_module %>Presenter.h"
3
+ #import "<%= @prefixed_module %>DataManager.h"
4
+ #import "<%= @prefixed_module %>Interactor.h"
@@ -0,0 +1,24 @@
1
+ //
2
+ // <%= @prefixed_module %>Interactor.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ #import "<%= @prefixed_module %>Presenter.h"
12
+ #import "<%= @prefixed_module %>DataManager.h"
13
+
14
+ @class <%= @prefixed_module %>Presenter;
15
+
16
+ /**
17
+ Business logic for the <%= @module %> module.
18
+ */
19
+ @interface <%= @prefixed_module %>Interactor : NSObject
20
+
21
+ @property (nonatomic, weak) <%= @prefixed_module %>Presenter *presenter;
22
+ @property (nonatomic, strong) <%= @prefixed_module %>DataManager *dataManager;
23
+
24
+ @end
@@ -0,0 +1,13 @@
1
+ //
2
+ // <%= @prefixed_module %>Interactor.m
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import "<%= @prefixed_module %>Interactor.h"
10
+
11
+ @implementation <%= @prefixed_module %>Interactor
12
+
13
+ @end
@@ -0,0 +1,23 @@
1
+ //
2
+ // <%= @prefixed_module %>ModuleInterface.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ /**
12
+ Module interface for the <%= @module %> module.
13
+ */
14
+ @protocol <%= @prefixed_module %>ModuleInterface <NSObject>
15
+
16
+ @end
17
+
18
+ /**
19
+ Module delegate for the <%= @module %> module.
20
+ */
21
+ @protocol <%= @prefixed_module %>ModuleDelegate <NSObject>
22
+
23
+ @end
@@ -0,0 +1,30 @@
1
+ //
2
+ // <%= @prefixed_module %>Presenter.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ #import "<%= @prefixed_module %>ModuleInterface.h"
12
+
13
+ #import "<%= @prefixed_module %>Interactor.h"
14
+ #import "<%= @prefixed_module %>Wireframe.h"
15
+ #import "<%= @prefixed_module %>ViewInterface.h"
16
+
17
+ @class <%= @prefixed_module %>Wireframe;
18
+ @class <%= @prefixed_module %>Interactor;
19
+
20
+ /**
21
+ Display logic for the <%= @module %> module.
22
+ */
23
+ @interface <%= @prefixed_module %>Presenter : NSObject <<%= @prefixed_module %>ModuleInterface>
24
+
25
+ @property (nonatomic, strong) <%= @prefixed_module %>Interactor *interactor;
26
+ @property (nonatomic, weak) <%= @prefixed_module %>Wireframe *wireframe;
27
+
28
+ @property (nonatomic, weak) UIViewController<<%= @prefixed_module %>ViewInterface> *userInterface;
29
+
30
+ @end
@@ -0,0 +1,17 @@
1
+ //
2
+ // <%= @prefixed_module %>Presenter.m
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import "<%= @prefixed_module %>Presenter.h"
10
+
11
+ @implementation <%= @prefixed_module %>Presenter
12
+
13
+ #pragma mark - <%= @prefixed_module %>ModuleInterface methods
14
+
15
+ // implement module interface here
16
+
17
+ @end
@@ -0,0 +1,23 @@
1
+ //
2
+ // <%= @prefixed_module %>ViewController.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <UIKit/UIKit.h>
10
+
11
+ #import "<%= @prefixed_module %>ModuleInterface.h"
12
+ #import "<%= @prefixed_module %>ViewInterface.h"
13
+
14
+ /**
15
+ View controller for the <%= @module %> module.
16
+ */
17
+ @interface <%= @prefixed_module %>ViewController : UIViewController <<%= @prefixed_module %>ViewInterface>
18
+
19
+ @property (nonatomic, strong) id<<%= @prefixed_module %>ModuleInterface> eventHandler;
20
+
21
+ // *** add UI events here
22
+
23
+ @end
@@ -0,0 +1,52 @@
1
+ //
2
+ // <%= @prefixed_module %>ViewController.m
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import "<%= @prefixed_module %>ViewController.h"
10
+
11
+ @interface <%= @prefixed_module %>ViewController ()
12
+
13
+ @end
14
+
15
+ @implementation <%= @prefixed_module %>ViewController
16
+
17
+ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18
+ {
19
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20
+ if (self)
21
+ {
22
+ // Custom initialization
23
+ }
24
+ return self;
25
+ }
26
+
27
+ #pragma mark - View lifecycle
28
+
29
+ - (void)viewDidLoad
30
+ {
31
+ [super viewDidLoad];
32
+ }
33
+
34
+ - (void)viewWillAppear:(BOOL)animated
35
+ {
36
+ [super viewWillAppear:animated];
37
+ }
38
+
39
+ - (void)viewDidAppear:(BOOL)animated
40
+ {
41
+ [super viewDidAppear:animated];
42
+ }
43
+
44
+ #pragma mark - <%= @prefixed_module %>ViewInterface methods
45
+
46
+ // *** implement view_interface methods here
47
+
48
+ #pragma mark - Button event handlers
49
+
50
+ // ** handle UI events here
51
+
52
+ @end
@@ -0,0 +1,16 @@
1
+ //
2
+ // <%= @prefixed_module %>View.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ /**
12
+ View interface for the <%= @module %> module.
13
+ */
14
+ @protocol <%= @prefixed_module %>ViewInterface <NSObject>
15
+
16
+ @end
@@ -0,0 +1,27 @@
1
+ //
2
+ // <%= @prefixed_module %>Wireframe.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ #import "RootWireframe.h"
12
+ #import "<%= @prefixed_module %>Presenter.h"
13
+
14
+ @class <%= @prefixed_module %>Presenter;
15
+
16
+ /**
17
+ Module wireframe for the <%= @module %> module.
18
+ */
19
+ @interface <%= @prefixed_module %>Wireframe : NSObject
20
+
21
+ @property (nonatomic, strong) RootWireframe *rootWireframe;
22
+ @property (nonatomic, strong) <%= @prefixed_module %>Presenter *presenter;
23
+
24
+ // initialization
25
+ - (void)presentSelfFromViewController:(UIViewController *)viewController;
26
+
27
+ @end
@@ -0,0 +1,33 @@
1
+ //
2
+ // <%= @prefixed_module %>Wireframe.m
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import "<%= @prefixed_module %>Wireframe.h"
10
+ #import "<%= @prefixed_module %>ViewController.h"
11
+
12
+ @interface <%= @prefixed_module %>Wireframe ()
13
+
14
+ @property (nonatomic, strong) <%= @prefixed_module %>ViewController *viewController;
15
+
16
+ @end
17
+
18
+ @implementation <%= @prefixed_module %>Wireframe
19
+
20
+ - (void)presentSelfFromViewController:(UIViewController *)viewController
21
+ {
22
+ // save reference
23
+ self.viewController = [[<%= @prefixed_module %>ViewController alloc] initWithNibName:@"<%= @prefixed_module %>ViewController" bundle:nil];
24
+
25
+ // view <-> presenter
26
+ self.presenter.userInterface = self.viewController;
27
+ self.viewController.eventHandler = self.presenter;
28
+
29
+ // present controller
30
+ // *** present self with RootViewController
31
+ }
32
+
33
+ @end
@@ -0,0 +1,18 @@
1
+ //
2
+ // <%= @project %>AppDelegate.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <UIKit/UIKit.h>
10
+
11
+ /**
12
+ App delegate for the <%= @project %> project.
13
+ */
14
+ @interface <%= @project %>AppDelegate : UIResponder <UIApplicationDelegate>
15
+
16
+ @property (strong, nonatomic) UIWindow *window;
17
+
18
+ @end
@@ -0,0 +1,38 @@
1
+ //
2
+ // <%= @project %>AppDelegate.m
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import "<%= @project %>AppDelegate.h"
10
+ #import "<%= @project %>AppDependencies.h"
11
+
12
+ @interface <%= @project %>AppDelegate ()
13
+
14
+ @property (nonatomic, strong) <%= @project %>AppDependencies *dependencies;
15
+
16
+ @end
17
+
18
+ @implementation <%= @project %>AppDelegate
19
+
20
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
21
+ {
22
+ // initialize window
23
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
24
+ _window.backgroundColor = [UIColor whiteColor];
25
+
26
+ // initialize dependencies
27
+ <%= @project %>AppDependencies *dependencies = [[<%= @project %>AppDependencies alloc] initWithWindow:self.window];
28
+ self.dependencies = dependencies;
29
+
30
+ // adding RootViewController
31
+ [self.dependencies installRootViewController];
32
+
33
+ [_window makeKeyAndVisible];
34
+
35
+ return YES;
36
+ }
37
+
38
+ @end
@@ -0,0 +1,20 @@
1
+ //
2
+ // <%= @project %>AppDependencies.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import <UIKit/UIKit.h>
11
+
12
+ /**
13
+ Dependency hierarchy for the <%= @project %> project.
14
+ */
15
+ @interface <%= @project %>AppDependencies : NSObject
16
+
17
+ - (id)initWithWindow:(UIWindow *)window;
18
+ - (void)installRootViewController;
19
+
20
+ @end
@@ -0,0 +1,50 @@
1
+ //
2
+ // <%= @project %>AppDependencies.m
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import "<%= @project %>AppDependencies.h"
10
+
11
+ #import "RootWireframe.h"
12
+
13
+ #import "HomeWireframe.h"
14
+ #import "HomePresenter.h"
15
+ #import "HomeDataManager.h"
16
+ #import "HomeInteractor.h"
17
+
18
+ @interface <%= @project %>AppDependencies ()
19
+
20
+ @end
21
+
22
+ @implementation <%= @project %>AppDependencies
23
+
24
+ - (id)initWithWindow:(UIWindow *)window
25
+ {
26
+ if ((self = [super init]))
27
+ {
28
+ [self configureDependencies:window];
29
+ }
30
+
31
+ return self;
32
+ }
33
+
34
+ - (void)installRootViewController
35
+ {
36
+ // *** present first wireframe here
37
+ }
38
+
39
+ - (void)configureDependencies:(UIWindow *)window
40
+ {
41
+ // -----
42
+ // root classes
43
+ RootWireframe *rootWireframe = [[RootWireframe alloc] initWithWindow:window];
44
+ // *** add datastore
45
+
46
+ // *** module initialization
47
+ }
48
+
49
+
50
+ @end
@@ -0,0 +1,19 @@
1
+ //
2
+ // RootWireframe.h
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import <UIKit/UIKit.h>
10
+ #import <Foundation/Foundation.h>
11
+
12
+ /**
13
+ Root wireframe for the <%= @project %> project.
14
+ */
15
+ @interface RootWireframe : NSObject
16
+
17
+ - (id)initWithWindow:(UIWindow *)window;
18
+
19
+ @end
@@ -0,0 +1,27 @@
1
+ //
2
+ // RootWireframe.m
3
+ // <%= @project %>
4
+ //
5
+ // Created by <%= @author %> on <%= @date %>.
6
+ //
7
+ //
8
+
9
+ #import "RootWireframe.h"
10
+
11
+ @interface RootWireframe ()
12
+
13
+ @end
14
+
15
+ @implementation RootWireframe
16
+
17
+ - (id)initWithWindow:(UIWindow *)window
18
+ {
19
+ if ((self = [super init]))
20
+ {
21
+ // custom initialization
22
+ }
23
+
24
+ return self;
25
+ }
26
+
27
+ @end
@@ -0,0 +1,3 @@
1
+ module MTViperFiles
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MTViperFiles
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - MTTGCC
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Creates all the files and setup required for Viper Architecture in iOS.
56
+ email:
57
+ - xbwudi20092@gmail.com
58
+ executables:
59
+ - MTViperFiles
60
+ - console
61
+ - setup
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - ".MTViperFiles.yml"
66
+ - ".gitignore"
67
+ - Gemfile
68
+ - LICENSE
69
+ - License.txt
70
+ - MTViperFiles.gemspec
71
+ - README.md
72
+ - bin/MTViperFiles
73
+ - bin/console
74
+ - bin/setup
75
+ - lib/MTViperFiles.rb
76
+ - lib/MTViperFiles/commands.rb
77
+ - lib/MTViperFiles/module/module.rb
78
+ - lib/MTViperFiles/module/templates/objc/DataManager.h
79
+ - lib/MTViperFiles/module/templates/objc/DataManager.m
80
+ - lib/MTViperFiles/module/templates/objc/DependenciesBody.m
81
+ - lib/MTViperFiles/module/templates/objc/DependenciesHead.m
82
+ - lib/MTViperFiles/module/templates/objc/Interactor.h
83
+ - lib/MTViperFiles/module/templates/objc/Interactor.m
84
+ - lib/MTViperFiles/module/templates/objc/ModuleInterface.h
85
+ - lib/MTViperFiles/module/templates/objc/Presenter.h
86
+ - lib/MTViperFiles/module/templates/objc/Presenter.m
87
+ - lib/MTViperFiles/module/templates/objc/ViewController.h
88
+ - lib/MTViperFiles/module/templates/objc/ViewController.m
89
+ - lib/MTViperFiles/module/templates/objc/ViewInterface.h
90
+ - lib/MTViperFiles/module/templates/objc/Wireframe.h
91
+ - lib/MTViperFiles/module/templates/objc/Wireframe.m
92
+ - lib/MTViperFiles/templates/objc/AppDelegate.h
93
+ - lib/MTViperFiles/templates/objc/AppDelegate.m
94
+ - lib/MTViperFiles/templates/objc/AppDependencies.h
95
+ - lib/MTViperFiles/templates/objc/AppDependencies.m
96
+ - lib/MTViperFiles/templates/objc/RootWireframe.h
97
+ - lib/MTViperFiles/templates/objc/RootWireframe.m
98
+ - lib/MTViperFiles/version.rb
99
+ homepage: https://github.com/lyle92
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.2.16
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Generates Objective C files for Viper Module Initialization.
122
+ test_files: []