ccios 2.0.5 → 2.3.1
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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +20 -0
- data/.gitignore +3 -1
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +89 -78
- data/Makefile +11 -0
- data/README.md +58 -0
- data/ccios.gemspec +1 -1
- data/lib/ccios.rb +7 -5
- data/lib/ccios/config.rb +116 -0
- data/lib/ccios/coordinator_generator.rb +4 -3
- data/lib/ccios/file_creator.rb +36 -10
- data/lib/ccios/interactor_generator.rb +9 -4
- data/lib/ccios/pbxproj_parser.rb +59 -23
- data/lib/ccios/presenter_generator.rb +26 -10
- data/lib/ccios/repository_generator.rb +19 -11
- data/lib/ccios/templates/coordinator.mustache +1 -1
- data/lib/ccios/templates/interactor.mustache +1 -1
- data/lib/ccios/templates/interactor_assembly.mustache +1 -1
- data/lib/ccios/templates/interactor_implementation.mustache +6 -2
- data/lib/ccios/templates/presenter.mustache +1 -1
- data/lib/ccios/templates/repository.mustache +1 -1
- data/lib/ccios/templates/repository_assembly.mustache +3 -2
- data/lib/ccios/templates/repository_implementation.mustache +3 -2
- data/lib/ccios/templates/view_contract.mustache +1 -1
- data/lib/ccios/templates/view_controller.mustache +0 -9
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a91b4b27117d32ca43866305dcb4b608e19b7b2bc11d549adf8949b9237130b
|
|
4
|
+
data.tar.gz: db06e885141f29fbdc87bf32d6275fc1d0991f3589b420771efed8ce0f906c31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b4be04de8f4743c6ea64f3c61dcea3cc13763bade1d832fda5096886843da51a7ee80f878c611aa00f6e5359d6a6b0bb8a22189b1e01c0adecacc95b3998112
|
|
7
|
+
data.tar.gz: a7fda8ce8630afc97a8e03986f3c70800ff0e7e331f5edd00479bcf7a2d29b73657ffd1ef66ca97be896e16a014a1cd6bf1aef38d080dbab9d03182c52c8852d
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v1
|
|
12
|
+
- name: Set up Ruby 2.6
|
|
13
|
+
uses: actions/setup-ruby@v1
|
|
14
|
+
with:
|
|
15
|
+
ruby-version: 2.6.x
|
|
16
|
+
- name: Build and test with Rake
|
|
17
|
+
run: |
|
|
18
|
+
gem install bundler
|
|
19
|
+
bundle install --jobs 4 --retry 3
|
|
20
|
+
bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
`ADUtils` adheres to [Semantic Versioning](http://semver.org/).
|
|
4
|
+
|
|
5
|
+
## [2.3.1]
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Import `Core` in Repository implementations
|
|
9
|
+
- Updated by [Hervé Béranger](https://github.com/hberenger) in Pull Request [#11](https://github.com/felginep/ccios/pull/11)
|
|
10
|
+
|
|
11
|
+
## [2.3.0]
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- Add possibilty to specify target in `.ccios.yml`
|
|
15
|
+
|
|
16
|
+
## [2.2.0]
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- Create configuration with optional `.ccios.yml` file
|
data/Gemfile.lock
CHANGED
|
@@ -1,122 +1,133 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ccios (
|
|
4
|
+
ccios (2.3.1)
|
|
5
5
|
mustache (~> 1.0)
|
|
6
|
-
rails
|
|
6
|
+
rails (~> 5.1)
|
|
7
7
|
xcodeproj (~> 1.4)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
CFPropertyList (
|
|
13
|
-
actioncable (5.
|
|
14
|
-
actionpack (= 5.
|
|
12
|
+
CFPropertyList (3.0.2)
|
|
13
|
+
actioncable (5.2.4.3)
|
|
14
|
+
actionpack (= 5.2.4.3)
|
|
15
15
|
nio4r (~> 2.0)
|
|
16
|
-
websocket-driver (
|
|
17
|
-
actionmailer (5.
|
|
18
|
-
actionpack (= 5.
|
|
19
|
-
actionview (= 5.
|
|
20
|
-
activejob (= 5.
|
|
16
|
+
websocket-driver (>= 0.6.1)
|
|
17
|
+
actionmailer (5.2.4.3)
|
|
18
|
+
actionpack (= 5.2.4.3)
|
|
19
|
+
actionview (= 5.2.4.3)
|
|
20
|
+
activejob (= 5.2.4.3)
|
|
21
21
|
mail (~> 2.5, >= 2.5.4)
|
|
22
22
|
rails-dom-testing (~> 2.0)
|
|
23
|
-
actionpack (5.
|
|
24
|
-
actionview (= 5.
|
|
25
|
-
activesupport (= 5.
|
|
26
|
-
rack (~> 2.0)
|
|
27
|
-
rack-test (
|
|
23
|
+
actionpack (5.2.4.3)
|
|
24
|
+
actionview (= 5.2.4.3)
|
|
25
|
+
activesupport (= 5.2.4.3)
|
|
26
|
+
rack (~> 2.0, >= 2.0.8)
|
|
27
|
+
rack-test (>= 0.6.3)
|
|
28
28
|
rails-dom-testing (~> 2.0)
|
|
29
29
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
30
|
-
actionview (5.
|
|
31
|
-
activesupport (= 5.
|
|
30
|
+
actionview (5.2.4.3)
|
|
31
|
+
activesupport (= 5.2.4.3)
|
|
32
32
|
builder (~> 3.1)
|
|
33
33
|
erubi (~> 1.4)
|
|
34
34
|
rails-dom-testing (~> 2.0)
|
|
35
35
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
36
|
-
activejob (5.
|
|
37
|
-
activesupport (= 5.
|
|
36
|
+
activejob (5.2.4.3)
|
|
37
|
+
activesupport (= 5.2.4.3)
|
|
38
38
|
globalid (>= 0.3.6)
|
|
39
|
-
activemodel (5.
|
|
40
|
-
activesupport (= 5.
|
|
41
|
-
activerecord (5.
|
|
42
|
-
activemodel (= 5.
|
|
43
|
-
activesupport (= 5.
|
|
44
|
-
arel (
|
|
45
|
-
|
|
39
|
+
activemodel (5.2.4.3)
|
|
40
|
+
activesupport (= 5.2.4.3)
|
|
41
|
+
activerecord (5.2.4.3)
|
|
42
|
+
activemodel (= 5.2.4.3)
|
|
43
|
+
activesupport (= 5.2.4.3)
|
|
44
|
+
arel (>= 9.0)
|
|
45
|
+
activestorage (5.2.4.3)
|
|
46
|
+
actionpack (= 5.2.4.3)
|
|
47
|
+
activerecord (= 5.2.4.3)
|
|
48
|
+
marcel (~> 0.3.1)
|
|
49
|
+
activesupport (5.2.4.3)
|
|
46
50
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
47
|
-
i18n (
|
|
51
|
+
i18n (>= 0.7, < 2)
|
|
48
52
|
minitest (~> 5.1)
|
|
49
53
|
tzinfo (~> 1.1)
|
|
50
|
-
arel (
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
arel (9.0.0)
|
|
55
|
+
atomos (0.1.3)
|
|
56
|
+
builder (3.2.4)
|
|
57
|
+
claide (1.0.3)
|
|
53
58
|
colored2 (3.1.2)
|
|
54
|
-
concurrent-ruby (1.
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
concurrent-ruby (1.1.6)
|
|
60
|
+
crass (1.0.6)
|
|
61
|
+
erubi (1.9.0)
|
|
62
|
+
globalid (0.4.2)
|
|
57
63
|
activesupport (>= 4.2.0)
|
|
58
|
-
i18n (
|
|
59
|
-
|
|
64
|
+
i18n (1.8.3)
|
|
65
|
+
concurrent-ruby (~> 1.0)
|
|
66
|
+
loofah (2.6.0)
|
|
67
|
+
crass (~> 1.0.2)
|
|
60
68
|
nokogiri (>= 1.5.9)
|
|
61
|
-
mail (2.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
rack
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
mail (2.7.1)
|
|
70
|
+
mini_mime (>= 0.1.1)
|
|
71
|
+
marcel (0.3.3)
|
|
72
|
+
mimemagic (~> 0.3.2)
|
|
73
|
+
method_source (1.0.0)
|
|
74
|
+
mimemagic (0.3.5)
|
|
75
|
+
mini_mime (1.0.2)
|
|
76
|
+
mini_portile2 (2.4.0)
|
|
77
|
+
minitest (5.14.1)
|
|
78
|
+
mustache (1.1.1)
|
|
79
|
+
nanaimo (0.2.6)
|
|
80
|
+
nio4r (2.5.2)
|
|
81
|
+
nokogiri (1.10.9)
|
|
82
|
+
mini_portile2 (~> 2.4.0)
|
|
83
|
+
rack (2.2.3)
|
|
84
|
+
rack-test (1.1.0)
|
|
85
|
+
rack (>= 1.0, < 3)
|
|
86
|
+
rails (5.2.4.3)
|
|
87
|
+
actioncable (= 5.2.4.3)
|
|
88
|
+
actionmailer (= 5.2.4.3)
|
|
89
|
+
actionpack (= 5.2.4.3)
|
|
90
|
+
actionview (= 5.2.4.3)
|
|
91
|
+
activejob (= 5.2.4.3)
|
|
92
|
+
activemodel (= 5.2.4.3)
|
|
93
|
+
activerecord (= 5.2.4.3)
|
|
94
|
+
activestorage (= 5.2.4.3)
|
|
95
|
+
activesupport (= 5.2.4.3)
|
|
86
96
|
bundler (>= 1.3.0)
|
|
87
|
-
railties (= 5.
|
|
97
|
+
railties (= 5.2.4.3)
|
|
88
98
|
sprockets-rails (>= 2.0.0)
|
|
89
99
|
rails-dom-testing (2.0.3)
|
|
90
100
|
activesupport (>= 4.2.0)
|
|
91
101
|
nokogiri (>= 1.6)
|
|
92
|
-
rails-html-sanitizer (1.0
|
|
93
|
-
loofah (~> 2.
|
|
94
|
-
railties (5.
|
|
95
|
-
actionpack (= 5.
|
|
96
|
-
activesupport (= 5.
|
|
102
|
+
rails-html-sanitizer (1.3.0)
|
|
103
|
+
loofah (~> 2.3)
|
|
104
|
+
railties (5.2.4.3)
|
|
105
|
+
actionpack (= 5.2.4.3)
|
|
106
|
+
activesupport (= 5.2.4.3)
|
|
97
107
|
method_source
|
|
98
108
|
rake (>= 0.8.7)
|
|
99
|
-
thor (>= 0.
|
|
100
|
-
rake (
|
|
101
|
-
sprockets (
|
|
109
|
+
thor (>= 0.19.0, < 2.0)
|
|
110
|
+
rake (13.0.1)
|
|
111
|
+
sprockets (4.0.2)
|
|
102
112
|
concurrent-ruby (~> 1.0)
|
|
103
113
|
rack (> 1, < 3)
|
|
104
|
-
sprockets-rails (3.2.
|
|
114
|
+
sprockets-rails (3.2.1)
|
|
105
115
|
actionpack (>= 4.0)
|
|
106
116
|
activesupport (>= 4.0)
|
|
107
117
|
sprockets (>= 3.0.0)
|
|
108
|
-
thor (0.
|
|
118
|
+
thor (1.0.1)
|
|
109
119
|
thread_safe (0.3.6)
|
|
110
|
-
tzinfo (1.2.
|
|
120
|
+
tzinfo (1.2.7)
|
|
111
121
|
thread_safe (~> 0.1)
|
|
112
|
-
websocket-driver (0.
|
|
122
|
+
websocket-driver (0.7.2)
|
|
113
123
|
websocket-extensions (>= 0.1.0)
|
|
114
|
-
websocket-extensions (0.1.
|
|
115
|
-
xcodeproj (1.
|
|
116
|
-
CFPropertyList (
|
|
124
|
+
websocket-extensions (0.1.5)
|
|
125
|
+
xcodeproj (1.16.0)
|
|
126
|
+
CFPropertyList (>= 2.3.3, < 4.0)
|
|
127
|
+
atomos (~> 0.1.3)
|
|
117
128
|
claide (>= 1.0.2, < 2.0)
|
|
118
129
|
colored2 (~> 3.1)
|
|
119
|
-
nanaimo (~> 0.2.
|
|
130
|
+
nanaimo (~> 0.2.6)
|
|
120
131
|
|
|
121
132
|
PLATFORMS
|
|
122
133
|
ruby
|
|
@@ -125,4 +136,4 @@ DEPENDENCIES
|
|
|
125
136
|
ccios!
|
|
126
137
|
|
|
127
138
|
BUNDLED WITH
|
|
128
|
-
1.
|
|
139
|
+
1.17.3
|
data/Makefile
ADDED
data/README.md
CHANGED
|
@@ -101,3 +101,61 @@ The following structure is created for you in the Xcode project:
|
|
|
101
101
|
+-- Coordinator/
|
|
102
102
|
| +-- ExampleCoordinator
|
|
103
103
|
```
|
|
104
|
+
|
|
105
|
+
## Configuration
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
Each project is different. You can configure the groups to use in the xcodeproj for the new files.
|
|
109
|
+
|
|
110
|
+
Create a file `.ccios.yml` at the root of your project.
|
|
111
|
+
|
|
112
|
+
By default, if no file is present, the following configuration will be used:
|
|
113
|
+
```
|
|
114
|
+
app:
|
|
115
|
+
project: MyProject.xcodeproj
|
|
116
|
+
presenter:
|
|
117
|
+
group: Classes/App
|
|
118
|
+
coordinator:
|
|
119
|
+
group: Classes/Coordinator
|
|
120
|
+
|
|
121
|
+
core:
|
|
122
|
+
project: MyProject.xcodeproj
|
|
123
|
+
interactor:
|
|
124
|
+
group: Classes/Core/Interactor
|
|
125
|
+
repository:
|
|
126
|
+
group: Classes/Core/Data
|
|
127
|
+
|
|
128
|
+
data:
|
|
129
|
+
project: MyProject.xcodeproj
|
|
130
|
+
repository:
|
|
131
|
+
group: Classes/Data
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
But you could imagine more complex project structures with multiple xcodeproj:
|
|
135
|
+
```
|
|
136
|
+
app:
|
|
137
|
+
project: MyProject/MyProject.xcodeproj
|
|
138
|
+
target: MyProject # optional
|
|
139
|
+
presenter:
|
|
140
|
+
group: Classes/App
|
|
141
|
+
coordinator:
|
|
142
|
+
group: Classes/Coordinator
|
|
143
|
+
|
|
144
|
+
core:
|
|
145
|
+
project: MyProjectCore/MyProjectCore.xcodeproj
|
|
146
|
+
target: MyProjectCore # optional
|
|
147
|
+
interactor:
|
|
148
|
+
group: MyProjectCore/Interactors
|
|
149
|
+
repository:
|
|
150
|
+
group: MyProjectCore/Repository
|
|
151
|
+
|
|
152
|
+
data:
|
|
153
|
+
project: MyProjectData/MyProjectData.xcodeproj
|
|
154
|
+
target: MyProjectData # optional
|
|
155
|
+
repository:
|
|
156
|
+
group: MyProjectData/Sources/Repositories
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
*Note*: The path of the new files will be infered from the path of the group. It works with *Group with folder* and *Group without folder* in Xcode.
|
|
161
|
+
|
data/ccios.gemspec
CHANGED
data/lib/ccios.rb
CHANGED
|
@@ -6,6 +6,7 @@ require 'ccios/presenter_generator'
|
|
|
6
6
|
require 'ccios/coordinator_generator'
|
|
7
7
|
require 'ccios/interactor_generator'
|
|
8
8
|
require 'ccios/repository_generator'
|
|
9
|
+
require 'ccios/config'
|
|
9
10
|
|
|
10
11
|
options = {}
|
|
11
12
|
OptionParser.new do |opts|
|
|
@@ -35,31 +36,32 @@ OptionParser.new do |opts|
|
|
|
35
36
|
end.parse!
|
|
36
37
|
|
|
37
38
|
source_path = Dir.pwd
|
|
38
|
-
|
|
39
|
+
config = Config.parse ".ccios.yml"
|
|
40
|
+
parser = PBXProjParser.new(source_path, config)
|
|
39
41
|
|
|
40
42
|
if options[:presenter]
|
|
41
43
|
presenter_name = options[:presenter]
|
|
42
|
-
presenter_generator = PresenterGenerator.new
|
|
44
|
+
presenter_generator = PresenterGenerator.new(parser, config)
|
|
43
45
|
generator_options = {generate_delegate: options[:generate_delegate]}
|
|
44
46
|
presenter_generator.generate(presenter_name, generator_options)
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
if options[:coordinator]
|
|
48
50
|
coordinator_name = options[:coordinator]
|
|
49
|
-
coordinator_generator = CoordinatorGenerator.new
|
|
51
|
+
coordinator_generator = CoordinatorGenerator.new(parser, config)
|
|
50
52
|
generator_options = {generate_delegate: options[:generate_delegate]}
|
|
51
53
|
coordinator_generator.generate(coordinator_name, generator_options)
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
if options[:interactor]
|
|
55
57
|
interactor_name = options[:interactor]
|
|
56
|
-
interactor_generator = InteractorGenerator.new
|
|
58
|
+
interactor_generator = InteractorGenerator.new(parser, config)
|
|
57
59
|
interactor_generator.generate(interactor_name)
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
if options[:repository]
|
|
61
63
|
repository_name = options[:repository]
|
|
62
|
-
repository_generator = RepositoryGenerator.new
|
|
64
|
+
repository_generator = RepositoryGenerator.new(parser, config)
|
|
63
65
|
repository_generator.generate(repository_name)
|
|
64
66
|
end
|
|
65
67
|
|
data/lib/ccios/config.rb
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
class Config
|
|
4
|
+
|
|
5
|
+
attr_reader :app, :core, :data
|
|
6
|
+
|
|
7
|
+
def self.parse(source_path)
|
|
8
|
+
if File.exist?(source_path)
|
|
9
|
+
config = YAML.load_file(source_path)
|
|
10
|
+
self.new config, source_path
|
|
11
|
+
else
|
|
12
|
+
puts "File #{source_path} does not exists. Using default config."
|
|
13
|
+
self.default
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.default_config_hash
|
|
18
|
+
project = "*.xcodeproj"
|
|
19
|
+
{
|
|
20
|
+
"app" => {
|
|
21
|
+
"project" => project,
|
|
22
|
+
"presenter" => {"group" => "Classes/App"},
|
|
23
|
+
"coordinator" => {"group" => "Classes/Coordinator"}
|
|
24
|
+
},
|
|
25
|
+
"core" => {
|
|
26
|
+
"project" => project,
|
|
27
|
+
"interactor" => {"group" => "Classes/Core/Interactor"},
|
|
28
|
+
"repository" => {"group" => "Classes/Core/Data"}
|
|
29
|
+
},
|
|
30
|
+
"data" => {
|
|
31
|
+
"project" => project,
|
|
32
|
+
"repository" => {"group" => "Classes/Data"}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.default
|
|
38
|
+
self.new default_config_hash
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def initialize(config_hash, source_path = nil)
|
|
42
|
+
@source_path = source_path
|
|
43
|
+
validate config_hash
|
|
44
|
+
@app = AppConfig.new config_hash["app"]
|
|
45
|
+
@core = CoreConfig.new config_hash["core"]
|
|
46
|
+
@data = DataConfig.new config_hash["data"]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def validate(hash)
|
|
50
|
+
validate_path hash, "app.project"
|
|
51
|
+
validate_path hash, "app.presenter.group"
|
|
52
|
+
validate_path hash, "app.coordinator.group"
|
|
53
|
+
|
|
54
|
+
validate_path hash, "core.project"
|
|
55
|
+
validate_path hash, "core.interactor.group"
|
|
56
|
+
validate_path hash, "core.repository.group"
|
|
57
|
+
|
|
58
|
+
validate_path hash, "data.project"
|
|
59
|
+
validate_path hash, "data.repository.group"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def validate_path(hash, path)
|
|
63
|
+
components = path.split(".")
|
|
64
|
+
keys = []
|
|
65
|
+
components.each do |component|
|
|
66
|
+
hash = hash[component]
|
|
67
|
+
keys << component
|
|
68
|
+
if hash.nil?
|
|
69
|
+
message = "Key \"#{keys.join(".")}\" is missing"
|
|
70
|
+
message += " in #{@source_path}" unless @source_path.nil?
|
|
71
|
+
raise message
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
class AppConfig
|
|
78
|
+
attr_reader :project, :target, :presenter, :coordinator
|
|
79
|
+
|
|
80
|
+
def initialize(hash)
|
|
81
|
+
@project = hash["project"]
|
|
82
|
+
@target = hash["target"]
|
|
83
|
+
@presenter = ObjectConfig.new hash["presenter"]
|
|
84
|
+
@coordinator = ObjectConfig.new hash["coordinator"]
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class CoreConfig
|
|
89
|
+
attr_reader :project, :target, :interactor, :repository
|
|
90
|
+
|
|
91
|
+
def initialize(hash)
|
|
92
|
+
@project = hash["project"]
|
|
93
|
+
@target = hash["target"]
|
|
94
|
+
@interactor = ObjectConfig.new hash["interactor"]
|
|
95
|
+
@repository = ObjectConfig.new hash["repository"]
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
class DataConfig
|
|
100
|
+
attr_reader :project, :target, :repository
|
|
101
|
+
|
|
102
|
+
def initialize(hash)
|
|
103
|
+
@project = hash["project"]
|
|
104
|
+
@target = hash["target"]
|
|
105
|
+
@repository = ObjectConfig.new hash["repository"]
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class ObjectConfig
|
|
110
|
+
|
|
111
|
+
attr_reader :group
|
|
112
|
+
|
|
113
|
+
def initialize(hash)
|
|
114
|
+
@group = hash["group"]
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -3,14 +3,15 @@ require_relative "pbxproj_parser"
|
|
|
3
3
|
|
|
4
4
|
class CoordinatorGenerator
|
|
5
5
|
|
|
6
|
-
def initialize(parser)
|
|
6
|
+
def initialize(parser, config)
|
|
7
7
|
@parser = parser
|
|
8
|
+
@config = config
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def generate(coordinator_name, options = {})
|
|
11
12
|
coordinator_group = @parser.coordinator_group
|
|
12
|
-
file_creator = FileCreator.new(
|
|
13
|
-
target = @parser.
|
|
13
|
+
file_creator = FileCreator.new(options)
|
|
14
|
+
target = @parser.app_target
|
|
14
15
|
file_creator.create_file(coordinator_name, 'Coordinator', coordinator_group, target)
|
|
15
16
|
end
|
|
16
17
|
end
|
data/lib/ccios/file_creator.rb
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
require_relative 'code_templater'
|
|
2
|
+
require 'fileutils'
|
|
2
3
|
|
|
3
4
|
class FileCreator
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
def self.logger
|
|
7
|
+
@@logger ||= create_logger
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def logger
|
|
11
|
+
FileCreator.logger
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def initialize(options = {})
|
|
7
15
|
@options = options
|
|
8
16
|
end
|
|
9
17
|
|
|
@@ -17,13 +25,15 @@ class FileCreator
|
|
|
17
25
|
end
|
|
18
26
|
|
|
19
27
|
def git_username
|
|
20
|
-
`
|
|
28
|
+
`git config user.name`.strip
|
|
21
29
|
end
|
|
22
30
|
|
|
23
31
|
def create_file(prefix, suffix, group, target)
|
|
24
|
-
file_path =
|
|
32
|
+
file_path = File.join(group.real_path, prefix + suffix + '.swift')
|
|
25
33
|
|
|
26
|
-
raise "File #{file_path} already exists" if File.
|
|
34
|
+
raise "File #{file_path} already exists" if File.exist?(file_path)
|
|
35
|
+
dirname = File.dirname(file_path)
|
|
36
|
+
FileUtils.mkdir_p dirname unless File.directory?(dirname)
|
|
27
37
|
file = File.new(file_path, 'w')
|
|
28
38
|
|
|
29
39
|
templater_options = templater_options(target)
|
|
@@ -36,14 +46,30 @@ class FileCreator
|
|
|
36
46
|
target.add_file_references([file_ref])
|
|
37
47
|
end
|
|
38
48
|
|
|
49
|
+
def create_empty_directory(group)
|
|
50
|
+
dirname = group.real_path
|
|
51
|
+
FileUtils.mkdir_p dirname unless File.directory?(dirname)
|
|
52
|
+
|
|
53
|
+
git_keep_path = File.join(dirname, ".gitkeep")
|
|
54
|
+
FileUtils.touch(git_keep_path) if Dir.empty?(dirname)
|
|
55
|
+
end
|
|
56
|
+
|
|
39
57
|
def print_file_content(prefix, suffix)
|
|
40
|
-
|
|
58
|
+
file_name = suffix + '.swift'
|
|
41
59
|
|
|
42
60
|
code_templater = CodeTemplater.new(@options)
|
|
43
61
|
template = code_templater.content_for_suffix(prefix, suffix)
|
|
44
62
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
logger.info "Add this snippet to #{file_name}"
|
|
64
|
+
logger.info template
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
def self.create_logger
|
|
70
|
+
logger = Logger.new(STDOUT)
|
|
71
|
+
logger.level = Logger::DEBUG
|
|
72
|
+
logger.formatter = proc { |severity, datetime, progname, msg| msg + "\n" }
|
|
73
|
+
logger
|
|
48
74
|
end
|
|
49
75
|
end
|
|
@@ -3,18 +3,23 @@ require_relative "pbxproj_parser"
|
|
|
3
3
|
|
|
4
4
|
class InteractorGenerator
|
|
5
5
|
|
|
6
|
-
def initialize(parser)
|
|
6
|
+
def initialize(parser, config)
|
|
7
7
|
@parser = parser
|
|
8
|
+
@config = config
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def generate(interactor_name, options = {})
|
|
11
12
|
interactor_group = @parser.interactor_group
|
|
12
13
|
new_group_name = "#{interactor_name}Interactor"
|
|
14
|
+
|
|
15
|
+
associate_path_to_group = !interactor_group.path.nil?
|
|
16
|
+
|
|
13
17
|
raise "[Error] Group #{new_group_name} already exists in #{app_group.display_name}" if interactor_group[new_group_name]
|
|
14
|
-
|
|
18
|
+
new_group_path = File.join(interactor_group.real_path, new_group_name)
|
|
19
|
+
new_group = interactor_group.new_group(new_group_name, associate_path_to_group ? new_group_path : nil)
|
|
15
20
|
|
|
16
|
-
file_creator = FileCreator.new(
|
|
17
|
-
target = @parser.
|
|
21
|
+
file_creator = FileCreator.new(options)
|
|
22
|
+
target = @parser.core_target
|
|
18
23
|
file_creator.create_file(interactor_name, 'Interactor', new_group, target)
|
|
19
24
|
file_creator.create_file(interactor_name, 'InteractorImplementation', new_group, target)
|
|
20
25
|
|
data/lib/ccios/pbxproj_parser.rb
CHANGED
|
@@ -2,49 +2,85 @@ require 'xcodeproj'
|
|
|
2
2
|
|
|
3
3
|
class PBXProjParser
|
|
4
4
|
|
|
5
|
-
attr_accessor :source_path
|
|
5
|
+
attr_accessor :source_path
|
|
6
6
|
|
|
7
|
-
def initialize(source_path)
|
|
7
|
+
def initialize(source_path, config)
|
|
8
8
|
@source_path = source_path
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
end
|
|
12
|
-
@project = Xcodeproj::Project.open(project_path)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def project_path
|
|
16
|
-
Dir.glob("#{@source_path}/*.xcodeproj").first
|
|
9
|
+
@config = config
|
|
10
|
+
@projects = {}
|
|
17
11
|
end
|
|
18
12
|
|
|
19
|
-
def
|
|
20
|
-
@
|
|
13
|
+
def app_project
|
|
14
|
+
project_for(@config.app.project)
|
|
21
15
|
end
|
|
22
16
|
|
|
23
|
-
def
|
|
24
|
-
@
|
|
17
|
+
def core_project
|
|
18
|
+
project_for(@config.core.project)
|
|
25
19
|
end
|
|
26
20
|
|
|
27
|
-
def
|
|
28
|
-
|
|
21
|
+
def data_project
|
|
22
|
+
project_for(@config.data.project)
|
|
29
23
|
end
|
|
30
24
|
|
|
31
|
-
def
|
|
32
|
-
|
|
25
|
+
def presenter_group
|
|
26
|
+
path = @config.app.presenter.group
|
|
27
|
+
app_project[path]
|
|
33
28
|
end
|
|
34
29
|
|
|
35
30
|
def coordinator_group
|
|
36
|
-
|
|
31
|
+
path = @config.app.coordinator.group
|
|
32
|
+
app_project[path]
|
|
37
33
|
end
|
|
38
34
|
|
|
39
35
|
def interactor_group
|
|
40
|
-
|
|
36
|
+
path = @config.core.interactor.group
|
|
37
|
+
core_project[path]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def repository_core_group
|
|
41
|
+
path = @config.core.repository.group
|
|
42
|
+
core_project[path]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def repository_data_group
|
|
46
|
+
path = @config.data.repository.group
|
|
47
|
+
data_project[path]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def app_target
|
|
51
|
+
target_for(app_project, @config.app.target)
|
|
41
52
|
end
|
|
42
53
|
|
|
43
|
-
def
|
|
44
|
-
|
|
54
|
+
def core_target
|
|
55
|
+
target_for(core_project, @config.core.target)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def data_target
|
|
59
|
+
target_for(data_project, @config.data.target)
|
|
45
60
|
end
|
|
46
61
|
|
|
47
62
|
def save
|
|
48
|
-
|
|
63
|
+
app_project.save
|
|
64
|
+
core_project.save
|
|
65
|
+
data_project.save
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def project_for(path)
|
|
71
|
+
module_project_path = File.join(source_path, path)
|
|
72
|
+
resolved_module_project_path = Dir.glob(module_project_path).first
|
|
73
|
+
if !File.exist?(resolved_module_project_path)
|
|
74
|
+
raise "[Error] There is no xcodeproj at path #{module_project_path}"
|
|
75
|
+
end
|
|
76
|
+
@projects[module_project_path] ||= Xcodeproj::Project.open(resolved_module_project_path)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def target_for(project, target_name)
|
|
80
|
+
if target_name.blank?
|
|
81
|
+
project.targets.find { |t| t.product_type == "com.apple.product-type.application" }
|
|
82
|
+
else
|
|
83
|
+
project.targets.find { |t| t.name == target_name }
|
|
84
|
+
end
|
|
49
85
|
end
|
|
50
86
|
end
|
|
@@ -3,27 +3,43 @@ require_relative "pbxproj_parser"
|
|
|
3
3
|
|
|
4
4
|
class PresenterGenerator
|
|
5
5
|
|
|
6
|
-
def initialize(parser)
|
|
6
|
+
def initialize(parser, config)
|
|
7
7
|
@parser = parser
|
|
8
|
+
@config = config
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def generate(presenter_name, options = {})
|
|
11
|
-
app_group = @parser.
|
|
12
|
+
app_group = @parser.presenter_group
|
|
13
|
+
|
|
14
|
+
associate_path_to_group = !app_group.path.nil?
|
|
15
|
+
|
|
12
16
|
raise "[Error] Group #{presenter_name} already exists in #{app_group.display_name}" if app_group[presenter_name]
|
|
13
|
-
|
|
17
|
+
new_group_path = File.join(app_group.real_path, presenter_name)
|
|
18
|
+
new_group = app_group.new_group(presenter_name, associate_path_to_group ? new_group_path : nil)
|
|
19
|
+
|
|
20
|
+
ui_group_path = File.join(new_group_path, "UI")
|
|
21
|
+
ui_group = new_group.new_group("UI", associate_path_to_group ? ui_group_path : nil)
|
|
22
|
+
|
|
23
|
+
view_group_path = File.join(ui_group_path, "View")
|
|
24
|
+
view_group = ui_group.new_group("View", associate_path_to_group ? view_group_path : nil)
|
|
25
|
+
|
|
26
|
+
view_controller_group_path = File.join(ui_group_path, "ViewController")
|
|
27
|
+
view_controller_group = ui_group.new_group("ViewController", associate_path_to_group ? view_controller_group_path : nil)
|
|
28
|
+
|
|
29
|
+
presenter_group_path = File.join(new_group_path, "Presenter")
|
|
30
|
+
presenter_group = new_group.new_group("Presenter", associate_path_to_group ? presenter_group_path : nil)
|
|
14
31
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
view_controller_group = ui_group.new_group("ViewController")
|
|
18
|
-
presenter_group = new_group.new_group("Presenter")
|
|
19
|
-
model_group = new_group.new_group("Model")
|
|
32
|
+
model_group_path = File.join(new_group_path, "Model")
|
|
33
|
+
model_group = new_group.new_group("Model", associate_path_to_group ? model_group_path : nil)
|
|
20
34
|
|
|
21
|
-
file_creator = FileCreator.new(
|
|
22
|
-
target = @parser.
|
|
35
|
+
file_creator = FileCreator.new(options)
|
|
36
|
+
target = @parser.app_target
|
|
23
37
|
file_creator.create_file(presenter_name, 'ViewContract', ui_group, target)
|
|
24
38
|
file_creator.create_file(presenter_name, 'ViewController', view_controller_group, target)
|
|
25
39
|
file_creator.create_file(presenter_name, 'Presenter', presenter_group, target)
|
|
26
40
|
file_creator.create_file(presenter_name, 'PresenterImplementation', presenter_group, target)
|
|
41
|
+
file_creator.create_empty_directory(model_group)
|
|
42
|
+
file_creator.create_empty_directory(view_group)
|
|
27
43
|
|
|
28
44
|
file_creator.print_file_content(presenter_name, 'DependencyProvider')
|
|
29
45
|
file_creator.print_file_content(presenter_name, 'PresenterAssembly')
|
|
@@ -3,24 +3,32 @@ require_relative "pbxproj_parser"
|
|
|
3
3
|
|
|
4
4
|
class RepositoryGenerator
|
|
5
5
|
|
|
6
|
-
def initialize(parser)
|
|
6
|
+
def initialize(parser, config)
|
|
7
7
|
@parser = parser
|
|
8
|
+
@config = config
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def generate(repository_name, options = {})
|
|
11
|
-
core_group = @parser.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
raise "[Error] Group #{repository_name} already exists in #{
|
|
15
|
-
|
|
12
|
+
core_group = @parser.repository_core_group
|
|
13
|
+
data_group = @parser.repository_data_group
|
|
14
|
+
|
|
15
|
+
raise "[Error] Group #{repository_name} already exists in #{core_group.display_name}" if core_group[repository_name]
|
|
16
|
+
associate_path_to_group = !core_group.path.nil?
|
|
17
|
+
core_data_new_group_path = File.join(core_group.real_path, repository_name)
|
|
18
|
+
core_data_new_group = core_group.new_group(repository_name, associate_path_to_group ? core_data_new_group_path : nil)
|
|
16
19
|
|
|
17
20
|
raise "[Error] Group #{repository_name} already exists in #{data_group.display_name}" if data_group[repository_name]
|
|
18
|
-
|
|
21
|
+
associate_path_to_group = !data_group.path.nil?
|
|
22
|
+
data_new_group_path = File.join(data_group.real_path, repository_name)
|
|
23
|
+
data_new_group = data_group.new_group(repository_name, associate_path_to_group ? data_new_group_path : nil)
|
|
24
|
+
|
|
25
|
+
file_creator = FileCreator.new(options)
|
|
26
|
+
core_target = @parser.core_target
|
|
27
|
+
file_creator.create_file(repository_name, 'Repository', core_data_new_group, core_target)
|
|
19
28
|
|
|
20
|
-
file_creator = FileCreator.new(
|
|
21
|
-
|
|
22
|
-
file_creator.create_file(repository_name, '
|
|
23
|
-
file_creator.create_file(repository_name, 'RepositoryImplementation', data_new_group, target)
|
|
29
|
+
file_creator = FileCreator.new(options)
|
|
30
|
+
data_target = @parser.data_target
|
|
31
|
+
file_creator.create_file(repository_name, 'RepositoryImplementation', data_new_group, data_target)
|
|
24
32
|
|
|
25
33
|
file_creator.print_file_content(repository_name, 'RepositoryAssembly')
|
|
26
34
|
end
|
|
@@ -8,11 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
import Foundation
|
|
10
10
|
|
|
11
|
-
class {{name}}InteractorImplementation: {{name}}Interactor {
|
|
11
|
+
public class {{name}}InteractorImplementation: {{name}}Interactor {
|
|
12
|
+
|
|
13
|
+
public init() {
|
|
14
|
+
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
// MARK: - {{name}}Interactor
|
|
14
18
|
|
|
15
|
-
func execute() {
|
|
19
|
+
public func execute() {
|
|
16
20
|
|
|
17
21
|
}
|
|
18
22
|
}
|
|
@@ -12,15 +12,6 @@ import UIKit
|
|
|
12
12
|
class {{name}}ViewController: SharedViewController, {{name}}ViewContract {
|
|
13
13
|
var presenter: {{name}}Presenter?
|
|
14
14
|
|
|
15
|
-
init() {
|
|
16
|
-
super.init(nibName: nil, bundle: nil)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@available(*, unavailable)
|
|
20
|
-
required init?(coder decoder: NSCoder) {
|
|
21
|
-
fatalError("init(coder:) has not been implemented")
|
|
22
|
-
}
|
|
23
|
-
|
|
24
15
|
override func viewDidLoad() {
|
|
25
16
|
super.viewDidLoad()
|
|
26
17
|
presenter?.start()
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ccios
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pierre Felgines
|
|
@@ -59,15 +59,19 @@ executables:
|
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
|
+
- ".github/workflows/ruby.yml"
|
|
62
63
|
- ".gitignore"
|
|
64
|
+
- CHANGELOG.md
|
|
63
65
|
- Gemfile
|
|
64
66
|
- Gemfile.lock
|
|
67
|
+
- Makefile
|
|
65
68
|
- README.md
|
|
66
69
|
- Rakefile
|
|
67
70
|
- bin/ccios
|
|
68
71
|
- ccios.gemspec
|
|
69
72
|
- lib/ccios.rb
|
|
70
73
|
- lib/ccios/code_templater.rb
|
|
74
|
+
- lib/ccios/config.rb
|
|
71
75
|
- lib/ccios/coordinator_generator.rb
|
|
72
76
|
- lib/ccios/file_creator.rb
|
|
73
77
|
- lib/ccios/interactor_generator.rb
|
|
@@ -106,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
106
110
|
- !ruby/object:Gem::Version
|
|
107
111
|
version: '0'
|
|
108
112
|
requirements: []
|
|
109
|
-
|
|
110
|
-
rubygems_version: 2.7.6
|
|
113
|
+
rubygems_version: 3.0.3
|
|
111
114
|
signing_key:
|
|
112
115
|
specification_version: 4
|
|
113
116
|
summary: Clean Code iOS Generator
|