generamba 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +10 -0
- data/.gitignore +1 -0
- data/.travis.yml +15 -3
- data/CHANGELOG.md +43 -44
- data/README.md +1 -1
- data/lib/generamba/cli/gen_command.rb +12 -9
- data/lib/generamba/cli/setup_command.rb +42 -32
- data/lib/generamba/code_generation/Rambafile.liquid +8 -7
- data/lib/generamba/code_generation/code_module.rb +44 -49
- data/lib/generamba/code_generation/content_generator.rb +8 -28
- data/lib/generamba/code_generation/module_template.rb +11 -3
- data/lib/generamba/constants/rambafile_constants.rb +3 -1
- data/lib/generamba/constants/rambaspec_constants.rb +2 -2
- data/lib/generamba/helpers/dependency_checker.rb +3 -7
- data/lib/generamba/helpers/gen_command_table_parameters_formatter.rb +20 -10
- data/lib/generamba/helpers/module_info_generator.rb +32 -0
- data/lib/generamba/helpers/module_validator.rb +27 -0
- data/lib/generamba/helpers/print_table.rb +1 -5
- data/lib/generamba/helpers/rambafile_validator.rb +17 -17
- data/lib/generamba/helpers/template_helper.rb +6 -8
- data/lib/generamba/helpers/xcodeproj_helper.rb +46 -65
- data/lib/generamba/module_generator.rb +31 -23
- data/lib/generamba/template/installer/remote_installer.rb +1 -1
- data/lib/generamba/version.rb +2 -2
- metadata +5 -2
@@ -10,9 +10,9 @@ module Generamba
|
|
10
10
|
TEMPLATE_CODE_FILES_KEY = 'code_files'
|
11
11
|
TEMPLATE_TEST_FILES_KEY = 'test_files'
|
12
12
|
TEMPLATE_FILE_NAME_KEY = 'name'
|
13
|
+
TEMPLATE_FILE_CUSTOM_NAME_KEY = 'custom_name'
|
13
14
|
TEMPLATE_FILE_PATH_KEY = 'path'
|
14
|
-
|
15
|
-
TEMPLATE_FILE_FILETYPE_KEY = 'file_type'
|
15
|
+
TEMPLATE_FILE_IS_RESOURCE_KEY = 'is_resource'
|
16
16
|
|
17
17
|
TEMPLATE_DEPENDENCIES_KEY = 'dependencies'
|
18
18
|
end
|
@@ -1,17 +1,15 @@
|
|
1
1
|
require 'cocoapods-core'
|
2
2
|
|
3
3
|
module Generamba
|
4
|
-
|
5
4
|
# Provides methods for check dependencies from rambaspec in podfile
|
6
5
|
class DependencyChecker
|
7
|
-
|
8
6
|
# Check Podfile for dependencies
|
9
7
|
# @param dependencies [Array] Array of dependencies name
|
10
8
|
# @param podfile_path [String] String of Podfile path
|
11
9
|
#
|
12
10
|
# @return [void]
|
13
11
|
def self.check_all_required_dependencies_has_in_podfile(dependencies, podfile_path)
|
14
|
-
return if !dependencies
|
12
|
+
return if !dependencies || dependencies.count == 0 || !podfile_path
|
15
13
|
|
16
14
|
dependencies_names = []
|
17
15
|
Pod::Podfile.from_file(Pathname.new(podfile_path)).dependencies.each do |dependency|
|
@@ -37,7 +35,7 @@ module Generamba
|
|
37
35
|
#
|
38
36
|
# @return [void]
|
39
37
|
def self.check_all_required_dependencies_has_in_cartfile(dependencies, cartfile_path)
|
40
|
-
return if !dependencies
|
38
|
+
return if !dependencies || dependencies.count == 0 || !cartfile_path
|
41
39
|
|
42
40
|
cartfile_string = File.read(cartfile_path)
|
43
41
|
|
@@ -52,7 +50,5 @@ module Generamba
|
|
52
50
|
puts "[Warning] Dependencies #{not_existing_dependency} missed in Cartfile".yellow
|
53
51
|
end
|
54
52
|
end
|
55
|
-
|
56
53
|
end
|
57
|
-
|
58
|
-
end
|
54
|
+
end
|
@@ -1,23 +1,33 @@
|
|
1
1
|
module Generamba
|
2
|
-
|
3
2
|
# Provides methods for prepare parameters for displaying in table.
|
4
3
|
class GenCommandTableParametersFormatter
|
4
|
+
require 'json'
|
5
5
|
|
6
6
|
# This method prepared parameter for displaying
|
7
|
-
def self.prepare_parameters_for_displaying(
|
8
|
-
params =
|
7
|
+
def self.prepare_parameters_for_displaying(code_module, template_name)
|
8
|
+
params = {}
|
9
9
|
|
10
|
-
|
10
|
+
params['Targets'] = code_module.project_targets.join(',')
|
11
|
+
params['Module path'] = code_module.module_file_path
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
if code_module.module_file_path != code_module.module_group_path
|
14
|
+
params['Module group path'] = code_module.module_group_path
|
14
15
|
end
|
15
16
|
|
16
|
-
params['
|
17
|
+
params['Test targets'] = code_module.test_targets.join(',') if code_module.test_targets
|
18
|
+
params['Test file path'] = code_module.test_file_path if code_module.test_file_path
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
+
if code_module.test_file_path != code_module.test_group_path
|
21
|
+
params['Test group path'] = code_module.test_group_path
|
22
|
+
end
|
20
23
|
|
21
|
-
|
24
|
+
params['Template'] = template_name
|
22
25
|
|
26
|
+
if code_module.custom_parameters
|
27
|
+
params['Custom parameters'] = code_module.custom_parameters.to_json
|
28
|
+
end
|
29
|
+
|
30
|
+
params
|
31
|
+
end
|
32
|
+
end
|
23
33
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Generamba
|
2
|
+
|
3
|
+
class ModuleInfoGenerator
|
4
|
+
attr_reader :scope
|
5
|
+
|
6
|
+
def initialize(code_module)
|
7
|
+
module_info = {
|
8
|
+
'name' => code_module.name,
|
9
|
+
'description' => code_module.description,
|
10
|
+
'project_name' => code_module.project_name,
|
11
|
+
'project_targets' => code_module.project_targets,
|
12
|
+
'test_targets' => code_module.test_targets
|
13
|
+
}
|
14
|
+
|
15
|
+
developer = {
|
16
|
+
'name' => code_module.author,
|
17
|
+
'company' => code_module.company
|
18
|
+
}
|
19
|
+
|
20
|
+
@scope = {
|
21
|
+
'year' => code_module.year,
|
22
|
+
'date' => Time.now.strftime('%d/%m/%Y'),
|
23
|
+
'developer' => developer,
|
24
|
+
'module_info' => module_info,
|
25
|
+
'prefix' => code_module.prefix,
|
26
|
+
'custom_parameters' => code_module.custom_parameters
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Generamba
|
2
|
+
# Provides methods for validating module
|
3
|
+
class ModuleValidator
|
4
|
+
|
5
|
+
# Method validates module
|
6
|
+
# @param code_module [CodeModule] The instance of CodeModule
|
7
|
+
#
|
8
|
+
# @return [Void]
|
9
|
+
def validate(code_module)
|
10
|
+
mandatory_fields = [COMPANY_KEY,
|
11
|
+
PROJECT_PREFIX_KEY,
|
12
|
+
PROJECT_NAME_KEY,
|
13
|
+
XCODEPROJ_PATH_KEY,
|
14
|
+
PROJECT_TARGETS_KEY,
|
15
|
+
'module_file_path',
|
16
|
+
'module_group_path']
|
17
|
+
|
18
|
+
mandatory_fields.each do |field|
|
19
|
+
unless code_module.instance_variable_get("@#{field}")
|
20
|
+
puts "Module is broken! *#{field}* field cannot be empty, because it is mandatory.".red
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Generamba
|
2
|
-
|
3
2
|
# Provides methods for print parameters in nice table.
|
4
3
|
class PrintTable
|
5
|
-
|
6
4
|
# This method prints out all the user inputs in a nice table.
|
7
5
|
def self.print_values(values: nil, title: nil)
|
8
6
|
require 'terminal-table'
|
@@ -15,7 +13,5 @@ module Generamba
|
|
15
13
|
puts Terminal::Table.new(params)
|
16
14
|
puts ''
|
17
15
|
end
|
18
|
-
|
19
16
|
end
|
20
|
-
|
21
|
-
end
|
17
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Generamba
|
2
|
-
|
3
2
|
# Provides methods for validating Rambafile contents
|
4
3
|
class RambafileValidator
|
5
|
-
|
6
4
|
# Method validates Rambafile contents
|
7
5
|
# @param path [String] The path to a Rambafile
|
8
6
|
#
|
@@ -44,7 +42,12 @@ module Generamba
|
|
44
42
|
#
|
45
43
|
# @return [Array]
|
46
44
|
def all_project_failure_fields(preferences)
|
47
|
-
|
45
|
+
file_path = preferences[PROJECT_FILE_PATH_KEY]
|
46
|
+
group_path = preferences[PROJECT_GROUP_PATH_KEY]
|
47
|
+
|
48
|
+
return [] if !file_path || !group_path
|
49
|
+
|
50
|
+
all_nil_mandatory_fields_for_target_type('project', preferences)
|
48
51
|
end
|
49
52
|
|
50
53
|
# Method which return all test failure fields
|
@@ -59,23 +62,21 @@ module Generamba
|
|
59
62
|
|
60
63
|
has_test_fields = target || targets || file_path || group_path
|
61
64
|
|
62
|
-
unless has_test_fields
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
return all_nil_mandatory_fields_for_target_type("test", preferences)
|
65
|
+
return [] unless has_test_fields
|
66
|
+
|
67
|
+
all_nil_mandatory_fields_for_target_type('test', preferences)
|
67
68
|
end
|
68
69
|
|
69
70
|
# Method which return all failure fields for target_type
|
70
71
|
# @param target_type [String] "project" or "test"
|
71
72
|
# @param preferences [Hash] Converted Rambafile
|
72
|
-
#
|
73
|
+
#
|
73
74
|
# @return [Array]
|
74
75
|
def all_nil_mandatory_fields_for_target_type(target_type, preferences)
|
75
76
|
target_type = target_type.upcase
|
76
77
|
|
77
|
-
target_const_value = Generamba.const_get(target_type +
|
78
|
-
targets_const_value = Generamba.const_get(target_type +
|
78
|
+
target_const_value = Generamba.const_get(target_type + '_TARGET_KEY')
|
79
|
+
targets_const_value = Generamba.const_get(target_type + '_TARGETS_KEY')
|
79
80
|
|
80
81
|
target = preferences[target_const_value]
|
81
82
|
targets = preferences[targets_const_value]
|
@@ -86,20 +87,19 @@ module Generamba
|
|
86
87
|
fields.push(target_const_value)
|
87
88
|
end
|
88
89
|
|
89
|
-
file_path_const_value = Generamba.const_get(target_type +
|
90
|
+
file_path_const_value = Generamba.const_get(target_type + '_FILE_PATH_KEY')
|
90
91
|
|
91
92
|
unless preferences[file_path_const_value]
|
92
93
|
fields.push(file_path_const_value)
|
93
|
-
end
|
94
|
+
end
|
94
95
|
|
95
|
-
group_path_const_value = Generamba.const_get(target_type +
|
96
|
+
group_path_const_value = Generamba.const_get(target_type + '_GROUP_PATH_KEY')
|
96
97
|
|
97
98
|
unless preferences[group_path_const_value]
|
98
99
|
fields.push(group_path_const_value)
|
99
100
|
end
|
100
101
|
|
101
|
-
|
102
|
+
fields
|
102
103
|
end
|
103
|
-
|
104
104
|
end
|
105
|
-
end
|
105
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Generamba
|
2
|
-
|
3
2
|
# Provides a number of helper methods for manipulating Generamba template files
|
4
3
|
class TemplateHelper
|
5
|
-
|
6
4
|
# Returns a file path for a specific template .rambaspec file
|
7
5
|
# @param template_name [String] The Generamba template name
|
8
6
|
#
|
@@ -11,7 +9,7 @@ module Generamba
|
|
11
9
|
template_path = self.obtain_path(template_name)
|
12
10
|
spec_path = template_path.join(template_name + RAMBASPEC_EXTENSION)
|
13
11
|
|
14
|
-
|
12
|
+
spec_path
|
15
13
|
end
|
16
14
|
|
17
15
|
# Returns a file path for a specific template folder
|
@@ -20,13 +18,13 @@ module Generamba
|
|
20
18
|
# @return [Pathname]
|
21
19
|
def self.obtain_path(template_name)
|
22
20
|
path = Pathname.new(Dir.getwd)
|
23
|
-
|
24
|
-
|
21
|
+
.join(TEMPLATES_FOLDER)
|
22
|
+
.join(template_name)
|
25
23
|
|
26
24
|
error_description = "Cannot find template named #{template_name}! Add it to the Rambafile and run *generamba template install*".red
|
27
|
-
raise StandardError
|
25
|
+
raise StandardError, error_description unless path.exist?
|
28
26
|
|
29
|
-
|
27
|
+
path
|
30
28
|
end
|
31
29
|
end
|
32
|
-
end
|
30
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Generamba
|
2
|
-
|
3
2
|
# Provides a number of helper methods for working with xcodeproj gem
|
4
3
|
class XcodeprojHelper
|
5
|
-
|
6
4
|
# Returns a PBXProject class for a given name
|
7
5
|
# @param project_name [String] The name of the project file
|
8
6
|
#
|
@@ -15,28 +13,24 @@ module Generamba
|
|
15
13
|
# @param project [Xcodeproj::Project] The target xcodeproj file
|
16
14
|
# @param targets_name [String] Array of targets name
|
17
15
|
# @param group_path [Pathname] The Xcode group path for current file
|
18
|
-
# @param
|
19
|
-
# @param
|
16
|
+
# @param dir_path [Pathname] The directory path for current file
|
17
|
+
# @param file_group_path [String] Directory path
|
18
|
+
# @param file_name [String] Current file name
|
19
|
+
# @param file_is_resource [TrueClass or FalseClass] If true then file is resource
|
20
20
|
#
|
21
21
|
# @return [void]
|
22
|
-
def self.add_file_to_project_and_targets(project, targets_name, group_path,
|
23
|
-
|
22
|
+
def self.add_file_to_project_and_targets(project, targets_name, group_path, dir_path, file_group_path, file_name, file_is_resource = false)
|
23
|
+
file_path = dir_path.join(file_group_path).join(file_name)
|
24
|
+
module_group = self.retrieve_group_or_create_if_needed(group_path, dir_path, file_group_path, project, true)
|
24
25
|
xcode_file = module_group.new_file(File.absolute_path(file_path))
|
25
26
|
|
26
|
-
file_name = File.basename(file_path)
|
27
27
|
targets_name.each do |target|
|
28
|
-
xcode_target =
|
28
|
+
xcode_target = obtain_target(target, project)
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
file_type = 'resource'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
if file_type != nil
|
39
|
-
self.add_file_to_target(xcode_target, xcode_file, file_type)
|
30
|
+
if file_is_resource || self.is_bundle_resource?(file_name)
|
31
|
+
xcode_target.add_resources([xcode_file])
|
32
|
+
elsif self.is_compile_source?(file_name)
|
33
|
+
xcode_target.add_file_references([xcode_file])
|
40
34
|
end
|
41
35
|
end
|
42
36
|
end
|
@@ -44,26 +38,12 @@ module Generamba
|
|
44
38
|
# Adds a provided directory to a specific Project
|
45
39
|
# @param project [Xcodeproj::Project] The target xcodeproj file
|
46
40
|
# @param group_path [Pathname] The Xcode group path for current directory
|
41
|
+
# @param dir_path [Pathname] The directory path for current directory
|
42
|
+
# @param directory_name [String] Current directory name
|
47
43
|
#
|
48
44
|
# @return [void]
|
49
|
-
def self.add_group_to_project(project, group_path)
|
50
|
-
self.retrieve_group_or_create_if_needed(group_path, project, true)
|
51
|
-
end
|
52
|
-
|
53
|
-
# Adds xcode file to target based on it's type
|
54
|
-
# @param target [Xcodeproj::AbstractTarget] xcode target to use
|
55
|
-
# @param file [Xcodeproj::PBXFileReference] file reference to add
|
56
|
-
# @param type [String] is either 'source' or 'resource'
|
57
|
-
#
|
58
|
-
def self.add_file_to_target(target, file, type)
|
59
|
-
case type
|
60
|
-
when 'source'
|
61
|
-
target.add_file_references([file])
|
62
|
-
when 'resource'
|
63
|
-
target.add_resources([file])
|
64
|
-
else
|
65
|
-
puts "Can't add file with type #{type}. Only 'source' and 'resource' are acceptable"
|
66
|
-
end
|
45
|
+
def self.add_group_to_project(project, group_path, dir_path, directory_name)
|
46
|
+
self.retrieve_group_or_create_if_needed(group_path, dir_path, directory_name, project, true)
|
67
47
|
end
|
68
48
|
|
69
49
|
# File is a compiled source
|
@@ -88,7 +68,7 @@ module Generamba
|
|
88
68
|
#
|
89
69
|
# @return [Void]
|
90
70
|
def self.clear_group(project, targets_name, group_path)
|
91
|
-
module_group = self.retrieve_group_or_create_if_needed(group_path, project, false)
|
71
|
+
module_group = self.retrieve_group_or_create_if_needed(group_path, nil, nil, project, false)
|
92
72
|
return unless module_group
|
93
73
|
|
94
74
|
files_path = self.files_path_from_group(module_group, project)
|
@@ -97,7 +77,7 @@ module Generamba
|
|
97
77
|
files_path.each do |file_path|
|
98
78
|
self.remove_file_by_file_path(file_path, targets_name, project)
|
99
79
|
end
|
100
|
-
|
80
|
+
|
101
81
|
module_group.clear
|
102
82
|
end
|
103
83
|
|
@@ -107,39 +87,44 @@ module Generamba
|
|
107
87
|
#
|
108
88
|
# @return [TrueClass or FalseClass]
|
109
89
|
def self.module_with_group_path_already_exists(project, group_path)
|
110
|
-
module_group = self.retrieve_group_or_create_if_needed(group_path, project, false)
|
111
|
-
|
90
|
+
module_group = self.retrieve_group_or_create_if_needed(group_path, nil, nil, project, false)
|
91
|
+
module_group.nil? ? false : true
|
112
92
|
end
|
113
93
|
|
114
94
|
private
|
115
95
|
|
116
96
|
# Finds or creates a group in a xcodeproj file with a given path
|
117
|
-
# @param group_path [Pathname] The
|
97
|
+
# @param group_path [Pathname] The Xcode group path for module
|
98
|
+
# @param dir_path [Pathname] The directory path for module
|
99
|
+
# @param file_group_path [String] Directory path
|
118
100
|
# @param project [Xcodeproj::Project] The working Xcode project file
|
119
|
-
# @param create_group_if_not_exists [TrueClass or FalseClass] If true
|
101
|
+
# @param create_group_if_not_exists [TrueClass or FalseClass] If true nonexistent group will be created
|
120
102
|
#
|
121
103
|
# @return [PBXGroup]
|
122
|
-
def self.retrieve_group_or_create_if_needed(group_path, project, create_group_if_not_exists)
|
104
|
+
def self.retrieve_group_or_create_if_needed(group_path, dir_path, file_group_path, project, create_group_if_not_exists)
|
123
105
|
group_names = path_names_from_path(group_path)
|
106
|
+
group_components_count = group_names.count
|
107
|
+
group_names += path_names_from_path(file_group_path) if file_group_path
|
124
108
|
|
125
109
|
final_group = project
|
126
110
|
|
127
|
-
group_names.
|
111
|
+
group_names.each_with_index do |group_name, index|
|
128
112
|
next_group = final_group[group_name]
|
129
113
|
|
130
114
|
unless next_group
|
131
|
-
unless create_group_if_not_exists
|
132
|
-
return nil
|
133
|
-
end
|
115
|
+
return nil unless create_group_if_not_exists
|
134
116
|
|
135
|
-
|
136
|
-
|
117
|
+
if group_path != dir_path && index == group_components_count-1
|
118
|
+
next_group = final_group.new_group(group_name, dir_path, :project)
|
119
|
+
else
|
120
|
+
next_group = final_group.new_group(group_name, group_name)
|
121
|
+
end
|
137
122
|
end
|
138
123
|
|
139
124
|
final_group = next_group
|
140
125
|
end
|
141
126
|
|
142
|
-
|
127
|
+
final_group
|
143
128
|
end
|
144
129
|
|
145
130
|
# Returns an AbstractTarget class for a given name
|
@@ -149,13 +134,11 @@ module Generamba
|
|
149
134
|
# @return [Xcodeproj::AbstractTarget]
|
150
135
|
def self.obtain_target(target_name, project)
|
151
136
|
project.targets.each do |target|
|
152
|
-
if target.name == target_name
|
153
|
-
return target
|
154
|
-
end
|
137
|
+
return target if target.name == target_name
|
155
138
|
end
|
156
139
|
|
157
140
|
error_description = "Cannot find a target with name #{target_name} in Xcode project".red
|
158
|
-
raise StandardError
|
141
|
+
raise StandardError, error_description
|
159
142
|
end
|
160
143
|
|
161
144
|
# Splits the provided Xcode path to an array of separate paths
|
@@ -163,8 +146,7 @@ module Generamba
|
|
163
146
|
#
|
164
147
|
# @return [[String]]
|
165
148
|
def self.path_names_from_path(path)
|
166
|
-
|
167
|
-
return paths
|
149
|
+
path.to_s.split('/')
|
168
150
|
end
|
169
151
|
|
170
152
|
# Remove build file from target build phase
|
@@ -188,7 +170,7 @@ module Generamba
|
|
188
170
|
end
|
189
171
|
|
190
172
|
def self.remove_file_from_build_phases(file_path, build_phases)
|
191
|
-
return if build_phases
|
173
|
+
return if build_phases.nil?
|
192
174
|
|
193
175
|
build_phases.each do |build_phase|
|
194
176
|
build_phase.files.each do |build_file|
|
@@ -220,7 +202,7 @@ module Generamba
|
|
220
202
|
end
|
221
203
|
end
|
222
204
|
|
223
|
-
|
205
|
+
build_phases
|
224
206
|
end
|
225
207
|
|
226
208
|
# Find and return target resources build phase
|
@@ -236,7 +218,7 @@ module Generamba
|
|
236
218
|
resource_build_phase.push(xcode_target.resources_build_phase)
|
237
219
|
end
|
238
220
|
|
239
|
-
|
221
|
+
resource_build_phase
|
240
222
|
end
|
241
223
|
|
242
224
|
# Get configure file full path
|
@@ -247,7 +229,7 @@ module Generamba
|
|
247
229
|
build_file_ref_path = file_ref.hierarchy_path.to_s
|
248
230
|
build_file_ref_path[0] = ''
|
249
231
|
|
250
|
-
|
232
|
+
build_file_ref_path
|
251
233
|
end
|
252
234
|
|
253
235
|
# Get all files path from group path
|
@@ -255,18 +237,17 @@ module Generamba
|
|
255
237
|
# @param project [Xcodeproj::Project] The target xcodeproj file
|
256
238
|
#
|
257
239
|
# @return [[String]]
|
258
|
-
def self.files_path_from_group(module_group,
|
240
|
+
def self.files_path_from_group(module_group, _project)
|
259
241
|
files_path = []
|
260
242
|
|
261
243
|
module_group.recursive_children.each do |file_ref|
|
262
244
|
if file_ref.isa == 'PBXFileReference'
|
263
|
-
file_ref_path =
|
245
|
+
file_ref_path = configure_file_ref_path(file_ref)
|
264
246
|
files_path.push(file_ref_path)
|
265
247
|
end
|
266
248
|
end
|
267
249
|
|
268
|
-
|
250
|
+
files_path
|
269
251
|
end
|
270
|
-
|
271
252
|
end
|
272
|
-
end
|
253
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
require 'generamba/helpers/xcodeproj_helper.rb'
|
4
|
+
require 'generamba/helpers/module_info_generator.rb'
|
4
5
|
|
5
6
|
module Generamba
|
6
7
|
|
@@ -47,15 +48,12 @@ module Generamba
|
|
47
48
|
# Saving the current changes in the Xcode project
|
48
49
|
project.save
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
puts
|
54
|
-
|
55
|
-
|
56
|
-
"Module group path: #{code_module.module_group_path}".green + "\n" +
|
57
|
-
test_file_path_created_message +
|
58
|
-
test_group_path_created_message)
|
51
|
+
puts 'Module successfully created!'
|
52
|
+
puts "Name: #{name}".green
|
53
|
+
puts "Module file path: #{code_module.module_file_path}".green
|
54
|
+
puts "Module group path: #{code_module.module_group_path}".green
|
55
|
+
puts "Test file path: #{code_module.test_file_path}".green if code_module.test_file_path
|
56
|
+
puts "Test group path: #{code_module.test_group_path}".green if code_module.test_group_path
|
59
57
|
end
|
60
58
|
|
61
59
|
def process_files_if_needed(files, name, code_module, template, project, targets, group_path, dir_path)
|
@@ -72,25 +70,35 @@ module Generamba
|
|
72
70
|
file_group = dir_path.join(directory_name)
|
73
71
|
|
74
72
|
FileUtils.mkdir_p file_group
|
75
|
-
XcodeprojHelper.add_group_to_project(project,
|
76
|
-
|
77
|
-
|
73
|
+
XcodeprojHelper.add_group_to_project(project, group_path, dir_path, directory_name)
|
74
|
+
|
75
|
+
next
|
76
|
+
end
|
78
77
|
|
79
|
-
|
80
|
-
file_name, file_content = ContentGenerator.create_file(file, code_module, template)
|
81
|
-
file_path = dir_path.join(file_group).join(file_name)
|
78
|
+
file_group = File.dirname(file[TEMPLATE_NAME_KEY])
|
82
79
|
|
83
|
-
|
84
|
-
FileUtils.mkdir_p File.dirname(file_path)
|
85
|
-
File.open(file_path, 'w+') do |f|
|
86
|
-
f.write(file_content)
|
87
|
-
end
|
80
|
+
module_info = ModuleInfoGenerator.new(code_module)
|
88
81
|
|
89
|
-
|
82
|
+
# Generating the content of the code file and it's name
|
83
|
+
file_name, file_content = ContentGenerator.create_file(file, module_info.scope, template)
|
84
|
+
file_path = dir_path.join(file_group).join(file_name)
|
90
85
|
|
91
|
-
|
92
|
-
|
86
|
+
# Creating the file in the filesystem
|
87
|
+
FileUtils.mkdir_p File.dirname(file_path)
|
88
|
+
File.open(file_path, 'w+') do |f|
|
89
|
+
f.write(file_content)
|
93
90
|
end
|
91
|
+
|
92
|
+
file_is_resource = file[TEMPLATE_FILE_IS_RESOURCE_KEY]
|
93
|
+
|
94
|
+
# Creating the file in the Xcode project
|
95
|
+
XcodeprojHelper.add_file_to_project_and_targets(project,
|
96
|
+
targets,
|
97
|
+
group_path,
|
98
|
+
dir_path,
|
99
|
+
file_group,
|
100
|
+
file_name,
|
101
|
+
file_is_resource)
|
94
102
|
end
|
95
103
|
end
|
96
104
|
end
|
@@ -24,7 +24,7 @@ module Generamba
|
|
24
24
|
Git.clone(repo_url, template_name, :path => temp_path)
|
25
25
|
end
|
26
26
|
|
27
|
-
template_path = "#{template_dir}
|
27
|
+
template_path = "#{template_dir}"
|
28
28
|
|
29
29
|
rambaspec_exist = Generamba::RambaspecValidator.validate_spec_existance(template_name, template_path)
|
30
30
|
unless rambaspec_exist
|
data/lib/generamba/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generamba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Egor Tolstoy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -175,6 +175,7 @@ executables:
|
|
175
175
|
extensions: []
|
176
176
|
extra_rdoc_files: []
|
177
177
|
files:
|
178
|
+
- ".codeclimate.yml"
|
178
179
|
- ".gitignore"
|
179
180
|
- ".rspec"
|
180
181
|
- ".travis.yml"
|
@@ -211,6 +212,8 @@ files:
|
|
211
212
|
- lib/generamba/constants/user_preferences_constants.rb
|
212
213
|
- lib/generamba/helpers/dependency_checker.rb
|
213
214
|
- lib/generamba/helpers/gen_command_table_parameters_formatter.rb
|
215
|
+
- lib/generamba/helpers/module_info_generator.rb
|
216
|
+
- lib/generamba/helpers/module_validator.rb
|
214
217
|
- lib/generamba/helpers/print_table.rb
|
215
218
|
- lib/generamba/helpers/rambafile_validator.rb
|
216
219
|
- lib/generamba/helpers/template_helper.rb
|