ccios 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +20 -0
- data/.gitignore +3 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +89 -78
- data/Makefile +11 -0
- data/README.md +55 -0
- data/ccios.gemspec +1 -1
- data/lib/ccios.rb +7 -5
- data/lib/ccios/config.rb +113 -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 +51 -23
- data/lib/ccios/presenter_generator.rb +26 -10
- data/lib/ccios/repository_generator.rb +19 -11
- 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: 17e45b6aa153c86b30ee9975a172b6a9e010c796633936310497a4d7eafea7e4
|
4
|
+
data.tar.gz: 61769b9cdd9d07510d855ccbbbdcace5a79fb171391872db91d93778bfbc0448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0782622ea52267f207de88a45a60fdcffe93629b3c6fcb8542c2ee256dccc7fd44e1aeb4b2dc1b2e4fb5514b836fbe561968e18bda962d50b4d5b23884cad34
|
7
|
+
data.tar.gz: a744aaa03b197360105b3656580dfecc9675138269a9bf7116093b1daa208919ac5cf77ece3ca735b92906a303b2e79dbe95df22f12653b631c4cb0d53c842ee
|
@@ -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
data/Gemfile.lock
CHANGED
@@ -1,122 +1,133 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ccios (
|
4
|
+
ccios (2.2.0)
|
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.2)
|
14
|
+
actionpack (= 5.2.4.2)
|
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.2)
|
18
|
+
actionpack (= 5.2.4.2)
|
19
|
+
actionview (= 5.2.4.2)
|
20
|
+
activejob (= 5.2.4.2)
|
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.2)
|
24
|
+
actionview (= 5.2.4.2)
|
25
|
+
activesupport (= 5.2.4.2)
|
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.2)
|
31
|
+
activesupport (= 5.2.4.2)
|
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.2)
|
37
|
+
activesupport (= 5.2.4.2)
|
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.2)
|
40
|
+
activesupport (= 5.2.4.2)
|
41
|
+
activerecord (5.2.4.2)
|
42
|
+
activemodel (= 5.2.4.2)
|
43
|
+
activesupport (= 5.2.4.2)
|
44
|
+
arel (>= 9.0)
|
45
|
+
activestorage (5.2.4.2)
|
46
|
+
actionpack (= 5.2.4.2)
|
47
|
+
activerecord (= 5.2.4.2)
|
48
|
+
marcel (~> 0.3.1)
|
49
|
+
activesupport (5.2.4.2)
|
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.2)
|
65
|
+
concurrent-ruby (~> 1.0)
|
66
|
+
loofah (2.5.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.4)
|
75
|
+
mini_mime (1.0.2)
|
76
|
+
mini_portile2 (2.4.0)
|
77
|
+
minitest (5.14.0)
|
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.2)
|
84
|
+
rack-test (1.1.0)
|
85
|
+
rack (>= 1.0, < 3)
|
86
|
+
rails (5.2.4.2)
|
87
|
+
actioncable (= 5.2.4.2)
|
88
|
+
actionmailer (= 5.2.4.2)
|
89
|
+
actionpack (= 5.2.4.2)
|
90
|
+
actionview (= 5.2.4.2)
|
91
|
+
activejob (= 5.2.4.2)
|
92
|
+
activemodel (= 5.2.4.2)
|
93
|
+
activerecord (= 5.2.4.2)
|
94
|
+
activestorage (= 5.2.4.2)
|
95
|
+
activesupport (= 5.2.4.2)
|
86
96
|
bundler (>= 1.3.0)
|
87
|
-
railties (= 5.
|
97
|
+
railties (= 5.2.4.2)
|
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.2)
|
105
|
+
actionpack (= 5.2.4.2)
|
106
|
+
activesupport (= 5.2.4.2)
|
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.0)
|
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.1)
|
113
123
|
websocket-extensions (>= 0.1.0)
|
114
|
-
websocket-extensions (0.1.
|
115
|
-
xcodeproj (1.
|
116
|
-
CFPropertyList (
|
124
|
+
websocket-extensions (0.1.4)
|
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,58 @@ 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
|
+
presenter:
|
139
|
+
group: Classes/App
|
140
|
+
coordinator:
|
141
|
+
group: Classes/Coordinator
|
142
|
+
|
143
|
+
core:
|
144
|
+
project: MyProjectCore/MyProjectCore.xcodeproj
|
145
|
+
interactor:
|
146
|
+
group: MyProjectCore/Interactors
|
147
|
+
repository:
|
148
|
+
group: MyProjectCore/Repository
|
149
|
+
|
150
|
+
data:
|
151
|
+
project: MyProjectData/MyProjectData.xcodeproj
|
152
|
+
repository:
|
153
|
+
group: MyProjectData/Sources/Repositories
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
*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.
|
158
|
+
|
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,113 @@
|
|
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, :presenter, :coordinator
|
79
|
+
|
80
|
+
def initialize(hash)
|
81
|
+
@project = hash["project"]
|
82
|
+
@presenter = ObjectConfig.new hash["presenter"]
|
83
|
+
@coordinator = ObjectConfig.new hash["coordinator"]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class CoreConfig
|
88
|
+
attr_reader :project, :interactor, :repository
|
89
|
+
|
90
|
+
def initialize(hash)
|
91
|
+
@project = hash["project"]
|
92
|
+
@interactor = ObjectConfig.new hash["interactor"]
|
93
|
+
@repository = ObjectConfig.new hash["repository"]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class DataConfig
|
98
|
+
attr_reader :project, :repository
|
99
|
+
|
100
|
+
def initialize(hash)
|
101
|
+
@project = hash["project"]
|
102
|
+
@repository = ObjectConfig.new hash["repository"]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class ObjectConfig
|
107
|
+
|
108
|
+
attr_reader :group
|
109
|
+
|
110
|
+
def initialize(hash)
|
111
|
+
@group = hash["group"]
|
112
|
+
end
|
113
|
+
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,77 @@ 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]
|
41
48
|
end
|
42
49
|
|
43
|
-
def
|
44
|
-
|
50
|
+
def app_target
|
51
|
+
app_project.targets.first
|
52
|
+
end
|
53
|
+
|
54
|
+
def core_target
|
55
|
+
core_project.targets.first
|
56
|
+
end
|
57
|
+
|
58
|
+
def data_target
|
59
|
+
data_project.targets.first
|
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)
|
49
77
|
end
|
50
78
|
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
|
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.2.0
|
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
|