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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +31 -0
- data/Gemfile.lock +13 -12
- data/README.md +188 -51
- data/ccios.gemspec +1 -1
- data/lib/ccios/argument_template_parameter.rb +33 -0
- data/lib/ccios/code_templater.rb +24 -7
- data/lib/ccios/config.rb +45 -78
- data/lib/ccios/file_creator.rb +24 -21
- data/lib/ccios/file_template_definition.rb +94 -0
- data/lib/ccios/flag_template_parameter.rb +17 -0
- data/lib/ccios/group_template_definition.rb +54 -0
- data/lib/ccios/pbxproj_parser.rb +3 -54
- data/lib/ccios/snippet_template_definition.rb +27 -0
- data/lib/ccios/template_definition.rb +116 -0
- data/lib/ccios/templates/Coordinator/template.yml +20 -0
- data/lib/ccios/templates/Interactor/template.yml +25 -0
- data/lib/ccios/templates/Presenter/template.yml +49 -0
- data/lib/ccios/templates/{repository_implementation.mustache → Repository/repository_implementation.mustache} +0 -1
- data/lib/ccios/templates/Repository/template.yml +26 -0
- data/lib/ccios/templates_loader.rb +31 -0
- data/lib/ccios.rb +65 -43
- data/templates_library/async/Coordinator/coordinator.mustache +41 -0
- data/templates_library/async/Coordinator/template.yml +20 -0
- data/templates_library/async/Presenter/dependency_provider.mustache +14 -0
- data/templates_library/async/Presenter/presenter.mustache +21 -0
- data/templates_library/async/Presenter/presenter_assembly.mustache +15 -0
- data/templates_library/async/Presenter/presenter_implementation.mustache +35 -0
- data/templates_library/async/Presenter/template.yml +49 -0
- data/templates_library/async/Presenter/view_contract.mustache +14 -0
- data/templates_library/async/Presenter/view_controller.mustache +23 -0
- data/templates_library/default/README.md +1 -0
- metadata +40 -22
- data/lib/ccios/coordinator_generator.rb +0 -18
- data/lib/ccios/interactor_generator.rb +0 -33
- data/lib/ccios/presenter_generator.rb +0 -71
- data/lib/ccios/repository_generator.rb +0 -44
- /data/lib/ccios/templates/{coordinator.mustache → Coordinator/coordinator.mustache} +0 -0
- /data/lib/ccios/templates/{interactor.mustache → Interactor/interactor.mustache} +0 -0
- /data/lib/ccios/templates/{interactor_assembly.mustache → Interactor/interactor_assembly.mustache} +0 -0
- /data/lib/ccios/templates/{interactor_implementation.mustache → Interactor/interactor_implementation.mustache} +0 -0
- /data/lib/ccios/templates/{dependency_provider.mustache → Presenter/dependency_provider.mustache} +0 -0
- /data/lib/ccios/templates/{presenter.mustache → Presenter/presenter.mustache} +0 -0
- /data/lib/ccios/templates/{presenter_assembly.mustache → Presenter/presenter_assembly.mustache} +0 -0
- /data/lib/ccios/templates/{presenter_implementation.mustache → Presenter/presenter_implementation.mustache} +0 -0
- /data/lib/ccios/templates/{view_contract.mustache → Presenter/view_contract.mustache} +0 -0
- /data/lib/ccios/templates/{view_controller.mustache → Presenter/view_controller.mustache} +0 -0
- /data/lib/ccios/templates/{repository.mustache → Repository/repository.mustache} +0 -0
- /data/lib/ccios/templates/{repository_assembly.mustache → Repository/repository_assembly.mustache} +0 -0
data/lib/ccios/file_creator.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative 'code_templater'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'logger'
|
4
|
+
require 'xcodeproj'
|
4
5
|
|
5
6
|
class Xcodeproj::Project::Object::PBXGroup
|
6
7
|
|
@@ -24,39 +25,51 @@ class FileCreator
|
|
24
25
|
FileCreator.logger
|
25
26
|
end
|
26
27
|
|
27
|
-
def initialize(options = {})
|
28
|
-
@options = options
|
29
|
-
end
|
30
|
-
|
31
28
|
def templater_options(target)
|
32
29
|
defaults = {
|
33
30
|
project_name: target.display_name,
|
34
31
|
full_username: git_username,
|
35
32
|
date: DateTime.now.strftime("%d/%m/%Y"),
|
36
33
|
}
|
37
|
-
defaults
|
34
|
+
defaults
|
38
35
|
end
|
39
36
|
|
40
37
|
def git_username
|
41
38
|
`git config user.name`.strip
|
42
39
|
end
|
43
40
|
|
44
|
-
def
|
45
|
-
|
41
|
+
def get_unknown_template_tags_for(template_path)
|
42
|
+
tags = CodeTemplater.new.get_unknown_context_keys_for_template(template_path)
|
43
|
+
tags.subtract(Set["project_name", "full_username", "date"])
|
44
|
+
tags
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_file_using_template_path(template_path, generated_filename, group, targets, context)
|
48
|
+
file_path = File.join(group.real_path, generated_filename)
|
46
49
|
|
47
50
|
raise "File #{file_path} already exists" if File.exist?(file_path)
|
48
51
|
dirname = File.dirname(file_path)
|
49
52
|
FileUtils.mkdir_p dirname unless File.directory?(dirname)
|
50
53
|
file = File.new(file_path, 'w')
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
context = context.merge(templater_options(targets[0]))
|
56
|
+
file_content = CodeTemplater.new.render_file_content_from_template(template_path, generated_filename, context)
|
57
|
+
|
55
58
|
file.puts(file_content)
|
56
59
|
|
57
60
|
file.close
|
58
61
|
file_ref = group.new_reference(file_path)
|
59
|
-
target
|
62
|
+
targets.each do |target|
|
63
|
+
target.add_file_references([file_ref])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def print_file_content_using_template(filename, template_path, context)
|
68
|
+
file_content = CodeTemplater.new.render_file_content_from_template(template_path, filename, context)
|
69
|
+
Mustache.render(File.read(template_path), context)
|
70
|
+
|
71
|
+
logger.info "Add this snippet to #{filename}"
|
72
|
+
logger.info file_content
|
60
73
|
end
|
61
74
|
|
62
75
|
def create_empty_directory(group)
|
@@ -67,16 +80,6 @@ class FileCreator
|
|
67
80
|
FileUtils.touch(git_keep_path) if Dir.empty?(dirname)
|
68
81
|
end
|
69
82
|
|
70
|
-
def print_file_content(prefix, suffix)
|
71
|
-
file_name = suffix + '.swift'
|
72
|
-
|
73
|
-
code_templater = CodeTemplater.new(@options)
|
74
|
-
template = code_templater.content_for_suffix(prefix, suffix)
|
75
|
-
|
76
|
-
logger.info "Add this snippet to #{file_name}"
|
77
|
-
logger.info template
|
78
|
-
end
|
79
|
-
|
80
83
|
private
|
81
84
|
|
82
85
|
def self.create_logger
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require_relative 'code_templater'
|
2
|
+
require_relative 'file_creator'
|
3
|
+
require_relative 'pbxproj_parser'
|
4
|
+
|
5
|
+
class FileTemplateDefinition
|
6
|
+
def initialize(file_template_definition_hash)
|
7
|
+
@name = file_template_definition_hash["name"]
|
8
|
+
@path = file_template_definition_hash["file"]
|
9
|
+
@template = file_template_definition_hash["template"]
|
10
|
+
@variables = file_template_definition_hash["variables"] || {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate(parser, project, context, template_definition, config)
|
14
|
+
|
15
|
+
merged_variables = config.variables_for_template_element(template_definition, @name, @variables)
|
16
|
+
|
17
|
+
code_templater = CodeTemplater.new
|
18
|
+
expected_context_keys = template_definition.provided_context_keys
|
19
|
+
pathTags = code_templater.get_unknown_context_keys_for_string(@path)
|
20
|
+
pathTags.each do |tag|
|
21
|
+
raise "Unknown parameter \"#{tag}\" in path \"#{@path}\"" unless expected_context_keys.include?(tag)
|
22
|
+
end
|
23
|
+
|
24
|
+
file_path = code_templater.render_string(@path, context)
|
25
|
+
raise "File #{file_path} already exists" if File.exist?(file_path)
|
26
|
+
|
27
|
+
file_creator = FileCreator.new
|
28
|
+
contentTags = file_creator.get_unknown_template_tags_for(template_definition.template_source_file(@template))
|
29
|
+
contentTags.each do |tag|
|
30
|
+
raise "Unknown parameter \"#{tag}\" in template \"#{@template}\"" unless expected_context_keys.include?(tag)
|
31
|
+
end
|
32
|
+
|
33
|
+
base_path = merged_variables["base_path"]
|
34
|
+
raise "Missing base_path variable" if base_path.nil?
|
35
|
+
|
36
|
+
base_group = project[base_path]
|
37
|
+
raise "Base path \"#{base_path}\" is missing" if base_group.nil?
|
38
|
+
|
39
|
+
target_name = merged_variables["target"]
|
40
|
+
if target_name.is_a?(String)
|
41
|
+
target = parser.target_for(project, target_name)
|
42
|
+
raise "Unable to find target \"#{target_name}\"" if target.nil?
|
43
|
+
elsif target_name.is_a?(Array)
|
44
|
+
target_name.each do |target_name|
|
45
|
+
target = parser.target_for(project, target_name)
|
46
|
+
raise "Unable to find target \"#{target_name}\"" if target.nil?
|
47
|
+
end
|
48
|
+
else
|
49
|
+
raise "Invalid target in template #{@name}"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate(parser, project, context, template_definition, config)
|
55
|
+
merged_variables = config.variables_for_template_element(template_definition, @name, @variables)
|
56
|
+
|
57
|
+
base_path = merged_variables["base_path"]
|
58
|
+
base_group = project[base_path]
|
59
|
+
file_path = CodeTemplater.new.render_string(@path, context)
|
60
|
+
|
61
|
+
intermediates_groups = file_path.split("/")[0...-1]
|
62
|
+
generated_filename = file_path.split("/")[-1]
|
63
|
+
|
64
|
+
group = base_group
|
65
|
+
associate_path_to_group = !base_group.path.nil?
|
66
|
+
|
67
|
+
intermediates_groups.each do |group_name|
|
68
|
+
new_group_path = File.join(group.real_path, group_name)
|
69
|
+
existing_group = group.groups.find { |g| g.display_name == group_name }
|
70
|
+
group = existing_group || group.pf_new_group(
|
71
|
+
associate_path_to_group: associate_path_to_group,
|
72
|
+
name: group_name,
|
73
|
+
path: new_group_path
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
target_name = merged_variables["target"]
|
78
|
+
|
79
|
+
targets = []
|
80
|
+
if target_name.is_a?(String)
|
81
|
+
targets = [parser.target_for(project, target_name)]
|
82
|
+
elsif target_name.is_a?(Array)
|
83
|
+
targets = target_name.map { |name| parser.target_for(project, name) }
|
84
|
+
end
|
85
|
+
|
86
|
+
FileCreator.new.create_file_using_template_path(
|
87
|
+
template_definition.template_source_file(@template),
|
88
|
+
generated_filename,
|
89
|
+
group,
|
90
|
+
targets,
|
91
|
+
context
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class FlagTemplateParameter
|
2
|
+
attr_reader :name, :short_name, :description, :template_variable_name
|
3
|
+
|
4
|
+
def initialize(parameter_template_definition_hash)
|
5
|
+
@name = parameter_template_definition_hash["flag"]
|
6
|
+
@short_name = parameter_template_definition_hash["short_name"]
|
7
|
+
@description = parameter_template_definition_hash["description"] || ""
|
8
|
+
@template_variable_name = parameter_template_definition_hash["template_variable_name"] || @name
|
9
|
+
|
10
|
+
raise "Missing flag name" if @name.nil? || @name.empty?
|
11
|
+
raise "Invalid flag template_variable_name for #{@name}" if @template_variable_name.nil? || template_variable_name.empty?
|
12
|
+
end
|
13
|
+
|
14
|
+
def provided_context_keys
|
15
|
+
[@template_variable_name]
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative 'code_templater'
|
2
|
+
require_relative 'file_creator'
|
3
|
+
require_relative 'pbxproj_parser'
|
4
|
+
|
5
|
+
class GroupTemplateDefinition
|
6
|
+
def initialize(group_template_definition_hash)
|
7
|
+
@name = group_template_definition_hash["name"]
|
8
|
+
@path = group_template_definition_hash["group"]
|
9
|
+
@template = group_template_definition_hash["path"]
|
10
|
+
@variables = group_template_definition_hash["variables"] || {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate(parser, project, context, template_definition, config)
|
14
|
+
merged_variables = config.variables_for_template_element(template_definition, @name, @variables)
|
15
|
+
|
16
|
+
code_templater = CodeTemplater.new
|
17
|
+
pathTags = code_templater.get_unknown_context_keys_for_string(@path)
|
18
|
+
pathTags.each do |tag|
|
19
|
+
raise "Unknown parameter \"#{tag}\" in path \"#{@path}\"" if context[tag].nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
base_path = merged_variables["base_path"]
|
23
|
+
raise "Missing base_path variable" if base_path.nil?
|
24
|
+
|
25
|
+
base_group = project[base_path]
|
26
|
+
raise "Base path \"#{base_path}\" is missing" if base_group.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
def generate(parser, project, context, template_definition, config)
|
30
|
+
merged_variables = config.variables_for_template_element(template_definition, @name, @variables)
|
31
|
+
|
32
|
+
base_path = merged_variables["base_path"]
|
33
|
+
base_group = project[base_path]
|
34
|
+
group_path = CodeTemplater.new.render_string(@path, context)
|
35
|
+
|
36
|
+
group_path = group_path.split("/")
|
37
|
+
|
38
|
+
group = base_group
|
39
|
+
associate_path_to_group = !base_group.path.nil?
|
40
|
+
|
41
|
+
group_path.each do |group_name|
|
42
|
+
new_group_path = File.join(group.real_path, group_name)
|
43
|
+
existing_group = group.groups.find { |g| g.display_name == group_name }
|
44
|
+
group = existing_group || group.pf_new_group(
|
45
|
+
associate_path_to_group: associate_path_to_group,
|
46
|
+
name: group_name,
|
47
|
+
path: new_group_path
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
file_creator = FileCreator.new
|
52
|
+
file_creator.create_empty_directory(group)
|
53
|
+
end
|
54
|
+
end
|
data/lib/ccios/pbxproj_parser.rb
CHANGED
@@ -11,63 +11,12 @@ class PBXProjParser
|
|
11
11
|
@projects = {}
|
12
12
|
end
|
13
13
|
|
14
|
-
def app_project
|
15
|
-
project_for(@config.app.project)
|
16
|
-
end
|
17
|
-
|
18
|
-
def core_project
|
19
|
-
project_for(@config.core.project)
|
20
|
-
end
|
21
|
-
|
22
|
-
def data_project
|
23
|
-
project_for(@config.data.project)
|
24
|
-
end
|
25
|
-
|
26
|
-
def presenter_group
|
27
|
-
path = @config.app.presenter.group
|
28
|
-
app_project[path]
|
29
|
-
end
|
30
|
-
|
31
|
-
def coordinator_group
|
32
|
-
path = @config.app.coordinator.group
|
33
|
-
app_project[path]
|
34
|
-
end
|
35
|
-
|
36
|
-
def interactor_group
|
37
|
-
path = @config.core.interactor.group
|
38
|
-
core_project[path]
|
39
|
-
end
|
40
|
-
|
41
|
-
def repository_core_group
|
42
|
-
path = @config.core.repository.group
|
43
|
-
core_project[path]
|
44
|
-
end
|
45
|
-
|
46
|
-
def repository_data_group
|
47
|
-
path = @config.data.repository.group
|
48
|
-
data_project[path]
|
49
|
-
end
|
50
|
-
|
51
|
-
def app_target
|
52
|
-
target_for(app_project, @config.app.target)
|
53
|
-
end
|
54
|
-
|
55
|
-
def core_target
|
56
|
-
target_for(core_project, @config.core.target)
|
57
|
-
end
|
58
|
-
|
59
|
-
def data_target
|
60
|
-
target_for(data_project, @config.data.target)
|
61
|
-
end
|
62
|
-
|
63
14
|
def save
|
64
|
-
|
65
|
-
|
66
|
-
|
15
|
+
@projects.each do |path, value|
|
16
|
+
value.save
|
17
|
+
end
|
67
18
|
end
|
68
19
|
|
69
|
-
private
|
70
|
-
|
71
20
|
def project_for(path)
|
72
21
|
module_project_path = File.join(source_path, path)
|
73
22
|
resolved_module_project_path = Dir.glob(module_project_path).first
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'file_creator'
|
2
|
+
|
3
|
+
class SnippetTemplateDefinition
|
4
|
+
def initialize(snippet_template_definition_hash)
|
5
|
+
@name = snippet_template_definition_hash["name"]
|
6
|
+
@template = snippet_template_definition_hash["template"]
|
7
|
+
end
|
8
|
+
|
9
|
+
def validate(template_definition)
|
10
|
+
expected_context_keys = template_definition.provided_context_keys
|
11
|
+
file_creator = FileCreator.new
|
12
|
+
contentTags = file_creator.get_unknown_template_tags_for(template_definition.template_source_file(@template))
|
13
|
+
contentTags.each do |tag|
|
14
|
+
raise "Unknown parameter \"#{tag}\" in template \"#{@template}\"" unless expected_context_keys.include?(tag)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate(context, template_definition)
|
19
|
+
|
20
|
+
file_creator = FileCreator.new
|
21
|
+
file_creator.print_file_content_using_template(
|
22
|
+
@name,
|
23
|
+
template_definition.template_source_file(@template),
|
24
|
+
context
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
require_relative 'file_creator'
|
4
|
+
require_relative 'pbxproj_parser'
|
5
|
+
require_relative 'argument_template_parameter'
|
6
|
+
require_relative 'flag_template_parameter'
|
7
|
+
require_relative 'file_template_definition'
|
8
|
+
require_relative 'group_template_definition'
|
9
|
+
require_relative 'snippet_template_definition'
|
10
|
+
|
11
|
+
class TemplateDefinition
|
12
|
+
|
13
|
+
attr_reader :name, :description, :template_path, :template_file_source, :parameters, :variables
|
14
|
+
|
15
|
+
def self.parse(template_path)
|
16
|
+
template_definition = File.join(template_path, 'template.yml')
|
17
|
+
if File.exist?(template_definition)
|
18
|
+
template_definition = YAML.load_file(template_definition)
|
19
|
+
self.new template_definition, template_path
|
20
|
+
else
|
21
|
+
puts "Template #{template_path} is invalid: file #{template_definition} not found."
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(template_definition_hash, template_path)
|
27
|
+
@template_definition_hash = template_definition_hash
|
28
|
+
@template_path = template_path
|
29
|
+
|
30
|
+
@name = template_definition_hash["name"]
|
31
|
+
@description = template_definition_hash["description"] || ""
|
32
|
+
@variables = template_definition_hash["variables"] || {}
|
33
|
+
|
34
|
+
@parameters = template_definition_hash["parameters"].map { |hash|
|
35
|
+
next ArgumentTemplateParameter.new(hash) unless hash["argument"].nil?
|
36
|
+
next FlagTemplateParameter.new(hash) unless hash["flag"].nil?
|
37
|
+
}.compact
|
38
|
+
|
39
|
+
@generated_elements = template_definition_hash["generated_elements"].map { |hash|
|
40
|
+
next FileTemplateDefinition.new(hash) unless hash["file"].nil?
|
41
|
+
next GroupTemplateDefinition.new(hash) unless hash["group"].nil?
|
42
|
+
next nil
|
43
|
+
}.compact
|
44
|
+
|
45
|
+
if template_definition_hash["code_snippets"].nil?
|
46
|
+
@snippets = []
|
47
|
+
else
|
48
|
+
@snippets = template_definition_hash["code_snippets"].map { |hash|
|
49
|
+
SnippetTemplateDefinition.new(hash)
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
@template_file_source = template_definition_hash["template_file_source"] || {}
|
54
|
+
end
|
55
|
+
|
56
|
+
def validate(parser, options, config)
|
57
|
+
|
58
|
+
raise "Error: missing name in template" if @name.nil?
|
59
|
+
raise "Error: invalid template name" unless @name.is_a? String
|
60
|
+
|
61
|
+
merged_variables = config.variables_for_template(self)
|
62
|
+
project_path = merged_variables["project"]
|
63
|
+
|
64
|
+
project = parser.project_for(project_path)
|
65
|
+
raise "Error: Unable to find project \"#{project_path}\"" if project.nil?
|
66
|
+
|
67
|
+
@template_file_source.each do |file_template_name, path|
|
68
|
+
raise "Missing template source file for \"#{file_template_name}\"" unless File.exist?(self.template_source_file(file_template_name))
|
69
|
+
end
|
70
|
+
|
71
|
+
options = agrument_transformed_options(options)
|
72
|
+
|
73
|
+
@generated_elements.each do |generated_element|
|
74
|
+
generated_element.validate(parser, project, options, self, config)
|
75
|
+
end
|
76
|
+
|
77
|
+
@snippets.each do |snippet|
|
78
|
+
snippet.validate(self)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def template_source_file(name)
|
83
|
+
raise "Unknown template file #{name}" if @template_file_source[name].nil?
|
84
|
+
File.join(@template_path, @template_file_source[name])
|
85
|
+
end
|
86
|
+
|
87
|
+
def provided_context_keys
|
88
|
+
@parameters.flat_map { |p| p.provided_context_keys }.to_set
|
89
|
+
end
|
90
|
+
|
91
|
+
def generate(parser, options, config)
|
92
|
+
|
93
|
+
options = agrument_transformed_options(options)
|
94
|
+
|
95
|
+
merged_variables = config.variables_for_template(self)
|
96
|
+
project_path = merged_variables["project"]
|
97
|
+
|
98
|
+
project = parser.project_for project_path
|
99
|
+
|
100
|
+
@generated_elements.each do |element|
|
101
|
+
element.generate(parser, project, options, self, config)
|
102
|
+
end
|
103
|
+
|
104
|
+
@snippets.each do |snippet|
|
105
|
+
snippet.generate(options, self)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def agrument_transformed_options(options)
|
110
|
+
@parameters.select { |p| p.is_a? ArgumentTemplateParameter }.each do |argument|
|
111
|
+
options = argument.update_context(options)
|
112
|
+
end
|
113
|
+
options
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -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,25 @@
|
|
1
|
+
name: "interactor"
|
2
|
+
description: "Generate NameInteractor and NameInteractorImplementation"
|
3
|
+
parameters:
|
4
|
+
- argument: "name"
|
5
|
+
removeSuffix: "Interactor"
|
6
|
+
variables:
|
7
|
+
project: "*.xcodeproj"
|
8
|
+
base_path: "Core/Interactor"
|
9
|
+
target: ""
|
10
|
+
generated_elements:
|
11
|
+
- name: "interactor"
|
12
|
+
file: "{{ name }}Interactor/{{ name }}Interactor.swift"
|
13
|
+
template: "interactor"
|
14
|
+
variables: {}
|
15
|
+
- name: "interactor_implementation"
|
16
|
+
file: "{{ name }}Interactor/{{ name }}InteractorImplementation.swift"
|
17
|
+
template: "interactor_implementation"
|
18
|
+
variables: {}
|
19
|
+
code_snippets:
|
20
|
+
- name: InteractorAssembly
|
21
|
+
template: "interactor_assembly"
|
22
|
+
template_file_source:
|
23
|
+
interactor: "interactor.mustache"
|
24
|
+
interactor_implementation: "interactor_implementation.mustache"
|
25
|
+
interactor_assembly: "interactor_assembly.mustache"
|
@@ -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,26 @@
|
|
1
|
+
name: "repository"
|
2
|
+
description: "Generate NameRepository and NameRepositoryImplementation"
|
3
|
+
parameters:
|
4
|
+
- argument: "name"
|
5
|
+
removeSuffix: "Repository"
|
6
|
+
variables:
|
7
|
+
project: "*.xcodeproj"
|
8
|
+
target: ""
|
9
|
+
generated_elements:
|
10
|
+
- name: "repository"
|
11
|
+
file: "{{ name }}/{{ name }}Repository.swift"
|
12
|
+
template: "repository"
|
13
|
+
variables:
|
14
|
+
base_path: "Core/Data"
|
15
|
+
- name: "repository_implementation"
|
16
|
+
file: "{{ name }}/{{ name }}RepositoryImplementation.swift"
|
17
|
+
template: "repository_implementation"
|
18
|
+
variables:
|
19
|
+
base_path: "Data"
|
20
|
+
code_snippets:
|
21
|
+
- name: RepositoryAssembly
|
22
|
+
template: "repository_assembly"
|
23
|
+
template_file_source:
|
24
|
+
repository: "repository.mustache"
|
25
|
+
repository_implementation: "repository_implementation.mustache"
|
26
|
+
repository_assembly: "repository_assembly.mustache"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'config'
|
2
|
+
require_relative 'template_definition'
|
3
|
+
|
4
|
+
class TemplatesLoader
|
5
|
+
|
6
|
+
def get_templates(config)
|
7
|
+
default_template_folder = File.join(File.dirname(__FILE__), "templates")
|
8
|
+
default_templates = load_templates_from_collection(default_template_folder)
|
9
|
+
custom_templates = []
|
10
|
+
if !config.templates_collection.nil?
|
11
|
+
custom_templates = load_templates_from_collection(config.templates_collection)
|
12
|
+
end
|
13
|
+
templates = {}
|
14
|
+
all_templates = default_templates + custom_templates
|
15
|
+
all_templates.each do |template|
|
16
|
+
templates[template.name] = template
|
17
|
+
end
|
18
|
+
Hash[templates.sort_by{|k,v| k}]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def load_templates_from_collection(collection_path)
|
24
|
+
template_paths = Dir.children(collection_path)
|
25
|
+
.map { |name| File.join(collection_path, name) }
|
26
|
+
.select { |path| File.directory? path }
|
27
|
+
template_paths
|
28
|
+
.map { |template_path| TemplateDefinition.parse(template_path) }
|
29
|
+
.compact
|
30
|
+
end
|
31
|
+
end
|