vipergen-roche 0.2.5

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 (64) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +134 -0
  4. data/bin/vipergen +9 -0
  5. data/lib/templates/default/objc/DataManager/API/VIPERAPIDataManager.h +12 -0
  6. data/lib/templates/default/objc/DataManager/API/VIPERAPIDataManager.m +10 -0
  7. data/lib/templates/default/objc/DataManager/Local/VIPERLocalDataManager.h +12 -0
  8. data/lib/templates/default/objc/DataManager/Local/VIPERLocalDataManager.m +10 -0
  9. data/lib/templates/default/objc/Interactor/VIPERInteractor.h +16 -0
  10. data/lib/templates/default/objc/Interactor/VIPERInteractor.m +10 -0
  11. data/lib/templates/default/objc/Interactor/VIPERItem.h +10 -0
  12. data/lib/templates/default/objc/Interactor/VIPERItem.m +10 -0
  13. data/lib/templates/default/objc/Presenter/VIPERPresenter.h +17 -0
  14. data/lib/templates/default/objc/Presenter/VIPERPresenter.m +11 -0
  15. data/lib/templates/default/objc/Protocols/VIPERProtocols.h +80 -0
  16. data/lib/templates/default/objc/View/VIPERView.h +13 -0
  17. data/lib/templates/default/objc/View/VIPERView.m +32 -0
  18. data/lib/templates/default/objc/WireFrame/VIPERWireFrame.h +18 -0
  19. data/lib/templates/default/objc/WireFrame/VIPERWireFrame.m +32 -0
  20. data/lib/templates/default/swift/DataManager/API/VIPERAPIDataManager.swift +11 -0
  21. data/lib/templates/default/swift/DataManager/Local/VIPERLocalDataManager.swift +11 -0
  22. data/lib/templates/default/swift/Interactor/VIPERInteractor.swift +15 -0
  23. data/lib/templates/default/swift/Interactor/VIPERItem.swift +13 -0
  24. data/lib/templates/default/swift/Presenter/VIPERPresenter.swift +15 -0
  25. data/lib/templates/default/swift/Protocols/VIPERProtocols.swift +70 -0
  26. data/lib/templates/default/swift/View/VIPERView.swift +12 -0
  27. data/lib/templates/default/swift/WireFrame/VIPERWireFrame.swift +29 -0
  28. data/lib/templates/default/viperspec.yml +4 -0
  29. data/lib/templates/testable/objc/DataManager/VIPERDataManager.h +15 -0
  30. data/lib/templates/testable/objc/DataManager/VIPERDataManager.m +11 -0
  31. data/lib/templates/testable/objc/Interactor/VIPERInteractor.h +16 -0
  32. data/lib/templates/testable/objc/Interactor/VIPERInteractor.m +10 -0
  33. data/lib/templates/testable/objc/Interactor/VIPERInteractorSpec.m +31 -0
  34. data/lib/templates/testable/objc/Presenter/VIPERPresenter.h +18 -0
  35. data/lib/templates/testable/objc/Presenter/VIPERPresenter.m +11 -0
  36. data/lib/templates/testable/objc/Presenter/VIPERPresenterSpec.m +31 -0
  37. data/lib/templates/testable/objc/Protocols/VIPERProtocols.h +64 -0
  38. data/lib/templates/testable/objc/ViewController/VIPERViewController.h +13 -0
  39. data/lib/templates/testable/objc/ViewController/VIPERViewController.m +32 -0
  40. data/lib/templates/testable/objc/ViewController/VIPERViewControllerSpec.m +31 -0
  41. data/lib/templates/testable/objc/WireFrame/VIPERWireFrame.h +19 -0
  42. data/lib/templates/testable/objc/WireFrame/VIPERWireFrame.m +31 -0
  43. data/lib/templates/testable/swift/DataManager/API/VIPERAPIDataManager.swift +11 -0
  44. data/lib/templates/testable/swift/DataManager/Local/VIPERLocalDataManager.swift +11 -0
  45. data/lib/templates/testable/swift/Interactor/VIPERInteractor.swift +15 -0
  46. data/lib/templates/testable/swift/Interactor/VIPERInteractorSpec.swift +22 -0
  47. data/lib/templates/testable/swift/Interactor/VIPERItem.swift +13 -0
  48. data/lib/templates/testable/swift/Presenter/VIPERPresenter.swift +15 -0
  49. data/lib/templates/testable/swift/Presenter/VIPERPresenterSpec.swift +22 -0
  50. data/lib/templates/testable/swift/Protocols/VIPERProtocols.swift +70 -0
  51. data/lib/templates/testable/swift/View/VIPERView.swift +12 -0
  52. data/lib/templates/testable/swift/View/VIPERViewSpec.swift +22 -0
  53. data/lib/templates/testable/swift/WireFrame/VIPERWireFrame.swift +29 -0
  54. data/lib/templates/testable/viperspec.yml +4 -0
  55. data/lib/vipergen.rb +6 -0
  56. data/lib/vipergen/dirutils.rb +17 -0
  57. data/lib/vipergen/filemanager.rb +51 -0
  58. data/lib/vipergen/generator.rb +66 -0
  59. data/lib/vipergen/templatemanager.rb +53 -0
  60. data/lib/vipergen/version.rb +4 -0
  61. data/lib/vipergen/viperthor.rb +21 -0
  62. data/spec/spec_helper.rb +4 -0
  63. data/spec/vipergen/vipergen_spec.rb +133 -0
  64. metadata +181 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e64ed19a8d5508076cce87ce78ac628fbdda2f7f
4
+ data.tar.gz: 80aa5143d6e0df2e2197935d576fff2bc67aebca
5
+ SHA512:
6
+ metadata.gz: 30d7345252f907e58f3e77066fcfbf632506a92c1c438c704790e14cc2f96954565ded8e958a679e64ee2aef28bba6d277617c27c5abf301124b06a8780a3b9f
7
+ data.tar.gz: 4a6f768f6493c681225e89c8e7b3d7b55c13892310fe68d96f50ed66d1f4206e3673a529e00b20aa783b3e220189980f7d07a648335441cebaac1ab5908f3b46
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Redbooth
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/README.md ADDED
@@ -0,0 +1,134 @@
1
+ Viper Module Generator
2
+ ======================
3
+ [![Code Climate](https://codeclimate.com/github/teambox/viper-module-generator/badges/gpa.svg)](https://codeclimate.com/github/teambox/viper-module-generator)
4
+ [![Build Status](https://travis-ci.org/teambox/viper-module-generator.svg?branch=master)](https://travis-ci.org/teambox/viper-module-generator)
5
+ [![Test Coverage](https://codeclimate.com/github/teambox/viper-module-generator/badges/coverage.svg)](https://codeclimate.com/github/teambox/viper-module-generator)
6
+ [![Dependency Status](https://gemnasium.com/teambox/viper-module-generator.svg)](https://gemnasium.com/teambox/viper-module-generator)
7
+
8
+
9
+ ![image](http://www.objc.io/images/issue-13/2014-06-07-viper-intro.jpg)
10
+
11
+ Gem to generate VIPER modules to use them in your Objective-C/Swift projects
12
+ The implementation scheme returned by this generator is hardly inspired in the example and post of Objc.io, http://www.objc.io/issue-13/viper.html .
13
+
14
+ - [Features](#features)
15
+ - [Changelog](#changelog-0.1)
16
+ - [Expected in version 0.2](#expected-in-version-0.2)
17
+ - [Viper files structure](#viper-files-structure)
18
+ - [How to install vipergen](#how-to-install-vipergen)
19
+ - [How to generate a VIPER module with a given name?](#how-to-generate-viper-module-with-a-given-name?)
20
+ - [Developer tips](#developer-tips)
21
+ - [Update the gem](#update-the-gem)
22
+ - [Add a new template](#add-a-new-template)
23
+ - [Resources](#resources)
24
+
25
+ ## Features
26
+ - Generates the module in Swift and Objective-C
27
+ - Ready to be installed as a gem https://rubygems.org/gems/VIPERGen
28
+
29
+ ### Changelog 0.1.6
30
+ - Added `templates` command to know which templates are available
31
+ - YAML file in each template with the information about the template (more scalable)
32
+
33
+ ### Changelog 0.1
34
+ - Added default template
35
+ - Fully components tested
36
+
37
+ ### Changelog 0.2.3
38
+ - VIPER Example using the Twitter API
39
+ - Default template implemented in Swift
40
+ -
41
+
42
+ ### Expected in version 0.3
43
+ - Integrate with XCode as a plugin (http://nshipster.com/xcode-plugins/)
44
+
45
+ ## Viper files structure
46
+ ```bash
47
+ .objc
48
+ +-- DataManager
49
+ | +-- VIPERDataManager.h
50
+ | +-- VIPERDataManager.m
51
+ +-- Interactor
52
+ | +-- VIPERInteractor.h
53
+ | +-- VIPERInteractor.m
54
+ +-- Presenter
55
+ | +-- VIPERPresenter.h
56
+ | +-- VIPERPresenter.m
57
+ +-- ViewController
58
+ | +-- VIPERViewController.h
59
+ | +-- VIPERViewController.m
60
+ +-- WireFrame
61
+ | +-- VIPERWireFrame.h
62
+ | +-- VIPERWireFrame.m
63
+ +-- Protocols
64
+ | +-- VIPERProtocols.h
65
+ .swift
66
+ +-- DataManager
67
+ | +-- VIPERDataManager.swift
68
+ +-- Interactor
69
+ | +-- VIPERInteractor.swift
70
+ +-- Presenter
71
+ | +-- VIPERPresenter.swift
72
+ +-- ViewController
73
+ | +-- VIPERViewController.swift
74
+ +-- WireFrame
75
+ | +-- VIPERWireFrame.swift
76
+ +-- Protocols
77
+ | +-- VIPERProtocols.swift
78
+ ```
79
+ ## How to install vipergen ?
80
+ You can install it easily as using the gem. With ruby installed in your OSX execute:
81
+ ```bash
82
+ sudo gem install vipergen
83
+ ```
84
+ If everything were right, you should have now the vipergem command available in your system console
85
+
86
+ ## How to generate a VIPER module with a given name?
87
+ You have just to execute the following command
88
+ ```bash
89
+ vipergen generate MyFirstViperModule --path=~/myproject/shared
90
+ ```
91
+ And then the files structure will be automatically created. Don't forget to add this folder to your project dragging it into the XCode/Appcode inspector
92
+
93
+ ## How can I try the demo project?
94
+
95
+ 1. Clone the repo `git clone https://github.com/pepibumur/viper-module-generator.git`
96
+ 2. Move into the repo folder and update the git submodules `git sumodule update --init`
97
+ 3. In the folder VIPERGenDemo install the pods `pod install`
98
+ 4. Open the project from the `VIPERGenDemo.xcworkspace` file
99
+ 5. Enjoy it!
100
+
101
+
102
+ ## Developer tips
103
+ ### Update the gem
104
+ When the gem is updated it has to be reported to the gem repository. I followed this tutorial http://amaras-tech.co.uk/article/43/Creating_executable_gems that basically says that once you have your gem ready execute:
105
+ ```bash
106
+ gem build vipergen.gemspec
107
+ gem install vipergen-0.1.gem
108
+ gem push vipergen-0.1.gem
109
+ ```
110
+ Then you'll be asked for your credentials in order to make the update in the repo (http://guides.rubygems.org/publishing/)
111
+
112
+ ### Add a new template
113
+ Are you interested in VIPER and you would like to contribute with this gem adding new templates? Feel free to do it. It's pretty easy. You've just to:
114
+ - Create a folder inside `templates` with the name of your template
115
+ - You'll have to create inside the templates in both languages, Swift and Objective-C (get inspired from existing templates)
116
+ - Use the word VIPER where you want the name to be replaced in.
117
+ - Remember to add the file viperspec.yml with the description of your template as below:
118
+ ```yaml
119
+ author: pepi
120
+ author_email: pepibumur@gmail.com
121
+ template_description: Default template with the simplest structure using VIPER
122
+ updated_at: 2014-08-24
123
+ ```
124
+ - Report it as a PR in this repo updating the gem version in Gemspec.
125
+
126
+ ## Resources
127
+ - Rspec documentation: http://rubydoc.info/gems/rspec-expectations/frames
128
+ - XCode Plugins: http://nshipster.com/xcode-plugins/
129
+ - XCodeProj gem (to modify project groups structure): https://github.com/CocoaPods/Xcodeproj
130
+ - Thor, powerful Ruby library for command line: http://whatisthor.com/
131
+ - Cocoa Design Patters: https://developer.apple.com/legacy/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html
132
+
133
+ ## Contact
134
+ If you have any doubt about the gem or even if you want to make any suggestion you can do it directly to my email address, pedro@redbooth.com . You can use the issues Github page too
data/bin/vipergen ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #require 'rubygems'
4
+ require 'vipergen/viperthor'
5
+
6
+ puts "------- VIPER GENERATOR---------\n"
7
+ puts ARGV
8
+ Vipergen::ViperThor.start(ARGV)
9
+ puts "--------------------------------\n"
@@ -0,0 +1,12 @@
1
+ //
2
+ // Created by AUTHOR.
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import "VIPERProtocols.h"
8
+
9
+
10
+ @interface VIPERAPIDataManager : NSObject <VIPERAPIDataManagerInputProtocol>
11
+
12
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import "VIPERAPIDataManager.h"
7
+
8
+ @implementation VIPERAPIDataManager
9
+
10
+ @end
@@ -0,0 +1,12 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import "VIPERProtocols.h"
8
+
9
+
10
+ @interface VIPERLocalDataManager : NSObject <VIPERLocalDataManagerInputProtocol>
11
+
12
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import "VIPERLocalDataManager.h"
7
+
8
+ @implementation VIPERLocalDataManager
9
+
10
+ @end
@@ -0,0 +1,16 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import "VIPERProtocols.h"
8
+
9
+
10
+ @interface VIPERInteractor : NSObject <VIPERInteractorInputProtocol>
11
+
12
+ @property (nonatomic, weak) id <VIPERInteractorOutputProtocol> presenter;
13
+ @property (nonatomic, strong) id <VIPERAPIDataManagerInputProtocol> APIDataManager;
14
+ @property (nonatomic, strong) id <VIPERLocalDataManagerInputProtocol> localDataManager;
15
+
16
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import "VIPERInteractor.h"
7
+
8
+ @implementation VIPERInteractor
9
+
10
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+
8
+ @interface VIPERItem : NSObject
9
+
10
+ @end
@@ -0,0 +1,10 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import "VIPERItem.h"
7
+
8
+ @implementation VIPERItem
9
+
10
+ @end
@@ -0,0 +1,17 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import "VIPERProtocols.h"
8
+
9
+ @class VIPERWireFrame;
10
+
11
+ @interface VIPERPresenter : NSObject <VIPERPresenterProtocol, VIPERInteractorOutputProtocol>
12
+
13
+ @property (nonatomic, weak) id <VIPERViewProtocol> view;
14
+ @property (nonatomic, strong) id <VIPERInteractorInputProtocol> interactor;
15
+ @property (nonatomic, strong) id <VIPERWireFrameProtocol> wireFrame;
16
+
17
+ @end
@@ -0,0 +1,11 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import "VIPERPresenter.h"
7
+ #import "VIPERWireframe.h"
8
+
9
+ @implementation VIPERPresenter
10
+
11
+ @end
@@ -0,0 +1,80 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import <UIKit/UIKit.h>
8
+
9
+ @protocol VIPERInteractorOutputProtocol;
10
+ @protocol VIPERInteractorInputProtocol;
11
+ @protocol VIPERViewProtocol;
12
+ @protocol VIPERPresenterProtocol;
13
+ @protocol VIPERLocalDataManagerInputProtocol;
14
+ @protocol VIPERAPIDataManagerInputProtocol;
15
+
16
+
17
+ @class VIPERWireFrame;
18
+
19
+ @protocol VIPERViewProtocol
20
+ @required
21
+ @property (nonatomic, strong) id <VIPERPresenterProtocol> presenter;
22
+ /**
23
+ * Add here your methods for communication PRESENTER -> VIEWCONTROLLER
24
+ */
25
+ @end
26
+
27
+ @protocol VIPERWireFrameProtocol
28
+ @required
29
+ + (void)presentVIPERModuleFrom:(id)fromView;
30
+ /**
31
+ * Add here your methods for communication PRESENTER -> WIREFRAME
32
+ */
33
+ @end
34
+
35
+ @protocol VIPERPresenterProtocol
36
+ @required
37
+ @property (nonatomic, weak) id <VIPERViewProtocol> view;
38
+ @property (nonatomic, strong) id <VIPERInteractorInputProtocol> interactor;
39
+ @property (nonatomic, strong) id <VIPERWireFrameProtocol> wireFrame;
40
+ /**
41
+ * Add here your methods for communication VIEWCONTROLLER -> PRESENTER
42
+ */
43
+ @end
44
+
45
+ @protocol VIPERInteractorOutputProtocol
46
+ /**
47
+ * Add here your methods for communication INTERACTOR -> PRESENTER
48
+ */
49
+ @end
50
+
51
+ @protocol VIPERInteractorInputProtocol
52
+ @required
53
+ @property (nonatomic, weak) id <VIPERInteractorOutputProtocol> presenter;
54
+ @property (nonatomic, strong) id <VIPERAPIDataManagerInputProtocol> APIDataManager;
55
+ @property (nonatomic, strong) id <VIPERLocalDataManagerInputProtocol> localDataManager;
56
+ /**
57
+ * Add here your methods for communication PRESENTER -> INTERACTOR
58
+ */
59
+ @end
60
+
61
+
62
+ @protocol VIPERDataManagerInputProtocol
63
+ /**
64
+ * Add here your methods for communication INTERACTOR -> DATAMANAGER
65
+ */
66
+ @end
67
+
68
+ @protocol VIPERAPIDataManagerInputProtocol <VIPERDataManagerInputProtocol>
69
+ /**
70
+ * Add here your methods for communication INTERACTOR -> APIDATAMANAGER
71
+ */
72
+ @end
73
+
74
+ @protocol VIPERLocalDataManagerInputProtocol <VIPERDataManagerInputProtocol>
75
+ /**
76
+ * Add here your methods for communication INTERACTOR -> LOCLDATAMANAGER
77
+ */
78
+ @end
79
+
80
+
@@ -0,0 +1,13 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import <UIKit/UIKit.h>
7
+ #import "VIPERProtocols.h"
8
+
9
+ @interface VIPERView : UIViewController <VIPERViewProtocol>
10
+
11
+ @property (nonatomic, strong) id <VIPERPresenterProtocol> presenter;
12
+
13
+ @end
@@ -0,0 +1,32 @@
1
+ //
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
+ //
5
+
6
+ #import "VIPERView.h"
7
+
8
+ @implementation VIPERView
9
+
10
+ #pragma mark - ViewController Lifecycle
11
+
12
+ - (void)viewDidLoad
13
+ {
14
+ [super viewDidLoad];
15
+ }
16
+
17
+ - (void)viewDidDisappear:(BOOL)animated
18
+ {
19
+ [super viewDidDisappear:animated];
20
+ }
21
+
22
+ - (void)viewWillAppear:(BOOL)animated
23
+ {
24
+ [super viewWillAppear:animated];
25
+ }
26
+
27
+ - (void)viewWillDisappear:(BOOL)animated
28
+ {
29
+ [super viewWillDisappear:animated];
30
+ }
31
+
32
+ @end