ccios 4.0.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +4 -4
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +31 -0
  5. data/Gemfile.lock +13 -12
  6. data/README.md +188 -51
  7. data/ccios.gemspec +1 -1
  8. data/lib/ccios/argument_template_parameter.rb +33 -0
  9. data/lib/ccios/code_templater.rb +24 -7
  10. data/lib/ccios/config.rb +45 -78
  11. data/lib/ccios/file_creator.rb +24 -21
  12. data/lib/ccios/file_template_definition.rb +94 -0
  13. data/lib/ccios/flag_template_parameter.rb +17 -0
  14. data/lib/ccios/group_template_definition.rb +54 -0
  15. data/lib/ccios/pbxproj_parser.rb +3 -54
  16. data/lib/ccios/snippet_template_definition.rb +27 -0
  17. data/lib/ccios/template_definition.rb +116 -0
  18. data/lib/ccios/templates/Coordinator/template.yml +20 -0
  19. data/lib/ccios/templates/Interactor/template.yml +25 -0
  20. data/lib/ccios/templates/Presenter/template.yml +49 -0
  21. data/lib/ccios/templates/{repository_implementation.mustache → Repository/repository_implementation.mustache} +0 -1
  22. data/lib/ccios/templates/Repository/template.yml +26 -0
  23. data/lib/ccios/templates_loader.rb +31 -0
  24. data/lib/ccios.rb +65 -43
  25. data/templates_library/async/Coordinator/coordinator.mustache +41 -0
  26. data/templates_library/async/Coordinator/template.yml +20 -0
  27. data/templates_library/async/Presenter/dependency_provider.mustache +14 -0
  28. data/templates_library/async/Presenter/presenter.mustache +21 -0
  29. data/templates_library/async/Presenter/presenter_assembly.mustache +15 -0
  30. data/templates_library/async/Presenter/presenter_implementation.mustache +35 -0
  31. data/templates_library/async/Presenter/template.yml +49 -0
  32. data/templates_library/async/Presenter/view_contract.mustache +14 -0
  33. data/templates_library/async/Presenter/view_controller.mustache +23 -0
  34. data/templates_library/default/README.md +1 -0
  35. metadata +40 -22
  36. data/lib/ccios/coordinator_generator.rb +0 -18
  37. data/lib/ccios/interactor_generator.rb +0 -33
  38. data/lib/ccios/presenter_generator.rb +0 -71
  39. data/lib/ccios/repository_generator.rb +0 -44
  40. /data/lib/ccios/templates/{coordinator.mustache → Coordinator/coordinator.mustache} +0 -0
  41. /data/lib/ccios/templates/{interactor.mustache → Interactor/interactor.mustache} +0 -0
  42. /data/lib/ccios/templates/{interactor_assembly.mustache → Interactor/interactor_assembly.mustache} +0 -0
  43. /data/lib/ccios/templates/{interactor_implementation.mustache → Interactor/interactor_implementation.mustache} +0 -0
  44. /data/lib/ccios/templates/{dependency_provider.mustache → Presenter/dependency_provider.mustache} +0 -0
  45. /data/lib/ccios/templates/{presenter.mustache → Presenter/presenter.mustache} +0 -0
  46. /data/lib/ccios/templates/{presenter_assembly.mustache → Presenter/presenter_assembly.mustache} +0 -0
  47. /data/lib/ccios/templates/{presenter_implementation.mustache → Presenter/presenter_implementation.mustache} +0 -0
  48. /data/lib/ccios/templates/{view_contract.mustache → Presenter/view_contract.mustache} +0 -0
  49. /data/lib/ccios/templates/{view_controller.mustache → Presenter/view_controller.mustache} +0 -0
  50. /data/lib/ccios/templates/{repository.mustache → Repository/repository.mustache} +0 -0
  51. /data/lib/ccios/templates/{repository_assembly.mustache → Repository/repository_assembly.mustache} +0 -0
data/lib/ccios.rb CHANGED
@@ -2,67 +2,89 @@ require 'date'
2
2
  require 'xcodeproj'
3
3
  require 'optparse'
4
4
  require 'active_support'
5
- require 'ccios/presenter_generator'
6
- require 'ccios/coordinator_generator'
7
- require 'ccios/interactor_generator'
8
- require 'ccios/repository_generator'
9
5
  require 'ccios/config'
6
+ require 'ccios/template_definition'
7
+ require 'ccios/templates_loader'
10
8
 
9
+ config = Config.parse ".ccios.yml"
10
+ source_path = Dir.pwd
11
+
12
+ templates = TemplatesLoader.new.get_templates(config)
13
+
14
+ subcommands = {}
11
15
  options = {}
12
- OptionParser.new do |opts|
13
- opts.banner = "Usage: ccios [options]"
16
+
17
+ templates.values.each do |template|
18
+ subcommands[template.name] = OptionParser.new do |opts|
19
+
20
+ arguments = template.parameters.select { |p| p.is_a?(ArgumentTemplateParameter) }
21
+ flags = template.parameters.select { |p| p.is_a?(FlagTemplateParameter) }
22
+
23
+ arguments_line = arguments.map { |argument| "<#{argument.name}>" }.join(" ")
24
+
25
+ opts.banner = "Usage: ccios #{template.name} #{arguments_line} [options]"
26
+
27
+ flags.each do |flagParameter|
28
+ if flagParameter.short_name != nil
29
+ opts.on("-#{flagParameter.short_name}", "--#{flagParameter.name}", flagParameter.description) do |v|
30
+ options[flagParameter.template_variable_name] = v
31
+ end
32
+ else
33
+ opts.on("--#{flagParameter.name}", flagParameter.description) do |v|
34
+ options[flagParameter.template_variable_name] = v
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ global_cli = OptionParser.new do |opts|
42
+ opts.banner = "Usage: ccios <template> [options]"
14
43
  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
15
44
  options[:verbose] = v
16
45
  end
17
- opts.on("-pName", "--presenter=Name", "Generate NamePresenter, NamePresenterImplementation, NameViewContract and NameViewController") do |v|
18
- options[:presenter] = v
19
- end
20
- opts.on("-cName", "--coordinator=Name", "Generate NameCoordinator") do |v|
21
- options[:coordinator] = v
22
- end
23
- opts.on("-iName", "--interactor=Name", "Generate NameInteractor and NameInteractorImplementation") do |v|
24
- options[:interactor] = v
25
- end
26
- opts.on("-rName", "--repository=Name", "Generate NameRepository and NameRepositoryImplementation") do |v|
27
- options[:repository] = v
28
- end
29
- opts.on("-d", "--delegate", "Add delegate for curent generation") do |v|
30
- options[:generate_delegate] = v
31
- end
32
46
  opts.on("-h", "--help", "Print this help") do
33
47
  puts opts
48
+ puts "Available templates: #{subcommands.keys.sort.join(", ")}"
34
49
  exit
35
50
  end
36
- end.parse!
51
+ end
37
52
 
38
- source_path = Dir.pwd
39
- config = Config.parse ".ccios.yml"
40
- parser = PBXProjParser.new(source_path, config)
53
+ global_cli.order!
54
+ template_name = ARGV.shift
41
55
 
42
- if options[:presenter]
43
- presenter_name = options[:presenter]
44
- presenter_generator = PresenterGenerator.new(parser, config)
45
- generator_options = {generate_delegate: options[:generate_delegate]}
46
- presenter_generator.generate(presenter_name, generator_options)
56
+ if template_name.nil?
57
+ puts "Error: Missing template name"
58
+ puts global_cli
59
+ exit(1)
47
60
  end
48
61
 
49
- if options[:coordinator]
50
- coordinator_name = options[:coordinator]
51
- coordinator_generator = CoordinatorGenerator.new(parser, config)
52
- generator_options = {generate_delegate: options[:generate_delegate]}
53
- coordinator_generator.generate(coordinator_name, generator_options)
62
+ if subcommands[template_name].nil?
63
+ puts "Error: Unknown template \"#{template_name}\""
64
+ puts global_cli
65
+ exit(1)
54
66
  end
55
67
 
56
- if options[:interactor]
57
- interactor_name = options[:interactor]
58
- interactor_generator = InteractorGenerator.new(parser, config)
59
- interactor_generator.generate(interactor_name)
68
+ template = templates[template_name]
69
+ expected_remaining_arguments = template.parameters.select { |p| p.is_a?(ArgumentTemplateParameter) }
70
+
71
+ subcommands[template_name].order! do |argument|
72
+ expected_argument = expected_remaining_arguments.shift
73
+ if expected_argument.nil?
74
+ puts "Unexpected argument: #{argument}"
75
+ exit 1
76
+ end
77
+ options[expected_argument.template_variable_name] = argument
60
78
  end
61
79
 
62
- if options[:repository]
63
- repository_name = options[:repository]
64
- repository_generator = RepositoryGenerator.new(parser, config)
65
- repository_generator.generate(repository_name)
80
+ if !expected_remaining_arguments.empty?
81
+ puts "Missing arguments: #{expected_remaining_arguments.map { |p| p.name }.join(", ")}"
82
+ exit 1
66
83
  end
67
84
 
85
+ parser = PBXProjParser.new(source_path, config)
86
+
87
+ template.validate(parser, options, config)
88
+ template.generate(parser, options, config)
89
+
68
90
  parser.save
@@ -0,0 +1,41 @@
1
+ //
2
+ // {{name}}Coordinator.swift
3
+ // {{project_name}}
4
+ //
5
+ // Created by {{full_username}} on {{date}}.
6
+ //
7
+ //
8
+
9
+ import Foundation
10
+ import ADCoordinator
11
+
12
+ {{#generate_delegate}}
13
+ @MainActor
14
+ protocol {{name}}CoordinatorDelegate: AnyObject {
15
+
16
+ }
17
+
18
+ {{/generate_delegate}}
19
+ @MainActor
20
+ class {{name}}Coordinator: Coordinator {
21
+
22
+ {{#generate_delegate}}
23
+ weak var delegate: {{name}}CoordinatorDelegate?
24
+ {{/generate_delegate}}
25
+ private let dependencyProvider: ApplicationDependencyProvider
26
+ private unowned var navigationController: UINavigationController
27
+
28
+ nonisolated init(navigationController: UINavigationController,
29
+ dependencyProvider: ApplicationDependencyProvider) {
30
+ self.navigationController = navigationController
31
+ self.dependencyProvider = dependencyProvider
32
+ }
33
+
34
+ // MARK: - Public
35
+
36
+ func start() {
37
+ let viewController = UIViewController()
38
+ navigationController.pushViewController(viewController, animated: false)
39
+ bindToLifecycle(of: viewController)
40
+ }
41
+ }
@@ -0,0 +1,20 @@
1
+ name: "coordinator"
2
+ description: "Generate NameCoordinator"
3
+ variables:
4
+ project: "*.xcodeproj"
5
+ base_path: "Coordinator"
6
+ target: ""
7
+ parameters:
8
+ - argument: "name"
9
+ removeSuffix: "Coordinator"
10
+ - flag: "delegate"
11
+ short_name: "d"
12
+ template_variable_name: "generate_delegate"
13
+ description: "Generate delegate protocols when provided"
14
+ generated_elements:
15
+ - name: "coordinator"
16
+ file: "{{ name }}Coordinator.swift"
17
+ template: "coordinator"
18
+ variables: {}
19
+ template_file_source:
20
+ coordinator: "coordinator.mustache"
@@ -0,0 +1,14 @@
1
+ {{#generate_delegate}}
2
+ func {{lowercased_name}}Presenter(viewContract: {{name}}ViewContract, presenterDelegate: {{name}}PresenterDelegate) -> {{name}}Presenter? {
3
+ return presenterAssembler
4
+ .resolver
5
+ .resolve({{name}}Presenter.self, arguments: viewContract, presenterDelegate)
6
+ }
7
+ {{/generate_delegate}}
8
+ {{^generate_delegate}}
9
+ func {{lowercased_name}}Presenter(viewContract: {{name}}ViewContract) -> {{name}}Presenter? {
10
+ return presenterAssembler
11
+ .resolver
12
+ .resolve({{name}}Presenter.self, argument: viewContract)
13
+ }
14
+ {{/generate_delegate}}
@@ -0,0 +1,21 @@
1
+ //
2
+ // {{name}}Presenter.swift
3
+ // {{project_name}}
4
+ //
5
+ // Created by {{full_username}} on {{date}}.
6
+ //
7
+ //
8
+
9
+ import Foundation
10
+
11
+ @MainActor
12
+ protocol {{name}}Presenter {
13
+ func start()
14
+ }
15
+ {{#generate_delegate}}
16
+
17
+ @MainActor
18
+ protocol {{name}}PresenterDelegate: AnyObject {
19
+
20
+ }
21
+ {{/generate_delegate}}
@@ -0,0 +1,15 @@
1
+ {{#generate_delegate}}
2
+ container.register({{name}}Presenter.self) { _, viewContract, delegate in
3
+ {{name}}PresenterImplementation(
4
+ viewContract: viewContract,
5
+ delegate: delegate
6
+ )
7
+ }
8
+ {{/generate_delegate}}
9
+ {{^generate_delegate}}
10
+ container.register({{name}}Presenter.self) { _, viewContract in
11
+ {{name}}PresenterImplementation(
12
+ viewContract: viewContract
13
+ )
14
+ }
15
+ {{/generate_delegate}}
@@ -0,0 +1,35 @@
1
+ //
2
+ // {{name}}PresenterImplementation.swift
3
+ // {{project_name}}
4
+ //
5
+ // Created by {{full_username}} on {{date}}.
6
+ //
7
+ //
8
+
9
+ import Foundation
10
+
11
+ class {{name}}PresenterImplementation: {{name}}Presenter {
12
+
13
+ private weak var viewContract: {{name}}ViewContract?
14
+ {{#generate_delegate}}
15
+ private weak var delegate: {{name}}PresenterDelegate?
16
+ {{/generate_delegate}}
17
+
18
+ {{#generate_delegate}}
19
+ nonisolated init(viewContract: {{name}}ViewContract, delegate: {{name}}PresenterDelegate) {
20
+ self.viewContract = viewContract
21
+ self.delegate = delegate
22
+ }
23
+ {{/generate_delegate}}
24
+ {{^generate_delegate}}
25
+ nonisolated init(viewContract: {{name}}ViewContract) {
26
+ self.viewContract = viewContract
27
+ }
28
+ {{/generate_delegate}}
29
+
30
+ // MARK: - {{name}}Presenter
31
+
32
+ func start() {
33
+
34
+ }
35
+ }
@@ -0,0 +1,49 @@
1
+ name: "presenter"
2
+ description: "Generate NamePresenter, NamePresenterImplementation, NameViewContract and NameViewController"
3
+ parameters:
4
+ - argument: "name"
5
+ removeSuffix: "Presenter"
6
+ lowercased_variable_name: "lowercased_name"
7
+ - flag: "delegate"
8
+ short_name: "d"
9
+ template_variable_name: "generate_delegate"
10
+ description: "Generate delegate protocols when provided"
11
+ variables:
12
+ project: "*.xcodeproj"
13
+ base_path: "App"
14
+ target: ""
15
+ generated_elements:
16
+ - name: "ui_view_group"
17
+ group: "{{ name }}/UI/View"
18
+ variables: {}
19
+ - name: "view_controller"
20
+ file: "{{ name }}/UI/ViewController/{{ name }}ViewController.swift"
21
+ template: "view_controller"
22
+ variables: {}
23
+ - name: "view_contract"
24
+ file: "{{ name }}/UI/{{ name }}ViewContract.swift"
25
+ template: "view_contract"
26
+ variables: {}
27
+ - name: "presenter"
28
+ file: "{{ name }}/Presenter/{{ name }}Presenter.swift"
29
+ template: "presenter"
30
+ variables: {}
31
+ - name: "presenter_implementation"
32
+ file: "{{ name }}/Presenter/{{ name }}PresenterImplementation.swift"
33
+ template: "presenter_implementation"
34
+ variables: {}
35
+ - name: "model_group"
36
+ group: "{{ name }}/Model"
37
+ variables: {}
38
+ code_snippets:
39
+ - name: DependencyProvider
40
+ template: "dependency_provider"
41
+ - name: PresenterAssembly
42
+ template: "presenter_assembly"
43
+ template_file_source:
44
+ view_controller: "view_controller.mustache"
45
+ view_contract: "view_contract.mustache"
46
+ presenter: "presenter.mustache"
47
+ presenter_implementation: "presenter_implementation.mustache"
48
+ dependency_provider: "dependency_provider.mustache"
49
+ presenter_assembly: "presenter_assembly.mustache"
@@ -0,0 +1,14 @@
1
+ //
2
+ // {{name}}ViewContract.swift
3
+ // {{project_name}}
4
+ //
5
+ // Created by {{full_username}} on {{date}}.
6
+ //
7
+ //
8
+
9
+ import Foundation
10
+
11
+ @MainActor
12
+ protocol {{name}}ViewContract: AnyObject {
13
+
14
+ }
@@ -0,0 +1,23 @@
1
+ //
2
+ // {{name}}ViewController.swift
3
+ // {{project_name}}
4
+ //
5
+ // Created by {{full_username}} on {{date}}.
6
+ //
7
+ //
8
+
9
+ import Foundation
10
+ import UIKit
11
+
12
+ @MainActor
13
+ class {{name}}ViewController: SharedViewController, {{name}}ViewContract {
14
+ var presenter: {{name}}Presenter?
15
+
16
+ override func viewDidLoad() {
17
+ super.viewDidLoad()
18
+ presenter?.start()
19
+ }
20
+
21
+ // MARK: - {{name}}ViewContract
22
+
23
+ }
@@ -0,0 +1 @@
1
+ Default templates are in <root>/lib/ccios/templates
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ccios
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Felgines
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-08-03 00:00:00.000000000 Z
@@ -89,6 +89,7 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - ".github/workflows/ruby.yml"
91
91
  - ".gitignore"
92
+ - ".ruby-version"
92
93
  - CHANGELOG.md
93
94
  - Gemfile
94
95
  - Gemfile.lock
@@ -98,32 +99,49 @@ files:
98
99
  - bin/ccios
99
100
  - ccios.gemspec
100
101
  - lib/ccios.rb
102
+ - lib/ccios/argument_template_parameter.rb
101
103
  - lib/ccios/code_templater.rb
102
104
  - lib/ccios/config.rb
103
- - lib/ccios/coordinator_generator.rb
104
105
  - lib/ccios/file_creator.rb
105
- - lib/ccios/interactor_generator.rb
106
+ - lib/ccios/file_template_definition.rb
107
+ - lib/ccios/flag_template_parameter.rb
108
+ - lib/ccios/group_template_definition.rb
106
109
  - lib/ccios/pbxproj_parser.rb
107
- - lib/ccios/presenter_generator.rb
108
- - lib/ccios/repository_generator.rb
109
- - lib/ccios/templates/coordinator.mustache
110
- - lib/ccios/templates/dependency_provider.mustache
111
- - lib/ccios/templates/interactor.mustache
112
- - lib/ccios/templates/interactor_assembly.mustache
113
- - lib/ccios/templates/interactor_implementation.mustache
114
- - lib/ccios/templates/presenter.mustache
115
- - lib/ccios/templates/presenter_assembly.mustache
116
- - lib/ccios/templates/presenter_implementation.mustache
117
- - lib/ccios/templates/repository.mustache
118
- - lib/ccios/templates/repository_assembly.mustache
119
- - lib/ccios/templates/repository_implementation.mustache
120
- - lib/ccios/templates/view_contract.mustache
121
- - lib/ccios/templates/view_controller.mustache
110
+ - lib/ccios/snippet_template_definition.rb
111
+ - lib/ccios/template_definition.rb
112
+ - lib/ccios/templates/Coordinator/coordinator.mustache
113
+ - lib/ccios/templates/Coordinator/template.yml
114
+ - lib/ccios/templates/Interactor/interactor.mustache
115
+ - lib/ccios/templates/Interactor/interactor_assembly.mustache
116
+ - lib/ccios/templates/Interactor/interactor_implementation.mustache
117
+ - lib/ccios/templates/Interactor/template.yml
118
+ - lib/ccios/templates/Presenter/dependency_provider.mustache
119
+ - lib/ccios/templates/Presenter/presenter.mustache
120
+ - lib/ccios/templates/Presenter/presenter_assembly.mustache
121
+ - lib/ccios/templates/Presenter/presenter_implementation.mustache
122
+ - lib/ccios/templates/Presenter/template.yml
123
+ - lib/ccios/templates/Presenter/view_contract.mustache
124
+ - lib/ccios/templates/Presenter/view_controller.mustache
125
+ - lib/ccios/templates/Repository/repository.mustache
126
+ - lib/ccios/templates/Repository/repository_assembly.mustache
127
+ - lib/ccios/templates/Repository/repository_implementation.mustache
128
+ - lib/ccios/templates/Repository/template.yml
129
+ - lib/ccios/templates_loader.rb
130
+ - templates_library/async/Coordinator/coordinator.mustache
131
+ - templates_library/async/Coordinator/template.yml
132
+ - templates_library/async/Presenter/dependency_provider.mustache
133
+ - templates_library/async/Presenter/presenter.mustache
134
+ - templates_library/async/Presenter/presenter_assembly.mustache
135
+ - templates_library/async/Presenter/presenter_implementation.mustache
136
+ - templates_library/async/Presenter/template.yml
137
+ - templates_library/async/Presenter/view_contract.mustache
138
+ - templates_library/async/Presenter/view_controller.mustache
139
+ - templates_library/default/README.md
122
140
  homepage: http://rubygems.org/gems/hola
123
141
  licenses:
124
142
  - MIT
125
143
  metadata: {}
126
- post_install_message:
144
+ post_install_message:
127
145
  rdoc_options: []
128
146
  require_paths:
129
147
  - lib
@@ -138,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
156
  - !ruby/object:Gem::Version
139
157
  version: '0'
140
158
  requirements: []
141
- rubygems_version: 3.0.3
142
- signing_key:
159
+ rubygems_version: 3.5.6
160
+ signing_key:
143
161
  specification_version: 4
144
162
  summary: Clean Code iOS Generator
145
163
  test_files: []
@@ -1,18 +0,0 @@
1
- require_relative 'file_creator'
2
- require_relative "pbxproj_parser"
3
-
4
- class CoordinatorGenerator
5
-
6
- def initialize(parser, config)
7
- @parser = parser
8
- @config = config
9
- end
10
-
11
- def generate(coordinator_name, options = {})
12
- coordinator_group = @parser.coordinator_group
13
- file_creator = FileCreator.new(options)
14
- target = @parser.app_target
15
- coordinator_name = coordinator_name.gsub("Coordinator", "")
16
- file_creator.create_file(coordinator_name, 'Coordinator', coordinator_group, target)
17
- end
18
- end
@@ -1,33 +0,0 @@
1
- require_relative 'file_creator'
2
- require_relative "pbxproj_parser"
3
-
4
- class InteractorGenerator
5
-
6
- def initialize(parser, config)
7
- @parser = parser
8
- @config = config
9
- end
10
-
11
- def generate(interactor_name, options = {})
12
- interactor_group = @parser.interactor_group
13
- interactor_name = interactor_name.gsub("Interactor", "")
14
- new_group_name = "#{interactor_name}Interactor"
15
-
16
- associate_path_to_group = !interactor_group.path.nil?
17
-
18
- raise "[Error] Group #{new_group_name} already exists in #{app_group.display_name}" if interactor_group[new_group_name]
19
- new_group_path = File.join(interactor_group.real_path, new_group_name)
20
- new_group = interactor_group.pf_new_group(
21
- associate_path_to_group: associate_path_to_group,
22
- name: new_group_name,
23
- path: new_group_path
24
- )
25
-
26
- file_creator = FileCreator.new(options)
27
- target = @parser.core_target
28
- file_creator.create_file(interactor_name, 'Interactor', new_group, target)
29
- file_creator.create_file(interactor_name, 'InteractorImplementation', new_group, target)
30
-
31
- file_creator.print_file_content(interactor_name, 'InteractorAssembly')
32
- end
33
- end
@@ -1,71 +0,0 @@
1
- require_relative 'file_creator'
2
- require_relative "pbxproj_parser"
3
-
4
- class PresenterGenerator
5
-
6
- def initialize(parser, config)
7
- @parser = parser
8
- @config = config
9
- end
10
-
11
- def generate(presenter_name, options = {})
12
- app_group = @parser.presenter_group
13
- presenter_name = presenter_name.gsub("Presenter", "")
14
- associate_path_to_group = !app_group.path.nil?
15
-
16
- raise "[Error] Group #{presenter_name} already exists in #{app_group.display_name}" if app_group[presenter_name]
17
- new_group_path = File.join(app_group.real_path, presenter_name)
18
- new_group = app_group.pf_new_group(
19
- associate_path_to_group: associate_path_to_group,
20
- name: presenter_name,
21
- path: new_group_path
22
- )
23
-
24
- ui_group_path = File.join(new_group_path, "UI")
25
- ui_group = new_group.pf_new_group(
26
- associate_path_to_group: associate_path_to_group,
27
- name: "UI",
28
- path: ui_group_path
29
- )
30
-
31
- view_group_path = File.join(ui_group_path, "View")
32
- view_group = ui_group.pf_new_group(
33
- associate_path_to_group: associate_path_to_group,
34
- name: "View",
35
- path: view_group_path
36
- )
37
-
38
- view_controller_group_path = File.join(ui_group_path, "ViewController")
39
- view_controller_group = ui_group.pf_new_group(
40
- associate_path_to_group: associate_path_to_group,
41
- name: "ViewController",
42
- path: view_controller_group_path
43
- )
44
-
45
- presenter_group_path = File.join(new_group_path, "Presenter")
46
- presenter_group = new_group.pf_new_group(
47
- associate_path_to_group: associate_path_to_group,
48
- name: "Presenter",
49
- path: presenter_group_path
50
- )
51
-
52
- model_group_path = File.join(new_group_path, "Model")
53
- model_group = new_group.pf_new_group(
54
- associate_path_to_group: associate_path_to_group,
55
- name: "Model",
56
- path: model_group_path
57
- )
58
-
59
- file_creator = FileCreator.new(options)
60
- target = @parser.app_target
61
- file_creator.create_file(presenter_name, 'ViewContract', ui_group, target)
62
- file_creator.create_file(presenter_name, 'ViewController', view_controller_group, target)
63
- file_creator.create_file(presenter_name, 'Presenter', presenter_group, target)
64
- file_creator.create_file(presenter_name, 'PresenterImplementation', presenter_group, target)
65
- file_creator.create_empty_directory(model_group)
66
- file_creator.create_empty_directory(view_group)
67
-
68
- file_creator.print_file_content(presenter_name, 'DependencyProvider')
69
- file_creator.print_file_content(presenter_name, 'PresenterAssembly')
70
- end
71
- end
@@ -1,44 +0,0 @@
1
- require_relative 'file_creator'
2
- require_relative "pbxproj_parser"
3
-
4
- class RepositoryGenerator
5
-
6
- def initialize(parser, config)
7
- @parser = parser
8
- @config = config
9
- end
10
-
11
- def generate(repository_name, options = {})
12
- core_group = @parser.repository_core_group
13
- data_group = @parser.repository_data_group
14
- repository_name = repository_name.gsub("Repository", "")
15
-
16
- raise "[Error] Group #{repository_name} already exists in #{core_group.display_name}" if core_group[repository_name]
17
- associate_path_to_group = !core_group.path.nil?
18
- core_data_new_group_path = File.join(core_group.real_path, repository_name)
19
- core_data_new_group = core_group.pf_new_group(
20
- associate_path_to_group: associate_path_to_group,
21
- name: repository_name,
22
- path: core_data_new_group_path
23
- )
24
-
25
- raise "[Error] Group #{repository_name} already exists in #{data_group.display_name}" if data_group[repository_name]
26
- associate_path_to_group = !data_group.path.nil?
27
- data_new_group_path = File.join(data_group.real_path, repository_name)
28
- data_new_group = data_group.pf_new_group(
29
- associate_path_to_group: associate_path_to_group,
30
- name: repository_name,
31
- path: data_new_group_path
32
- )
33
-
34
- file_creator = FileCreator.new(options)
35
- core_target = @parser.core_target
36
- file_creator.create_file(repository_name, 'Repository', core_data_new_group, core_target)
37
-
38
- file_creator = FileCreator.new(options)
39
- data_target = @parser.data_target
40
- file_creator.create_file(repository_name, 'RepositoryImplementation', data_new_group, data_target)
41
-
42
- file_creator.print_file_content(repository_name, 'RepositoryAssembly')
43
- end
44
- end