molt 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +56 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +55 -0
- data/LICENSE.txt +21 -0
- data/README.md +210 -0
- data/Rakefile +6 -0
- data/bin/console +7 -0
- data/bin/molt +6 -0
- data/bin/setup +7 -0
- data/bundled/models/Entity+CoreData.swift.liquid +15 -0
- data/bundled/models/Entity.swift.liquid +7 -0
- data/bundled/models/Model.swift.liquid +20 -0
- data/bundled/partials/_header.liquid +5 -0
- data/bundled/swift_helpers/ErrorTypes/APIError.swift +28 -0
- data/bundled/swift_helpers/ErrorTypes/ErrorTypes.swift +12 -0
- data/bundled/swift_helpers/ErrorTypes/PersistenceError.swift +28 -0
- data/bundled/swift_helpers/ISODateTransform.swift +26 -0
- data/bundled/swift_helpers/Identifiable.swift +29 -0
- data/bundled/swift_helpers/Loadable.swift +37 -0
- data/bundled/swift_helpers/Networking/APIRouter.swift +54 -0
- data/bundled/swift_helpers/StoryboardExtensions.swift +49 -0
- data/bundled/template_sets/viper_detail/Presenter.swift.liquid +17 -0
- data/bundled/template_sets/viper_detail/Protocols.swift.liquid +23 -0
- data/bundled/template_sets/viper_detail/View.swift.liquid +25 -0
- data/bundled/template_sets/viper_detail/WireFrame.swift.liquid +21 -0
- data/bundled/template_sets/viper_table/DataManagers/LocalDataManager.swift.liquid +45 -0
- data/bundled/template_sets/viper_table/DataManagers/RemoteDataManager.swift.liquid +26 -0
- data/bundled/template_sets/viper_table/Interactor.swift.liquid +48 -0
- data/bundled/template_sets/viper_table/Presenter.swift.liquid +49 -0
- data/bundled/template_sets/viper_table/Protocols.swift.liquid +58 -0
- data/bundled/template_sets/viper_table/View.swift.liquid +60 -0
- data/bundled/template_sets/viper_table/WireFrame.swift.liquid +43 -0
- data/lib/generamba/string-colorize.rb +31 -0
- data/lib/molt/cli/create_module.rb +76 -0
- data/lib/molt/cli/main.rb +74 -0
- data/lib/molt/cli/setup.rb +23 -0
- data/lib/molt/cli/template_sets.rb +18 -0
- data/lib/molt/configuration.rb +43 -0
- data/lib/molt/template.rb +9 -0
- data/lib/molt/version.rb +3 -0
- data/lib/molt.rb +22 -0
- data/molt.gemspec +32 -0
- data/sample_configs/global_config.yml.erb +7 -0
- metadata +218 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1f653a91f4ffbb1fae1b4ebed28e5705ca47aa10
|
4
|
+
data.tar.gz: 2e817635437347b36f3be3326cd9e225789cdeb7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f96319f8ec285255791c61bc4e53b6ead9723f29d7578e6b2f665bb431effa36c53269206ad2f630b35c560697faf6a4ef4e1e73e4c5cc3c11d1c99bb5d5c9a
|
7
|
+
data.tar.gz: 7cecde0df45fb3239777f9e8c63172cfcc575e62f70a396757478d47d9dbbdb8150420305f9653fe67cfa3d30cfb87ecae211bc96f48aa8063df1b675fe6489b
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
defaults: &defaults
|
3
|
+
environment:
|
4
|
+
TZ: "/usr/share/zoneinfo/Asia/Manila"
|
5
|
+
working_directory: ~/molt
|
6
|
+
docker:
|
7
|
+
- image: ruby:2.4.3
|
8
|
+
|
9
|
+
version: 2
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
<<: *defaults
|
13
|
+
steps:
|
14
|
+
- checkout
|
15
|
+
|
16
|
+
- restore_cache:
|
17
|
+
key: magnitude-{{ checksum "Gemfile.lock" }}
|
18
|
+
|
19
|
+
- run:
|
20
|
+
name: Installing App Bundle
|
21
|
+
command: |
|
22
|
+
gem install bundler
|
23
|
+
bundle install --path vendor/bundle
|
24
|
+
|
25
|
+
- save_cache:
|
26
|
+
key: molt-{{ checksum "Gemfile.lock" }}
|
27
|
+
paths:
|
28
|
+
- vendor/bundle
|
29
|
+
|
30
|
+
- run:
|
31
|
+
name: Running RSpec
|
32
|
+
command: bundle exec rspec
|
33
|
+
|
34
|
+
workflows:
|
35
|
+
version: 2
|
36
|
+
build-test-and-deploy:
|
37
|
+
jobs:
|
38
|
+
- build
|
39
|
+
- alpha:
|
40
|
+
filters:
|
41
|
+
branches:
|
42
|
+
only: alpha
|
43
|
+
requires:
|
44
|
+
- build
|
45
|
+
- beta:
|
46
|
+
filters:
|
47
|
+
branches:
|
48
|
+
only: beta
|
49
|
+
requires:
|
50
|
+
- build
|
51
|
+
- production:
|
52
|
+
filters:
|
53
|
+
branches:
|
54
|
+
only: master
|
55
|
+
requires:
|
56
|
+
- build
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at marco.cabazal@chillmill.mobi. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
molt (0.1.2)
|
5
|
+
commander
|
6
|
+
liquid (~> 4.0.0)
|
7
|
+
terminal-table
|
8
|
+
thor (~> 0.20)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
awesome_print (1.8.0)
|
14
|
+
coderay (1.1.2)
|
15
|
+
commander (4.4.4)
|
16
|
+
highline (~> 1.7.2)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
highline (1.7.10)
|
19
|
+
liquid (4.0.0)
|
20
|
+
method_source (0.9.0)
|
21
|
+
pry (0.11.3)
|
22
|
+
coderay (~> 1.1.0)
|
23
|
+
method_source (~> 0.9.0)
|
24
|
+
rake (12.3.0)
|
25
|
+
rspec (3.7.0)
|
26
|
+
rspec-core (~> 3.7.0)
|
27
|
+
rspec-expectations (~> 3.7.0)
|
28
|
+
rspec-mocks (~> 3.7.0)
|
29
|
+
rspec-core (3.7.1)
|
30
|
+
rspec-support (~> 3.7.0)
|
31
|
+
rspec-expectations (3.7.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.7.0)
|
34
|
+
rspec-mocks (3.7.0)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.7.0)
|
37
|
+
rspec-support (3.7.1)
|
38
|
+
terminal-table (1.8.0)
|
39
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
40
|
+
thor (0.20.0)
|
41
|
+
unicode-display_width (1.3.0)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
awesome_print
|
48
|
+
bundler (~> 1.16)
|
49
|
+
molt!
|
50
|
+
pry
|
51
|
+
rake
|
52
|
+
rspec (~> 3.4)
|
53
|
+
|
54
|
+
BUNDLED WITH
|
55
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Marco Cabazal
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
Molt
|
2
|
+
====
|
3
|
+
|
4
|
+
Molt is a simple VIPER module generator for Swift apps.
|
5
|
+
|
6
|
+
[![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
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
$ gem install molt
|
11
|
+
|
12
|
+
### Global Configuration
|
13
|
+
|
14
|
+
To initialize global configuration in `~/.molt`:
|
15
|
+
|
16
|
+
$ 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
|
42
|
+
|
43
|
+
This will create the folder `~/.molt`, copy bundled template sets and helper Swift extensions onto it.
|
44
|
+
|
45
|
+
This will also create a base config file (`config.yml`). If you have a global git config at `~/.gitconfig`, some of the developer details would already be filled out for you. The details you put here would be used to populate meta data in the header files of the generated source code.
|
46
|
+
|
47
|
+
You should customize this with your information before you proceed with generating new modules.
|
48
|
+
|
49
|
+
developer:
|
50
|
+
name: Tom Hagen
|
51
|
+
email: tom@omerta.org
|
52
|
+
company: Genco Olive Oil Imports
|
53
|
+
|
54
|
+
project:
|
55
|
+
name: CapoRegime
|
56
|
+
|
57
|
+
### Per-Project Configuration
|
58
|
+
|
59
|
+
On the other hand, to setup per-project configuration, go to your project's root folder, then:
|
60
|
+
|
61
|
+
$ molt setup:project
|
62
|
+
create .molt
|
63
|
+
create .molt/models/Entity+CoreData.swift.liquid
|
64
|
+
create .molt/models/Entity.swift.liquid
|
65
|
+
create .molt/models/Model.swift.liquid
|
66
|
+
create .molt/partials/_header.liquid
|
67
|
+
create .molt/swift_helpers/ErrorTypes/APIError.swift
|
68
|
+
create .molt/swift_helpers/ErrorTypes/ErrorTypes.swift
|
69
|
+
create .molt/swift_helpers/ErrorTypes/PersistenceError.swift
|
70
|
+
create .molt/swift_helpers/ISODateTransform.swift
|
71
|
+
create .molt/swift_helpers/Identifiable.swift
|
72
|
+
create .molt/swift_helpers/Loadable.swift
|
73
|
+
create .molt/swift_helpers/Networking/APIRouter.swift
|
74
|
+
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
|
86
|
+
create .molt/config.yml
|
87
|
+
|
88
|
+
|
89
|
+
### Template Sets
|
90
|
+
|
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.
|
92
|
+
|
93
|
+
The template system makes use of `Liquid` and supports partials which are located in `.molt/partials`.
|
94
|
+
|
95
|
+
To list available template sets (search order: current project directory, global, bundled):
|
96
|
+
|
97
|
+
$ molt template_sets
|
98
|
+
./.molt:
|
99
|
+
./.molt/template_sets/viper_table
|
100
|
+
./.molt/template_sets/some_project_specific_template
|
101
|
+
|
102
|
+
/Users/TomHagen/.molt:
|
103
|
+
/Users/TomHagen/.molt/template_sets/viper_table
|
104
|
+
/Users/TomHagen/.molt/template_sets/viper_detail
|
105
|
+
|
106
|
+
Add --verbose to list all files in each template set
|
107
|
+
|
108
|
+
|
109
|
+
To list available template sets and the template files they contain:
|
110
|
+
|
111
|
+
$ molt template_sets --verbose
|
112
|
+
./.molt:
|
113
|
+
./.molt/models/Entity+CoreData.swift.liquid
|
114
|
+
./.molt/models/Model.swift.liquid
|
115
|
+
./.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
|
123
|
+
./.molt/template_sets/some_project_specific_template/Protocols.swift.liquid
|
124
|
+
./.molt/template_sets/some_project_specific_template/Presenter.swift.liquid
|
125
|
+
./.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
|
145
|
+
|
146
|
+
$ molt create_module Friends viper_table
|
147
|
+
+---------------------------------------------------------+-------------------------------------------------------+
|
148
|
+
| Developer | Tom Hagen |
|
149
|
+
| Email | tom@omerta.org |
|
150
|
+
| Company | Genco Olive Oil Imports |
|
151
|
+
| Project | CapoRegime |
|
152
|
+
| | |
|
153
|
+
| Template Set | viper_table |
|
154
|
+
| | |
|
155
|
+
| Source | Destination |
|
156
|
+
| viper_table/Protocols.swift.liquid | ./Friends/FriendsProtocols.swift |
|
157
|
+
| viper_table/Presenter.swift.liquid | ./Friends/FriendsPresenter.swift |
|
158
|
+
| viper_table/DataManagers/RemoteDataManager.swift.liquid | ./Friends/DataManagers/FriendsRemoteDataManager.swift |
|
159
|
+
| viper_table/DataManagers/LocalDataManager.swift.liquid | ./Friends/DataManagers/FriendsLocalDataManager.swift |
|
160
|
+
| viper_table/View.swift.liquid | ./Friends/FriendsView.swift |
|
161
|
+
| viper_table/WireFrame.swift.liquid | ./Friends/FriendsWireFrame.swift |
|
162
|
+
| viper_table/Interactor.swift.liquid | ./Friends/FriendsInteractor.swift |
|
163
|
+
+---------------------------------------------------------+-------------------------------------------------------+
|
164
|
+
|
165
|
+
That was just a dry-run. If this looks good to you, don't forget to add --do-it
|
166
|
+
|
167
|
+
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
|
+
|
169
|
+
### Additional options/overrides when generating modules
|
170
|
+
|
171
|
+
$ molt help create_module
|
172
|
+
Usage:
|
173
|
+
molt create_module MODULE_NAME TEMPLATE_SET
|
174
|
+
|
175
|
+
Options:
|
176
|
+
--name NAME # Author name
|
177
|
+
--email EMAIL # Author email
|
178
|
+
-company COMPANY # Author company
|
179
|
+
-project PROJECT # Project name
|
180
|
+
-output-folder DIRECTORY # Create module folder in this directory. Defaults to "./"
|
181
|
+
-model MODEL # Model name. If unspecified, Xcode placeholders will be used instead
|
182
|
+
-create-model # If specified, it creates corresponding Mappable struct (ObjectMapper) and Core Data entity; requires --model to be set
|
183
|
+
-do-it # Release the Kraken and write the files
|
184
|
+
|
185
|
+
### Notes about the bundled `viper_table` template set
|
186
|
+
|
187
|
+
1. The `RemoteDataManager` makes use of `Alamofire` and `ObjectMapper`
|
188
|
+
2. The `LocalDataManager` makes use of `Core Data`
|
189
|
+
3. The `Interactor` and `RemoteDataManager` talks to each other using promises via `Hydra`
|
190
|
+
3. You'll notice there aren't any mention of segues here, but Storyboards and Scenes are in.
|
191
|
+
4. The template makes use of some Swift extensions, all of which are made available in `.molt/swift_helpers`
|
192
|
+
|
193
|
+
To appreciate, please see the sample rendered source code for [Friends](https://github.com/MarcoCabazal/Molt/tree/development/sample_output).
|
194
|
+
|
195
|
+
### TODOs
|
196
|
+
|
197
|
+
1. Demo a working app done created using generators
|
198
|
+
1. Write more comprehensive tests
|
199
|
+
|
200
|
+
### Contributing
|
201
|
+
|
202
|
+
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
|
+
|
204
|
+
### License
|
205
|
+
|
206
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
207
|
+
|
208
|
+
### Code of Conduct
|
209
|
+
|
210
|
+
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).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/molt
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
//
|
2
|
+
// {{ entity }}+CoreData.swift
|
3
|
+
{% include 'header' %}
|
4
|
+
import Foundation
|
5
|
+
import CoreData
|
6
|
+
|
7
|
+
extension {{ entity }} {
|
8
|
+
|
9
|
+
@nonobjc public class func fetchRequest() -> NSFetchRequest<{{ entity }}> {
|
10
|
+
return NSFetchRequest<{{ entity }}>(entityName: {{ entity }}.id)
|
11
|
+
}
|
12
|
+
|
13
|
+
@NSManaged public var id: Int32
|
14
|
+
@NSManaged public var title: String?
|
15
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
//
|
2
|
+
// {{ model }}.swift
|
3
|
+
{% include 'header' %}
|
4
|
+
import Foundation
|
5
|
+
import ObjectMapper
|
6
|
+
|
7
|
+
struct {{ model }} {
|
8
|
+
var id = 0
|
9
|
+
var title = ""
|
10
|
+
}
|
11
|
+
|
12
|
+
extension {{ model }}: Mappable {
|
13
|
+
|
14
|
+
init?(map: Map) { }
|
15
|
+
|
16
|
+
mutating func mapping(map: Map) {
|
17
|
+
id <- map["id"]
|
18
|
+
title <- map["title"]
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
//
|
2
|
+
// APIError.swift
|
3
|
+
// YATodo
|
4
|
+
//
|
5
|
+
// Created by Marco Cabazal on 2/14/18.
|
6
|
+
// Copyright © 2018 The Chill Mill, Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
import Alamofire
|
10
|
+
import SwiftyJSON
|
11
|
+
|
12
|
+
enum APIError: DisplayableError {
|
13
|
+
case connectivityError
|
14
|
+
case unknown
|
15
|
+
|
16
|
+
var title: String {
|
17
|
+
return "API Error"
|
18
|
+
}
|
19
|
+
|
20
|
+
var message: String {
|
21
|
+
switch self {
|
22
|
+
case .connectivityError:
|
23
|
+
return "Couldn't connect to the server"
|
24
|
+
case .unknown:
|
25
|
+
return "Something went wrong."
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
//
|
2
|
+
// PersistenceError.swift
|
3
|
+
// Yet Another Todo App (using Viper)
|
4
|
+
//
|
5
|
+
// Created by Marco Cabazal on 18 Jan 2017.
|
6
|
+
// Copyright © 2017 The Chill Mill, Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
enum PersistenceError: DisplayableError {
|
10
|
+
case mocNotFound
|
11
|
+
case couldNotSaveObject
|
12
|
+
case objectNotFound
|
13
|
+
|
14
|
+
var title: String {
|
15
|
+
return "Core Data Error"
|
16
|
+
}
|
17
|
+
|
18
|
+
var message: String {
|
19
|
+
switch self {
|
20
|
+
case .mocNotFound:
|
21
|
+
return "MOC not found."
|
22
|
+
case .couldNotSaveObject:
|
23
|
+
return "Couldn't save object."
|
24
|
+
case .objectNotFound:
|
25
|
+
return "Object not found."
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
//
|
2
|
+
// ISODateTransform.swift
|
3
|
+
// YATodo
|
4
|
+
//
|
5
|
+
// Created by Marco Cabazal on 2/4/18.
|
6
|
+
// Copyright © 2018 The Chill Mill, Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
import ObjectMapper
|
10
|
+
|
11
|
+
public struct ISODateTransform: TransformType {
|
12
|
+
|
13
|
+
public func transformFromJSON(_ value: Any?) -> Date? {
|
14
|
+
guard let dateString = value as? String else { return nil }
|
15
|
+
let formatter = DateFormatter()
|
16
|
+
formatter.dateFormat = "YYYY-MM-dd'T'HH:mm:ss.SSSZ"
|
17
|
+
return formatter.date(from: dateString)
|
18
|
+
}
|
19
|
+
|
20
|
+
public func transformToJSON(_ value: Date?) -> String? {
|
21
|
+
guard let dateString = value else { return nil }
|
22
|
+
let formatter = DateFormatter()
|
23
|
+
formatter.dateFormat = "YYYY-MM-dd'T'HH:mm:ss.SSSZ"
|
24
|
+
return formatter.string(from: dateString)
|
25
|
+
}
|
26
|
+
}
|