MagicViper 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 (35) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +6 -0
  4. data/LICENSE +21 -0
  5. data/License.txt +22 -0
  6. data/MagicViper.gemspec +28 -0
  7. data/README.md +46 -0
  8. data/Rakefile +2 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/lib/MagicViper.rb +2 -0
  12. data/lib/MagicViper/commands.rb +93 -0
  13. data/lib/MagicViper/module/module.rb +85 -0
  14. data/lib/MagicViper/module/templates/objc/DataManager.h +16 -0
  15. data/lib/MagicViper/module/templates/objc/DataManager.m +13 -0
  16. data/lib/MagicViper/module/templates/objc/DependenciesBody.m +32 -0
  17. data/lib/MagicViper/module/templates/objc/DependenciesHead.m +4 -0
  18. data/lib/MagicViper/module/templates/objc/Interactor.h +24 -0
  19. data/lib/MagicViper/module/templates/objc/Interactor.m +13 -0
  20. data/lib/MagicViper/module/templates/objc/ModuleInterface.h +23 -0
  21. data/lib/MagicViper/module/templates/objc/Presenter.h +30 -0
  22. data/lib/MagicViper/module/templates/objc/Presenter.m +17 -0
  23. data/lib/MagicViper/module/templates/objc/ViewController.h +23 -0
  24. data/lib/MagicViper/module/templates/objc/ViewController.m +52 -0
  25. data/lib/MagicViper/module/templates/objc/ViewInterface.h +16 -0
  26. data/lib/MagicViper/module/templates/objc/Wireframe.h +27 -0
  27. data/lib/MagicViper/module/templates/objc/Wireframe.m +33 -0
  28. data/lib/MagicViper/templates/objc/AppDelegate.h +18 -0
  29. data/lib/MagicViper/templates/objc/AppDelegate.m +38 -0
  30. data/lib/MagicViper/templates/objc/AppDependencies.h +20 -0
  31. data/lib/MagicViper/templates/objc/AppDependencies.m +50 -0
  32. data/lib/MagicViper/templates/objc/RootWireframe.h +19 -0
  33. data/lib/MagicViper/templates/objc/RootWireframe.m +27 -0
  34. data/lib/MagicViper/version.rb +3 -0
  35. metadata +118 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8ce1deea65f5fa5d9b4a94f7109fad4cf665dec2
4
+ data.tar.gz: a9c14a5beac20d8eda41170d8c897c3df0c34e9d
5
+ SHA512:
6
+ metadata.gz: 75c5b602273df4d195dfc7bb863dda43cf8052b49c84cc3d08dffae15b39f7fba4f62d8aaf11f6b1ab6864640e9e4ed9d205040bb6fd8e7a416ee1afe004e61c
7
+ data.tar.gz: 72d0470e592e2ebe7c04b1bd8cb59ed3b9ada97e57231d8ec85cf1dde9e8a7c775399b09864c3e60adef08e647ad54201bfec116b58f7b9155556de07d041aee
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 MagicViper.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,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "MagicViper/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "MagicViper"
8
+ spec.version = MagicViper::VERSION
9
+ spec.authors = ["Nilesh Agrawal"]
10
+ spec.email = ["nilesh.d.agrawal@gmail.com"]
11
+
12
+ spec.summary = %q{Generates Objective C files for Viper Module Initialization.}
13
+ spec.description = %q{Creates all the files and setup required for Viper Architecture in iOS.}
14
+ spec.homepage = "https://github.com/ndagrawal"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.15"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "thor", "~> 1.0"
28
+ end
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # MagicViper
2
+ MagicViper 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
+
5
+ ## Requirements
6
+ * Objective-C
7
+
8
+ ## Installation
9
+
10
+ Install gem with:
11
+
12
+ $ gem install MagicViper
13
+
14
+ ## Usage
15
+
16
+ 1. Create an Xcode project
17
+
18
+ 2. Initialize basic VIPER structure with
19
+
20
+ ```
21
+ MagicViper init
22
+ ```
23
+
24
+ 3. Input
25
+
26
+ * your project name
27
+ * preferred language
28
+ * author
29
+ # class prefix
30
+
31
+ (these will be used in generated files). You can change these settings in `.MagicViper.yml`
32
+
33
+ 4. Create your module with
34
+
35
+ ```
36
+ MagicViper module create Example
37
+ ```
38
+
39
+ You can use saved configuration by just pressing enters.
40
+
41
+ #### v1.s
42
+ * initial version
43
+ * added class prefix option
44
+ * added basic appledoc comments for interfaces and protocols
45
+ * using new instead of alloc-init
46
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "MagicViper"
5
+
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
data/lib/MagicViper.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'MagicViper/version'
2
+ require 'MagicViper/commands'
@@ -0,0 +1,93 @@
1
+ require 'MagicViper/module/module'
2
+ require 'yaml'
3
+
4
+ module MagicViper
5
+ class Commands < Thor
6
+ include Thor::Actions
7
+
8
+ # ----
9
+ # register additional moduls
10
+ register(MagicViper::Module, 'module', 'module [COMMAND]', 'Managing modules.')
11
+ MagicViper::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
+ PROJECT_FILES_OBJC = {
23
+ 'RootWireframe.h' => 'Classes/Common/Wireframe',
24
+ 'RootWireframe.m' => 'Classes/Common/Wireframe'
25
+ }
26
+
27
+ desc 'init', 'initializes VIPER project'
28
+ def init
29
+ config = invoke(:configure, [])
30
+
31
+ # Classes
32
+ empty_directory 'Classes'
33
+
34
+ # Classes/Common
35
+ empty_directory 'Classes/Common'
36
+ empty_directory 'Classes/Common/Categories'
37
+ empty_directory 'Classes/Common/Model'
38
+ empty_directory 'Classes/Common/Store'
39
+ empty_directory 'Classes/Common/Utils'
40
+ empty_directory 'Classes/Common/Wireframe'
41
+
42
+ # Classes/Modules
43
+ empty_directory 'Classes/Modules'
44
+
45
+ # Add config
46
+ @project = config[:project]
47
+ @author = config[:author]
48
+ @date = Time.now.strftime('%d/%m/%y')
49
+ lang = config[:language]
50
+
51
+ # Generate files
52
+ base_files = case lang
53
+ when 'objc' then BASE_FILES_OBJC
54
+ end
55
+
56
+ base_files.each do |file_name, folder|
57
+ template "templates/#{lang}/#{file_name}", "#{folder}/#{@project}#{file_name}"
58
+ end
59
+
60
+ project_files = case lang
61
+ when 'objc' then PROJECT_FILES_OBJC
62
+ end
63
+ project_files.each do |file_name, folder|
64
+ template "templates/#{lang}/#{file_name}", "#{folder}/#{file_name}"
65
+ end
66
+ end
67
+
68
+ # ----
69
+ # configuration
70
+ CONFIG_FILE = '.MagicViper.yml'
71
+
72
+ desc 'configure', 'configures project properties'
73
+ def configure
74
+ config = File.exists?(CONFIG_FILE) ? YAML.load_file(CONFIG_FILE) : {}
75
+
76
+ project = ask("Project name [#{config[:project]}] ?")
77
+ language = ask("Project language [#{config[:language]}] ?", :limited_to => ["objc", ""])
78
+ class_prefix = ask("Class prefix [#{config[:class_prefix]}] ?")
79
+ author = ask("Author [#{config[:author]}] ?")
80
+
81
+ config[:project] = project.empty? ? config[:project] || '' : project
82
+ config[:language] = language.empty? ? config[:language] || 'objc' : language
83
+ config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
84
+ config[:author] = author.empty? ? config[:author] || '' : author
85
+
86
+ File.open(CONFIG_FILE, 'w') do |f|
87
+ f.write config.to_yaml
88
+ end
89
+
90
+ config
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,85 @@
1
+ require 'tempfile'
2
+
3
+ module MagicViper
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
+ MagicViper::Module.source_root(File.dirname(__FILE__))
25
+
26
+ desc 'list', 'lists available VIPER modules'
27
+ def list
28
+ return unless File.exists? BASE_PATH
29
+
30
+ module_names = Dir.entries(BASE_PATH).reject { |d| d == '.' || d == '..' }
31
+ print_table module_names.map.with_index { |m, i| [i+1, m] }
32
+ end
33
+
34
+ desc 'create NAME', 'adds a new VIPER module with the specified name'
35
+ def create(module_name)
36
+ config = invoke('boa:commands:configure', [])
37
+
38
+ @module = module_name
39
+ @prefixed_module = config[:class_prefix] + @module
40
+ @project = config[:project]
41
+ @author = config[:author]
42
+ @date = Time.now.strftime('%d/%m/%y')
43
+ lang = config[:language]
44
+
45
+ # copying template files
46
+ files = case lang
47
+ when 'objc' then FILES_OBJC
48
+ end
49
+ files.each do |file_name, folder|
50
+ template "templates/#{lang}/#{file_name}", "#{BASE_PATH}/#{@module}/#{folder}/#{@prefixed_module}#{file_name}"
51
+ end
52
+
53
+ # rendering dependencies head
54
+ path = Dir::Tmpname.create('dep') { |path| path }
55
+ case lang
56
+ when 'objc' then template('templates/objc/DependenciesHead.m', path)
57
+ end
58
+
59
+ say "\nAdd these lines to the AppDependencies imports:\n\n", :green
60
+ say File.open(path).read + "\n", :yellow
61
+
62
+ # rendering dependencies body
63
+ path = Dir::Tmpname.create('dep') { |path| path }
64
+ case lang
65
+ when 'objc' then template('templates/objc/DependenciesBody.m', path)
66
+ end
67
+
68
+ say "\nAdd these lines to the AppDependencies#configureDependencies:\n\n", :green
69
+ say File.open(path).read + "\n", :yellow
70
+ end
71
+
72
+ desc 'destroy NAME', 'destroys VIPER module with the specified name'
73
+ def destroy(module_name)
74
+ @module = module_name
75
+
76
+ module_path = "#{BASE_PATH}/#{@module}"
77
+
78
+ if File.exists? module_path
79
+ remove_dir module_path if yes?("Really destroy module: #{@module}? [y/N]")
80
+ else
81
+ say "No such module: #{@module}"
82
+ end
83
+ end
84
+ end
85
+ 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 MagicViper
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MagicViper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nilesh Agrawal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-16 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: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ description: Creates all the files and setup required for Viper Architecture in iOS.
56
+ email:
57
+ - nilesh.d.agrawal@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE
65
+ - License.txt
66
+ - MagicViper.gemspec
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/MagicViper.rb
72
+ - lib/MagicViper/commands.rb
73
+ - lib/MagicViper/module/module.rb
74
+ - lib/MagicViper/module/templates/objc/DataManager.h
75
+ - lib/MagicViper/module/templates/objc/DataManager.m
76
+ - lib/MagicViper/module/templates/objc/DependenciesBody.m
77
+ - lib/MagicViper/module/templates/objc/DependenciesHead.m
78
+ - lib/MagicViper/module/templates/objc/Interactor.h
79
+ - lib/MagicViper/module/templates/objc/Interactor.m
80
+ - lib/MagicViper/module/templates/objc/ModuleInterface.h
81
+ - lib/MagicViper/module/templates/objc/Presenter.h
82
+ - lib/MagicViper/module/templates/objc/Presenter.m
83
+ - lib/MagicViper/module/templates/objc/ViewController.h
84
+ - lib/MagicViper/module/templates/objc/ViewController.m
85
+ - lib/MagicViper/module/templates/objc/ViewInterface.h
86
+ - lib/MagicViper/module/templates/objc/Wireframe.h
87
+ - lib/MagicViper/module/templates/objc/Wireframe.m
88
+ - lib/MagicViper/templates/objc/AppDelegate.h
89
+ - lib/MagicViper/templates/objc/AppDelegate.m
90
+ - lib/MagicViper/templates/objc/AppDependencies.h
91
+ - lib/MagicViper/templates/objc/AppDependencies.m
92
+ - lib/MagicViper/templates/objc/RootWireframe.h
93
+ - lib/MagicViper/templates/objc/RootWireframe.m
94
+ - lib/MagicViper/version.rb
95
+ homepage: https://github.com/ndagrawal
96
+ licenses: []
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.4.8
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Generates Objective C files for Viper Module Initialization.
118
+ test_files: []