molt 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a428c468b097e83028f010ce513957de5647c3d0
4
- data.tar.gz: 4171a151cbebeffc9f34b74846ad15385a37184a
3
+ metadata.gz: edf7d6d814c587a5e3f82421e79d35c500225d7e
4
+ data.tar.gz: 44f63fccebce865328ca4419bcb4168a4b025709
5
5
  SHA512:
6
- metadata.gz: 38e06bef87ff4584dcd8b29ce7536c04f9e259ce96e559f246ba6d4635875476615eb311ef0b43a6ee4de557852dd0955c3f5b4cb489068548f033cadcb631d3
7
- data.tar.gz: 718b4af00d6590a7efac07616ce09fcde62d617a938625ab211926ac8e22ed3138b3ec0ec8ed04cb4688a8b2336f0ce5772dfd65eddd05a130bcb8a49f5f798c
6
+ metadata.gz: 7c0e15fedccc8ef6d6f23640dd0e2fcc14c10a3d57d28bd463821c143f974cb35f83de7c63d9572a1b7c590260ec17f4f059edf00e3b5e9cad9ad7cfc0779934
7
+ data.tar.gz: 91dc7c49226a93a91f4fe5340e50d77f3e9fa9415ad7c42b983eaf378e2f138940bceae9b65aa46e1ff95a46f9c107123202863f1d2477200480c0e6131adb3a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- molt (0.1.4)
4
+ molt (0.2.0)
5
5
  commander
6
6
  liquid (~> 4.0.0)
7
7
  terminal-table
data/README.md CHANGED
@@ -5,40 +5,55 @@ Molt is a simple VIPER module generator for Swift apps.
5
5
 
6
6
  [![Gem Version](https://badge.fury.io/rb/molt.svg)](https://badge.fury.io/rb/molt) [![Build Status](https://travis-ci.org/MarcoCabazal/Molt.svg?branch=development)](https://travis-ci.org/MarcoCabazal/Molt) [![CircleCI](https://circleci.com/gh/MarcoCabazal/Molt.svg?style=svg)](https://circleci.com/gh/MarcoCabazal/Molt)
7
7
 
8
- ## Installation
8
+ ### Table of Contents
9
+ 1. [Installation](#installation)
10
+ 2. [Global Configuration](#global-configuration)
11
+ 3. [Per-Project Configuration](#per-project-configuration)
12
+ 4. [Template Sets](#template-sets)
13
+ 5. [Creating (generating) a module](#creation)
14
+ 6. [Additional options/overrides when generating modules](#options)
15
+ 7. [Exporting template sets as Xcode templates](#xcode)
16
+ 8. [Notes about the bundled `VIPER_TableView` template set](#notes)
17
+ 9. [TODOs](#todos)
18
+ 10. [Contributing](#contributing)
19
+ 11. [License](#license)
20
+ 12. [Code of Conduct](#coc)
21
+
22
+
23
+ ## Installation <a name="installation"></a>
9
24
 
10
25
  $ gem install molt
11
26
 
12
- ### Global Configuration
27
+ ## Global Configuration <a name="global-configuration"></a>
13
28
 
14
29
  To initialize global configuration in `~/.molt`:
15
30
 
16
31
  $ molt setup
17
- create /Users/TomHagen/.molt
18
- create /Users/TomHagen/.molt/models/Entity+CoreData.swift.liquid
19
- create /Users/TomHagen/.molt/models/Entity.swift.liquid
20
- create /Users/TomHagen/.molt/models/Model.swift.liquid
21
- create /Users/TomHagen/.molt/partials/_header.liquid
22
- create /Users/TomHagen/.molt/swift_helpers/ErrorTypes/APIError.swift
23
- create /Users/TomHagen/.molt/swift_helpers/ErrorTypes/ErrorTypes.swift
24
- create /Users/TomHagen/.molt/swift_helpers/ErrorTypes/PersistenceError.swift
25
- create /Users/TomHagen/.molt/swift_helpers/ISODateTransform.swift
26
- create /Users/TomHagen/.molt/swift_helpers/Identifiable.swift
27
- create /Users/TomHagen/.molt/swift_helpers/Loadable.swift
28
- create /Users/TomHagen/.molt/swift_helpers/Networking/APIRouter.swift
29
- create /Users/TomHagen/.molt/swift_helpers/StoryboardExtensions.swift
30
- create /Users/TomHagen/.molt/template_sets/viper_detail/Presenter.swift.liquid
31
- create /Users/TomHagen/.molt/template_sets/viper_detail/Protocols.swift.liquid
32
- create /Users/TomHagen/.molt/template_sets/viper_detail/View.swift.liquid
33
- create /Users/TomHagen/.molt/template_sets/viper_detail/WireFrame.swift.liquid
34
- create /Users/TomHagen/.molt/template_sets/viper_table/DataManagers/LocalDataManager.swift.liquid
35
- create /Users/TomHagen/.molt/template_sets/viper_table/DataManagers/RemoteDataManager.swift.liquid
36
- create /Users/TomHagen/.molt/template_sets/viper_table/Interactor.swift.liquid
37
- create /Users/TomHagen/.molt/template_sets/viper_table/Presenter.swift.liquid
38
- create /Users/TomHagen/.molt/template_sets/viper_table/Protocols.swift.liquid
39
- create /Users/TomHagen/.molt/template_sets/viper_table/View.swift.liquid
40
- create /Users/TomHagen/.molt/template_sets/viper_table/WireFrame.swift.liquid
41
- create /Users/TomHagen/.molt/config.yml
32
+ create ~/.molt
33
+ create ~/.molt/models/Entity+CoreData.swift.liquid
34
+ create ~/.molt/models/Entity.swift.liquid
35
+ create ~/.molt/models/Model.swift.liquid
36
+ create ~/.molt/partials/_header.liquid
37
+ create ~/.molt/swift_helpers/ErrorTypes/APIError.swift
38
+ create ~/.molt/swift_helpers/ErrorTypes/ErrorTypes.swift
39
+ create ~/.molt/swift_helpers/ErrorTypes/PersistenceError.swift
40
+ create ~/.molt/swift_helpers/ISODateTransform.swift
41
+ create ~/.molt/swift_helpers/Identifiable.swift
42
+ create ~/.molt/swift_helpers/Loadable.swift
43
+ create ~/.molt/swift_helpers/Networking/APIRouter.swift
44
+ create ~/.molt/swift_helpers/StoryboardExtensions.swift
45
+ create ~/.molt/template_sets/VIPER_Detail/Presenter.swift.liquid
46
+ create ~/.molt/template_sets/VIPER_Detail/Protocols.swift.liquid
47
+ create ~/.molt/template_sets/VIPER_Detail/View.swift.liquid
48
+ create ~/.molt/template_sets/VIPER_Detail/Wireframe.swift.liquid
49
+ create ~/.molt/template_sets/VIPER_TableView/DataManagers/LocalDataManager.swift.liquid
50
+ create ~/.molt/template_sets/VIPER_TableView/DataManagers/RemoteDataManager.swift.liquid
51
+ create ~/.molt/template_sets/VIPER_TableView/Interactor.swift.liquid
52
+ create ~/.molt/template_sets/VIPER_TableView/Presenter.swift.liquid
53
+ create ~/.molt/template_sets/VIPER_TableView/Protocols.swift.liquid
54
+ create ~/.molt/template_sets/VIPER_TableView/View.swift.liquid
55
+ create ~/.molt/template_sets/VIPER_TableView/Wireframe.swift.liquid
56
+ create ~/.molt/config.yml
42
57
 
43
58
  This will create the folder `~/.molt`, copy bundled template sets and helper Swift extensions onto it.
44
59
 
@@ -54,7 +69,7 @@ You should customize this with your information before you proceed with generati
54
69
  project:
55
70
  name: CapoRegime
56
71
 
57
- ### Per-Project Configuration
72
+ ## Per-Project Configuration <a name="per-project-configuration"></a>
58
73
 
59
74
  On the other hand, to setup per-project configuration, go to your project's root folder, then:
60
75
 
@@ -72,23 +87,23 @@ On the other hand, to setup per-project configuration, go to your project's root
72
87
  create .molt/swift_helpers/Loadable.swift
73
88
  create .molt/swift_helpers/Networking/APIRouter.swift
74
89
  create .molt/swift_helpers/StoryboardExtensions.swift
75
- create .molt/template_sets/viper_detail/Presenter.swift.liquid
76
- create .molt/template_sets/viper_detail/Protocols.swift.liquid
77
- create .molt/template_sets/viper_detail/View.swift.liquid
78
- create .molt/template_sets/viper_detail/WireFrame.swift.liquid
79
- create .molt/template_sets/viper_table/DataManagers/LocalDataManager.swift.liquid
80
- create .molt/template_sets/viper_table/DataManagers/RemoteDataManager.swift.liquid
81
- create .molt/template_sets/viper_table/Interactor.swift.liquid
82
- create .molt/template_sets/viper_table/Presenter.swift.liquid
83
- create .molt/template_sets/viper_table/Protocols.swift.liquid
84
- create .molt/template_sets/viper_table/View.swift.liquid
85
- create .molt/template_sets/viper_table/WireFrame.swift.liquid
90
+ create .molt/template_sets/VIPER_Detail/Presenter.swift.liquid
91
+ create .molt/template_sets/VIPER_Detail/Protocols.swift.liquid
92
+ create .molt/template_sets/VIPER_Detail/View.swift.liquid
93
+ create .molt/template_sets/VIPER_Detail/Wireframe.swift.liquid
94
+ create .molt/template_sets/VIPER_TableView/DataManagers/LocalDataManager.swift.liquid
95
+ create .molt/template_sets/VIPER_TableView/DataManagers/RemoteDataManager.swift.liquid
96
+ create .molt/template_sets/VIPER_TableView/Interactor.swift.liquid
97
+ create .molt/template_sets/VIPER_TableView/Presenter.swift.liquid
98
+ create .molt/template_sets/VIPER_TableView/Protocols.swift.liquid
99
+ create .molt/template_sets/VIPER_TableView/View.swift.liquid
100
+ create .molt/template_sets/VIPER_TableView/Wireframe.swift.liquid
86
101
  create .molt/config.yml
87
102
 
88
103
 
89
- ### Template Sets
104
+ ## Template Sets <a name="template-sets"></a>
90
105
 
91
- Template sets are groups of [Liquid](https://shopify.github.io/liquid/) template files which make up a VIPER module. This gem comes with two sample sets that can be used to generate a module for use with a `UITableView` (`viper_table`) and a detail screen (`viper_detail`). These should serve as good starting points for your own customizations. Just duplicate the respective folders under `~/.molt/template_sets`, then customize to suit your taste.
106
+ Template sets are groups of [Liquid](https://shopify.github.io/liquid/) template files which make up a VIPER module. This gem comes with two sample sets that can be used to generate a module for use with a `UITableView` (`VIPER_TableView`) and a detail screen (`VIPER_Detail`). These should serve as good starting points for your own customizations. Just duplicate the respective folders under `~/.molt/template_sets`, then customize to suit your taste.
92
107
 
93
108
  The template system makes use of `Liquid` and supports partials which are located in `.molt/partials`.
94
109
 
@@ -96,12 +111,12 @@ To list available template sets (search order: current project directory, global
96
111
 
97
112
  $ molt template_sets
98
113
  ./.molt:
99
- ./.molt/template_sets/viper_table
114
+ ./.molt/template_sets/VIPER_TableView
100
115
  ./.molt/template_sets/some_project_specific_template
101
116
 
102
- /Users/TomHagen/.molt:
103
- /Users/TomHagen/.molt/template_sets/viper_table
104
- /Users/TomHagen/.molt/template_sets/viper_detail
117
+ ~/.molt:
118
+ ~/.molt/template_sets/VIPER_TableView
119
+ ~/.molt/template_sets/VIPER_Detail
105
120
 
106
121
  Add --verbose to list all files in each template set
107
122
 
@@ -113,35 +128,35 @@ To list available template sets and the template files they contain:
113
128
  ./.molt/models/Entity+CoreData.swift.liquid
114
129
  ./.molt/models/Model.swift.liquid
115
130
  ./.molt/models/Entity.swift.liquid
116
- ./.molt/template_sets/viper_table/Protocols.swift.liquid
117
- ./.molt/template_sets/viper_table/Presenter.swift.liquid
118
- ./.molt/template_sets/viper_table/DataManagers/RemoteDataManager.swift.liquid
119
- ./.molt/template_sets/viper_table/DataManagers/LocalDataManager.swift.liquid
120
- ./.molt/template_sets/viper_table/View.swift.liquid
121
- ./.molt/template_sets/viper_table/WireFrame.swift.liquid
122
- ./.molt/template_sets/viper_table/Interactor.swift.liquid
131
+ ./.molt/template_sets/VIPER_TableView/Protocols.swift.liquid
132
+ ./.molt/template_sets/VIPER_TableView/Presenter.swift.liquid
133
+ ./.molt/template_sets/VIPER_TableView/DataManagers/RemoteDataManager.swift.liquid
134
+ ./.molt/template_sets/VIPER_TableView/DataManagers/LocalDataManager.swift.liquid
135
+ ./.molt/template_sets/VIPER_TableView/View.swift.liquid
136
+ ./.molt/template_sets/VIPER_TableView/Wireframe.swift.liquid
137
+ ./.molt/template_sets/VIPER_TableView/Interactor.swift.liquid
123
138
  ./.molt/template_sets/some_project_specific_template/Protocols.swift.liquid
124
139
  ./.molt/template_sets/some_project_specific_template/Presenter.swift.liquid
125
140
  ./.molt/template_sets/some_project_specific_template/View.swift.liquid
126
- ./.molt/template_sets/some_project_specific_template/WireFrame.swift.liquid
127
-
128
- /Users/TomHagen/.molt:
129
- /Users/TomHagen/.molt/models/Entity+CoreData.swift.liquid
130
- /Users/TomHagen/.molt/models/Model.swift.liquid
131
- /Users/TomHagen/.molt/models/Entity.swift.liquid
132
- /Users/TomHagen/.molt/template_sets/viper_table/Protocols.swift.liquid
133
- /Users/TomHagen/.molt/template_sets/viper_table/Presenter.swift.liquid
134
- /Users/TomHagen/.molt/template_sets/viper_table/DataManagers/RemoteDataManager.swift.liquid
135
- /Users/TomHagen/.molt/template_sets/viper_table/DataManagers/LocalDataManager.swift.liquid
136
- /Users/TomHagen/.molt/template_sets/viper_table/View.swift.liquid
137
- /Users/TomHagen/.molt/template_sets/viper_table/WireFrame.swift.liquid
138
- /Users/TomHagen/.molt/template_sets/viper_table/Interactor.swift.liquid
139
- /Users/TomHagen/.molt/template_sets/viper_detail/Protocols.swift.liquid
140
- /Users/TomHagen/.molt/template_sets/viper_detail/Presenter.swift.liquid
141
- /Users/TomHagen/.molt/template_sets/viper_detail/View.swift.liquid
142
- /Users/TomHagen/.molt/template_sets/viper_detail/WireFrame.swift.liquid
143
-
144
- ### Creating (generating) a module
141
+ ./.molt/template_sets/some_project_specific_template/Wireframe.swift.liquid
142
+
143
+ ~/.molt:
144
+ ~/.molt/models/Entity+CoreData.swift.liquid
145
+ ~/.molt/models/Model.swift.liquid
146
+ ~/.molt/models/Entity.swift.liquid
147
+ ~/.molt/template_sets/VIPER_TableView/Protocols.swift.liquid
148
+ ~/.molt/template_sets/VIPER_TableView/Presenter.swift.liquid
149
+ ~/.molt/template_sets/VIPER_TableView/DataManagers/RemoteDataManager.swift.liquid
150
+ ~/.molt/template_sets/VIPER_TableView/DataManagers/LocalDataManager.swift.liquid
151
+ ~/.molt/template_sets/VIPER_TableView/View.swift.liquid
152
+ ~/.molt/template_sets/VIPER_TableView/Wireframe.swift.liquid
153
+ ~/.molt/template_sets/VIPER_TableView/Interactor.swift.liquid
154
+ ~/.molt/template_sets/VIPER_Detail/Protocols.swift.liquid
155
+ ~/.molt/template_sets/VIPER_Detail/Presenter.swift.liquid
156
+ ~/.molt/template_sets/VIPER_Detail/View.swift.liquid
157
+ ~/.molt/template_sets/VIPER_Detail/Wireframe.swift.liquid
158
+
159
+ ## Creating (generating) a module <a name="creation"></a>
145
160
 
146
161
  $ molt create_module Friends viper_table
147
162
  +---------------------------------------------------------+-------------------------------------------------------+
@@ -158,7 +173,7 @@ To list available template sets and the template files they contain:
158
173
  | viper_table/DataManagers/RemoteDataManager.swift.liquid | ./Friends/DataManagers/FriendsRemoteDataManager.swift |
159
174
  | viper_table/DataManagers/LocalDataManager.swift.liquid | ./Friends/DataManagers/FriendsLocalDataManager.swift |
160
175
  | viper_table/View.swift.liquid | ./Friends/FriendsView.swift |
161
- | viper_table/WireFrame.swift.liquid | ./Friends/FriendsWireFrame.swift |
176
+ | viper_table/Wireframe.swift.liquid | ./Friends/FriendsWireframe.swift |
162
177
  | viper_table/Interactor.swift.liquid | ./Friends/FriendsInteractor.swift |
163
178
  +---------------------------------------------------------+-------------------------------------------------------+
164
179
 
@@ -166,7 +181,7 @@ To list available template sets and the template files they contain:
166
181
 
167
182
  Note that generating a new module will never touch your Xcode project, but it's just a matter of dragging the resulting folder onto Xcode.
168
183
 
169
- ### Additional options/overrides when generating modules
184
+ ## Additional options/overrides when generating modules <a name="options"></a>
170
185
 
171
186
  $ molt help create_module
172
187
  Usage:
@@ -182,7 +197,25 @@ Note that generating a new module will never touch your Xcode project, but it's
182
197
  -create-model # If specified, it creates corresponding Mappable struct (ObjectMapper) and Core Data entity; requires --model to be set
183
198
  -do-it # Release the Kraken and write the files
184
199
 
185
- ### Notes about the bundled `viper_table` template set
200
+ ## Exporting template sets as Xcode templates <a name="xcode"></a>
201
+
202
+ $ molt xcode viper_table
203
+ +---------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
204
+ | Template Set | viper_table |
205
+ | | |
206
+ | Source | Destination |
207
+ | viper_table/Protocols.swift.liquid | ~/Library/Developer/Xcode/Templates/File Templates/Molt/viper_table.xctemplate/___FILEBASENAME___Protocols.swift |
208
+ | viper_table/Presenter.swift.liquid | ~/Library/Developer/Xcode/Templates/File Templates/Molt/viper_table.xctemplate/___FILEBASENAME___Presenter.swift |
209
+ | viper_table/DataManagers/RemoteDataManager.swift.liquid | ~/Library/Developer/Xcode/Templates/File Templates/Molt/viper_table.xctemplate/___FILEBASENAME___RemoteDataManager.swift |
210
+ | viper_table/DataManagers/LocalDataManager.swift.liquid | ~/Library/Developer/Xcode/Templates/File Templates/Molt/viper_table.xctemplate/___FILEBASENAME___LocalDataManager.swift |
211
+ | viper_table/View.swift.liquid | ~/Library/Developer/Xcode/Templates/File Templates/Molt/viper_table.xctemplate/___FILEBASENAME___View.swift |
212
+ | viper_table/Wireframe.swift.liquid | ~/Library/Developer/Xcode/Templates/File Templates/Molt/viper_table.xctemplate/___FILEBASENAME___Wireframe.swift |
213
+ | viper_table/Interactor.swift.liquid | ~/Library/Developer/Xcode/Templates/File Templates/Molt/viper_table.xctemplate/___FILEBASENAME___Interactor.swift |
214
+ +---------------------------------------------------------+------------------------------------------------------------------------===-----------------------------------------------+
215
+
216
+ This command basically exports a template set and makes it available as an Xcode template, which makes your often-used template instantly available from within Xcode itself. When you do create a new file from within Xcode, you will be prompted for the module name and the model. Other meta details normally available in `create_module` won't be necessary during the export.
217
+
218
+ ## Notes about the bundled `viper_table` template set <a name="notes"></a>
186
219
 
187
220
  1. The `RemoteDataManager` makes use of `Alamofire` and `ObjectMapper`
188
221
  2. The `LocalDataManager` makes use of `Core Data`
@@ -192,19 +225,19 @@ Note that generating a new module will never touch your Xcode project, but it's
192
225
 
193
226
  To appreciate, please see the sample rendered source code for [Friends](https://github.com/MarcoCabazal/Molt/tree/development/sample_output).
194
227
 
195
- ### TODOs
228
+ ### TODOs <a name="todos"></a>
196
229
 
197
230
  1. Demo a working app done created using generators
198
231
  1. Write more comprehensive tests
199
232
 
200
- ### Contributing
233
+ ### Contributing <a name="contributing"></a>
201
234
 
202
235
  Bug reports and pull requests are welcome on GitHub at https://github.com/MarcoCabazal/molt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
203
236
 
204
- ### License
237
+ ### License <a name="license"></a>
205
238
 
206
239
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
207
240
 
208
- ### Code of Conduct
241
+ ### Code of Conduct <a name="coc"></a>
209
242
 
210
243
  Everyone interacting in the Molt project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/darthmarku/molt/blob/master/CODE_OF_CONDUCT.md).
@@ -1,4 +1,5 @@
1
1
  // {{ project.name }}
2
+ // {{ module_name }}{{ filename_suffix }}
2
3
  //
3
4
  // Created by {{ developer.name }} on {{ date }}.
4
5
  // Copyright © {{ year }} {{ developer.company }}. All rights reserved.
@@ -1,6 +1,5 @@
1
- //
2
- // {{ module_name }}LocalDataManager.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "LocalDataManager.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  import CoreData
5
4
  import Hydra
6
5
 
@@ -1,6 +1,5 @@
1
- //
2
- // {{ module_name }}RemoteDataManager.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "RemoteDataManager.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___ {% endif %}
2
+
4
3
  import Alamofire
5
4
  import AlamofireObjectMapper
6
5
  import Hydra
@@ -10,10 +9,9 @@ class {{ module_name }}RemoteDataManager: {{ module_name }}RemoteDataManagerProt
10
9
 
11
10
  func retrieveDataFromAPI() -> Promise<[{{ model }}]> {
12
11
  return Promise<[{{ model }}]>(in: .background) { resolve, reject, _ in
13
- Alamofire.request(APIRouter.{{ model | downcase }})
12
+ Alamofire.request(APIRouter.<# Enum Key #>)
14
13
  .validate()
15
- .responseArray(keyPath: "{{ model | downcase }}") { (response: DataResponse<[{{ model }}]>) in
16
-
14
+ .responseArray(keyPath: "<# JSON KeyPath #>") { (response: DataResponse<[{{ model }}]>) in
17
15
  switch response.result {
18
16
  case .success(let data):
19
17
  resolve(data)
@@ -1,6 +1,5 @@
1
- //
2
- // {{ module_name }}Interactor.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "Interactor.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  final class {{ module_name }}Interactor {
5
4
  weak var presenter: {{ module_name }}InteractorOutputProtocol?
6
5
  var localDataManager: {{ module_name }}LocalDataManagerProtocol?
@@ -1,10 +1,9 @@
1
- //
2
- // {{ module_name }}Presenter.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "Presenter.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  final class {{ module_name }}Presenter {
5
4
 
6
5
  weak var view: {{ module_name }}ViewProtocol?
7
- var wireFrame: {{ module_name }}WireFrameProtocol?
6
+ var wireframe: {{ module_name }}WireframeProtocol?
8
7
  var interactor: {{ module_name }}InteractorProtocol?
9
8
  var dataSource: [{{ model }}] = []
10
9
  }
@@ -29,7 +28,7 @@ extension {{ module_name }}Presenter: {{ module_name }}PresenterProtocol {
29
28
 
30
29
  func process(object: {{ model }}) {
31
30
  guard let view = view else { return }
32
- wireFrame?.navigate(to: object, from: view)
31
+ wireframe?.navigate(to: object, from: view)
33
32
  }
34
33
  }
35
34
 
@@ -1,13 +1,12 @@
1
- //
2
- // {{ module_name }}Protocols.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "Protocols.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  import UIKit
5
4
  import Hydra
6
5
 
7
6
  // MARK: Called by VIEW -> Implemented BY PRESENTER
8
7
  protocol {{ module_name }}PresenterProtocol: class {
9
8
  var view: {{ module_name }}ViewProtocol? { get set }
10
- var wireFrame: {{ module_name }}WireFrameProtocol? { get set }
9
+ var wireframe: {{ module_name }}WireframeProtocol? { get set }
11
10
  var interactor: {{ module_name }}InteractorProtocol? { get set }
12
11
 
13
12
  func viewDidLoad()
@@ -15,7 +14,7 @@ protocol {{ module_name }}PresenterProtocol: class {
15
14
  // datasource
16
15
  var numberOfSection: Int { get }
17
16
  func numberOfRows(in section: Int) -> Int
18
- func content(at row: Int) -> <{{ model }}>?
17
+ func content(at row: Int) -> {{ model }}?
19
18
 
20
19
  func process(object: {{ model }})
21
20
  }
@@ -52,7 +51,7 @@ protocol {{ module_name }}ViewProtocol: Loadable {
52
51
  }
53
52
 
54
53
  // MARK: PRESENTER -> WIREFRAME
55
- protocol {{ module_name }}WireFrameProtocol: class {
54
+ protocol {{ module_name }}WireframeProtocol: class {
56
55
  static func prepareModule() -> UIViewController
57
56
  func navigate(to object: {{ model }}, from view: {{ module_name }}ViewProtocol)
58
57
  }
@@ -1,6 +1,5 @@
1
- //
2
- // {{ module_name }}View.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "View.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  import UIKit
5
4
 
6
5
  class {{ module_name }}View: UIViewController {
@@ -1,9 +1,8 @@
1
- //
2
- // {{ module_name }}WireFrame.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "Wireframe.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  import UIKit
5
4
 
6
- final class {{ module_name }}WireFrame {
5
+ final class {{ module_name }}Wireframe {
7
6
 
8
7
  static func prepareModule() -> UIViewController {
9
8
  let navController = UINavigationController.instantiate(from: .main, identifier: "mainNavigationController")
@@ -14,14 +13,14 @@ final class {{ module_name }}WireFrame {
14
13
 
15
14
  let presenter: {{ module_name }}PresenterProtocol & {{ module_name }}InteractorOutputProtocol = {{ module_name }}Presenter()
16
15
  let interactor: {{ module_name }}InteractorProtocol = {{ module_name }}Interactor()
17
- let wireFrame: {{ module_name }}WireFrameProtocol = {{ module_name }}WireFrame()
16
+ let wireframe: {{ module_name }}WireframeProtocol = {{ module_name }}Wireframe()
18
17
  let localDataManager: {{ module_name }}LocalDataManagerProtocol = {{ module_name }}LocalDataManager()
19
18
  let remoteDataManager: {{ module_name }}RemoteDataManagerProtocol = {{ module_name }}RemoteDataManager()
20
19
 
21
20
  // INTEGRATION
22
21
  view.presenter = presenter
23
22
  presenter.view = view
24
- presenter.wireFrame = wireFrame
23
+ presenter.wireframe = wireframe
25
24
  presenter.interactor = interactor
26
25
  interactor.presenter = presenter
27
26
  interactor.localDataManager = localDataManager
@@ -32,12 +31,12 @@ final class {{ module_name }}WireFrame {
32
31
  }
33
32
 
34
33
  // MARK: NAVIGATION
35
- extension {{ module_name }}WireFrame: {{ module_name }}WireFrameProtocol {
34
+ extension {{ module_name }}Wireframe: {{ module_name }}WireframeProtocol {
36
35
 
37
36
  func navigate(to object: {{ model }}, from view: {{ module_name }}ViewProtocol) {
38
37
  guard let sourceView = view as? UIViewController else { return }
39
38
 
40
- let detailVC = {{ module_name }}DetailWireFrame.prepareModule(with: object)
41
- sourceView.navigationController?.pushViewController(detailVC, animated: true)
39
+ // let detailVC = {{ module_name }}DetailWireframe.prepareModule(with: object)
40
+ // sourceView.navigationController?.pushViewController(detailVC, animated: true)
42
41
  }
43
42
  }
@@ -1,10 +1,9 @@
1
- //
2
- // {{ module_name }}Interactor.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "Presenter.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  final class {{ module_name }}Presenter {
5
4
 
6
5
  weak var view: {{ module_name }}ViewProtocol?
7
- var wireFrame: {{ module_name }}WireFrameProtocol?
6
+ var wireframe: {{ module_name }}WireframeProtocol?
8
7
  var dataSource: {{ model }}?
9
8
  }
10
9
 
@@ -1,12 +1,11 @@
1
- //
2
- // {{ module_name }}Protocols.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "Protocols.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  import UIKit
5
4
 
6
5
  // MARK: Called by VIEW -> Implemented BY PRESENTER
7
6
  protocol {{ module_name }}PresenterProtocol: class {
8
7
  weak var view: {{ module_name }}ViewProtocol? { get set }
9
- weak var wireFrame: {{ module_name }}WireFrameProtocol? { get set }
8
+ weak var wireframe: {{ module_name }}WireframeProtocol? { get set }
10
9
  var dataSource: {{ model }}? { get set }
11
10
 
12
11
  func viewDidLoad()
@@ -18,6 +17,6 @@ protocol {{ module_name }}ViewProtocol: Loadable {
18
17
  }
19
18
 
20
19
  // MARK: PRESENTER -> WIREFRAME
21
- protocol {{ module_name }}WireFrameProtocol: class {
20
+ protocol {{ module_name }}WireframeProtocol: class {
22
21
  static func prepareModule(with object: {{ model }}) -> UIViewController
23
22
  }
@@ -1,6 +1,5 @@
1
- //
2
- // {{ module_name }}View.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "View.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  import UIKit
5
4
 
6
5
  class {{ module_name }}View: UIViewController {
@@ -1,20 +1,19 @@
1
- //
2
- // {{ module_name }}WireFrame.swift
3
- {% include 'header' %}
1
+ {% if target != "xcode" %}{% assign filename_suffix = "Wireframe.swift" %}{% include 'header' %}{% else %}//___FILEHEADER___{% endif %}
2
+
4
3
  import UIKit
5
4
 
6
- final class {{ module_name }}WireFrame: {{ module_name }}WireFrameProtocol {
5
+ final class {{ module_name }}Wireframe: {{ module_name }}WireframeProtocol {
7
6
 
8
7
  static func prepareModule(with object: {{ model }}) -> UIViewController {
9
8
  let view = {{ module_name }}View.instantiate(from: .main)
10
9
 
11
10
  let presenter: {{ module_name }}PresenterProtocol = {{ module_name }}Presenter()
12
- let wireFrame = {{ module_name }}WireFrame()
11
+ let wireframe = {{ module_name }}Wireframe()
13
12
 
14
13
  view.presenter = presenter
15
14
  presenter.view = view
16
15
  presenter.dataSource = object
17
- presenter.wireFrame = wireFrame
16
+ presenter.wireframe = wireframe
18
17
 
19
18
  return view
20
19
  }
data/lib/molt.rb CHANGED
@@ -5,17 +5,28 @@ require "molt/cli/main"
5
5
  require "generamba/string-colorize"
6
6
 
7
7
  module Molt
8
+ ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
8
9
  MOLT_GLOBAL = "#{Dir.home}/.molt"
9
10
  MOLT_PROJECT = "./.molt"
10
11
  CONFIG_GLOBAL = "#{MOLT_GLOBAL}/config.yml"
11
12
  CONFIG_PROJECT = "#{MOLT_PROJECT}/config.yml"
12
- LONG_DESC = <<-TAG
13
+ LONG_DESC_CREATE_MODULE = <<-TAG
13
14
  This generates a scaffold for a new VIPER module all contained in a folder. You will then have onto drag this folder onto Xcode.
14
15
 
15
16
  This command runs in dry-run mode by default (without using -f). That means this will only print the project/module configuration, list of templates, and eventual output files.
16
17
 
17
18
  When you're happy with what you see, just add --do-it or -f to exit dry-run mode.
18
19
 
20
+ * Note that the default template set "viper_table" uses several Swift helper extensions all of which could be found in either ~/.molt or your project's ./.molt folder. These were all copied when you ran "molt setup" or "molt setup_project". Feel free to copy them or modify the template files to suit your preference.
21
+ TAG
22
+ LONG_DESC_XCODE = <<-TAG
23
+
24
+ This command basically exports a template set and makes it available as an Xcode template, which makes your often-used template instantly available from within Xcode itself. When you do create a new file from within Xcode, you will be prompted for the module name and the model. Other meta details normally available in create_module won't be necessary during the export.
25
+
26
+ This command runs in dry-run mode by default (without using -f). That means this will only print the project/module configuration, list of templates, and eventual output files.
27
+
28
+ When you're happy with what you see, just add --do-it or -f to exit dry-run mode.
29
+
19
30
  * Note that the default template set "viper_table" uses several Swift helper extensions all of which could be found in either ~/.molt or your project's ./.molt folder. These were all copied when you ran "molt setup" or "molt setup_project". Feel free to copy them or modify the template files to suit your preference.
20
31
  TAG
21
32
  end
@@ -1,11 +1,14 @@
1
1
  module Molt::CLI
2
2
  class Generator
3
3
 
4
- def self.create_module(module_name, template_set, options)
5
- puts "OPTIONS #{options.inspect}".blue
4
+ def self.create_module(module_name, template_set, options, xcode = false)
6
5
  config = Molt::Configuration.load_or_initialize
7
- config = Molt::Configuration.apply_cli_overrides config, options, module_name, template_set
8
- rows = table_rows_for config
6
+ if !xcode
7
+ config = Molt::Configuration.apply_cli_overrides config, options, module_name, template_set
8
+ else
9
+ config = Molt::Configuration.config_for_xcode config, options, module_name, template_set
10
+ end
11
+ rows = table_rows_for config, xcode
9
12
 
10
13
  sets = ""
11
14
  models = ""
@@ -20,14 +23,17 @@ module Molt::CLI
20
23
 
21
24
  Dir["#{sets}/#{template_set}/**/*swift.liquid"].each do |template_file|
22
25
  template_base_folder = File.dirname(template_file).gsub(/#{sets}\/#{template_set}/, "")
23
- destination_folder = "#{options.output_folder}/#{module_name}#{template_base_folder}"
26
+ destination_folder = "#{options.output_folder}/#{module_name}#{template_base_folder}" if !xcode
27
+ destination_folder = File.expand_path("~/Library/Developer/Xcode/Templates/File Templates/Molt/#{template_set.gsub(/_/, " ")}.xctemplate") if xcode
24
28
 
25
29
  base_file = File.basename(template_file.gsub(/.liquid$/, ""))
26
- output_file = "#{destination_folder}/#{module_name}#{base_file}"
30
+ output_file = "#{destination_folder}/#{module_name}#{base_file}" if !xcode
31
+ output_file = "#{destination_folder}/___FILEBASENAME___#{base_file}" if xcode
27
32
  rows << [template_file.gsub(/#{sets}\//, ""), output_file.blue]
28
33
 
29
34
  if options.do_it
30
35
  FileUtils.mkdir_p destination_folder
36
+ FileUtils.cp Dir.glob("#{Molt::ROOT}/sample_configs/Template*"), destination_folder
31
37
  Molt::Template.liquify(template: template_file, output_file: output_file, config: config)
32
38
  end
33
39
  end
@@ -55,14 +61,16 @@ module Molt::CLI
55
61
  end
56
62
 
57
63
  private
58
- def self.table_rows_for config
64
+ def self.table_rows_for config, xcode
59
65
  rows = []
60
- rows << ["Developer", config["developer"]["name"].blue]
61
- rows << ["Email", config["developer"]["email"].blue]
62
- rows << ["Company", config["developer"]["company"].blue]
63
- rows << ["Project", config["project"]["name"].blue]
64
66
 
65
- rows << [" ", " "]
67
+ if !xcode
68
+ rows << ["Developer", config["developer"]["name"].blue]
69
+ rows << ["Email", config["developer"]["email"].blue]
70
+ rows << ["Company", config["developer"]["company"].blue]
71
+ rows << ["Project", config["project"]["name"].blue]
72
+ rows << [" ", " "]
73
+ end
66
74
  rows << ["Template Set", config["template_set"].yellow]
67
75
  rows << [" ", " "]
68
76
  rows << ["Source".green, "Destination".green]
data/lib/molt/cli/main.rb CHANGED
@@ -51,7 +51,7 @@ module Molt::CLI
51
51
  command :create_module do |c|
52
52
  c.syntax = 'molt create_module MODULE_NAME TEMPLATE_SET'
53
53
  c.summary = "Generate component files for a VIPER module"
54
- c.description = Molt::LONG_DESC
54
+ c.description = Molt::LONG_DESC_CREATE_MODULE
55
55
  c.option '--name NAME', String, "Author name"
56
56
  c.option '--email EMAIL', String, "Author email"
57
57
  c.option '--company COMPANY', String, "Author company"
@@ -62,12 +62,23 @@ module Molt::CLI
62
62
  c.option '--do-it', false, "Release the Kraken and write the files"
63
63
  c.action do |args, options|
64
64
  options.default :output_folder => "."
65
- puts "ARGS #{args}\nOPTS #{options.inspect}"
66
65
  Molt::CLI::Generator.create_module(args[0], args[1], options)
67
66
  end
68
67
  end
69
68
  alias_command :'c', :create_module
70
69
 
70
+ command :xcode do |c|
71
+ c.syntax = 'molt xcode TEMPLATE_SET'
72
+ c.summary = "Export template set as Xcode template"
73
+ c.description = Molt::LONG_DESC_XCODE
74
+ c.option '--output-folder DIRECTORY', String, "Create module folder in this directory. Defaults to \"./\""
75
+ c.option '--do-it', false, "Release the Kraken and write the files"
76
+ c.action do |args, options|
77
+ options.default :output_folder => "."
78
+ Molt::CLI::Generator.create_module("", args[0], options, true)
79
+ end
80
+ end
81
+ alias_command :'c', :create_module
71
82
  end
72
83
  end
73
84
  end
@@ -5,8 +5,7 @@ module Molt::CLI
5
5
  include Thor::Actions
6
6
 
7
7
  def self.source_root
8
- gem_root = File.join(File.dirname(__FILE__), "../../..")
9
- File.expand_path(gem_root)
8
+ Molt::ROOT
10
9
  end
11
10
 
12
11
  desc "perform", "perform"
@@ -24,19 +24,31 @@ module Molt
24
24
  end
25
25
 
26
26
  def self.apply_cli_overrides config, options, module_name, template_set
27
+ config["template_set"] = template_set
28
+ config["target"] = "raw"
29
+
27
30
  config["developer"]["name"] = options.name if options.name
28
31
  config["developer"]["email"] = options.email if options.email
29
32
  config["developer"]["company"] = options.company if options.company
30
33
  config["project"]["name"] = options.project if options.project
34
+
35
+ config["module_name"] = module_name
31
36
  config["model"] = "#{options.model}Model" || "<# Model #>"
32
37
  config["entity"] = options.model || "<# Entity #>"
33
38
 
34
- # meta
35
- config["module_name"] = module_name
36
- config["template_set"] = template_set
37
39
  config["year"] = Time.now.strftime("%Y")
38
40
  config["date"] = Time.now.strftime("%d/%m/%Y")
39
41
  config
40
42
  end
43
+
44
+ def self.config_for_xcode config, options, module_name, template_set
45
+ config["template_set"] = template_set
46
+ config["target"] = "xcode"
47
+
48
+ config["module_name"] = "___VARIABLE_productName:identifier___"
49
+ config["model"] = "___VARIABLE_MODEL___Model"
50
+ config["entity"] = "___VARIABLE_MODEL___"
51
+ config
52
+ end
41
53
  end
42
54
  end
data/lib/molt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Molt
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
Binary file
@@ -0,0 +1,57 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>Kind</key>
6
+ <string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
7
+ <key>Description</key>
8
+ <string>VIPER Module for a TableView</string>
9
+ <key>Summary</key>
10
+ <string>VIPER Module for a TableView</string>
11
+ <key>SortOrder</key>
12
+ <string>30</string>
13
+ <key>AllowedTypes</key>
14
+ <array>
15
+ <string>public.swift-source</string>
16
+ </array>
17
+ <key>DefaultCompletionName</key>
18
+ <string>File</string>
19
+ <key>MainTemplateFile</key>
20
+ <string>___FILEBASENAME___.swift</string>
21
+ <key>Options</key>
22
+ <array>
23
+ <dict>
24
+ <key>Identifier</key>
25
+ <string>MODEL</string>
26
+ <key>Required</key>
27
+ <true/>
28
+ <key>Name</key>
29
+ <string>Model</string>
30
+ <key>Description</key>
31
+ <string>Model</string>
32
+ <key>Type</key>
33
+ <string>text</string>
34
+ <key>Default</key>
35
+ <string>&lt;# Model #&gt;</string>
36
+ <key>NotPersisted</key>
37
+ <true/>
38
+ </dict>
39
+ <dict>
40
+ <key>Identifier</key>
41
+ <string>productName</string>
42
+ <key>Required</key>
43
+ <true/>
44
+ <key>Name</key>
45
+ <string>Module Name</string>
46
+ <key>Description</key>
47
+ <string>Module Description</string>
48
+ <key>Type</key>
49
+ <string>text</string>
50
+ <key>Default</key>
51
+ <string>Awesome</string>
52
+ <key>NotPersisted</key>
53
+ <true/>
54
+ </dict>
55
+ </array>
56
+ </dict>
57
+ </plist>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: molt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Cabazal
@@ -169,17 +169,17 @@ files:
169
169
  - bundle/swift_helpers/Loadable.swift
170
170
  - bundle/swift_helpers/Networking/APIRouter.swift
171
171
  - bundle/swift_helpers/StoryboardExtensions.swift
172
+ - bundle/template_sets/VIPER_TableView/DataManagers/LocalDataManager.swift.liquid
173
+ - bundle/template_sets/VIPER_TableView/DataManagers/RemoteDataManager.swift.liquid
174
+ - bundle/template_sets/VIPER_TableView/Interactor.swift.liquid
175
+ - bundle/template_sets/VIPER_TableView/Presenter.swift.liquid
176
+ - bundle/template_sets/VIPER_TableView/Protocols.swift.liquid
177
+ - bundle/template_sets/VIPER_TableView/View.swift.liquid
178
+ - bundle/template_sets/VIPER_TableView/Wireframe.swift.liquid
172
179
  - bundle/template_sets/viper_detail/Presenter.swift.liquid
173
180
  - bundle/template_sets/viper_detail/Protocols.swift.liquid
174
181
  - bundle/template_sets/viper_detail/View.swift.liquid
175
182
  - bundle/template_sets/viper_detail/WireFrame.swift.liquid
176
- - bundle/template_sets/viper_table/DataManagers/LocalDataManager.swift.liquid
177
- - bundle/template_sets/viper_table/DataManagers/RemoteDataManager.swift.liquid
178
- - bundle/template_sets/viper_table/Interactor.swift.liquid
179
- - bundle/template_sets/viper_table/Presenter.swift.liquid
180
- - bundle/template_sets/viper_table/Protocols.swift.liquid
181
- - bundle/template_sets/viper_table/View.swift.liquid
182
- - bundle/template_sets/viper_table/WireFrame.swift.liquid
183
183
  - lib/generamba/string-colorize.rb
184
184
  - lib/molt.rb
185
185
  - lib/molt/cli/create_module.rb
@@ -190,6 +190,9 @@ files:
190
190
  - lib/molt/template.rb
191
191
  - lib/molt/version.rb
192
192
  - molt.gemspec
193
+ - sample_configs/TemplateIcon.png
194
+ - sample_configs/TemplateIcon@2x.png
195
+ - sample_configs/TemplateInfo.plist
193
196
  - sample_configs/global_config.yml.erb
194
197
  homepage: https://github.com/MarcoCabazal/Molt
195
198
  licenses: