generamba 0.7.8 → 1.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/generamba.gemspec +6 -2
- data/lib/generamba/cli/gen_command.rb +2 -0
- data/lib/generamba/cli/version_command.rb +13 -1
- data/lib/generamba/code_generation/code_module.rb +39 -9
- data/lib/generamba/code_generation/content_generator.rb +2 -1
- data/lib/generamba/helpers/dependency_checker.rb +23 -1
- data/lib/generamba/helpers/xcodeproj_helper.rb +19 -7
- data/lib/generamba/module_generator.rb +23 -17
- data/lib/generamba/version.rb +3 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40260eafddc1f86ef6b3583e592e0fe6f0716efe
|
4
|
+
data.tar.gz: 525027d7e7ab9a936c4d5843da3903ffc30a3d1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a135a4822acac9d8524d94b18a986252d700826ba464369979ac46d5066bf603b4aba54c50b88a381bb665a1244b4a8076803fa0abd1d252671307d5aa5d4ae7
|
7
|
+
data.tar.gz: 911f34694191b513c6bf47f8bacccbfc1559b39dea7d298dfcd38080fa6f2348da8fcc6abac898fae1ab1e62a64e1f3ed7af13f77db1e81363dc524f192d11f7
|
data/generamba.gemspec
CHANGED
@@ -21,14 +21,18 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.required_ruby_version = '>= 2.2'
|
22
22
|
|
23
23
|
spec.add_runtime_dependency 'thor', '0.19.1'
|
24
|
-
spec.add_runtime_dependency 'xcodeproj', '
|
24
|
+
spec.add_runtime_dependency 'xcodeproj', '1.2.0'
|
25
25
|
spec.add_runtime_dependency 'liquid', '3.0.6'
|
26
26
|
spec.add_runtime_dependency 'git', '1.2.9.1'
|
27
|
-
spec.add_runtime_dependency 'cocoapods-core', '0.
|
27
|
+
spec.add_runtime_dependency 'cocoapods-core', '1.0.1'
|
28
28
|
spec.add_runtime_dependency 'terminal-table', '1.4.5'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
31
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
33
33
|
spec.add_development_dependency 'fakefs', '~> 0.6.1'
|
34
|
+
# ActiveSupport dependency is not used by dashramba; instead some other dependency
|
35
|
+
# requires it. We lock it to 4.2.7 so as to avoid using 5.0, which is
|
36
|
+
# not compatible with older versions of Ruby.
|
37
|
+
spec.add_development_dependency 'activesupport', '~> 4.2.7'
|
34
38
|
end
|
@@ -21,6 +21,7 @@ module Generamba::CLI
|
|
21
21
|
method_option :test_file_path, :desc => 'Specifies a location in the filesystem for new test files'
|
22
22
|
method_option :test_group_path, :desc => 'Specifies a location in Xcode groups for new test files'
|
23
23
|
method_option :test_path, :desc => 'Specifies a location (both in the filesystem and Xcode) for new test files'
|
24
|
+
method_option :custom_parameters, :type => :hash, :default => {}, :desc => 'Specifies extra parameters in format `key1:value1 key2:value2` for usage during code generation'
|
24
25
|
def gen(module_name, template_name)
|
25
26
|
|
26
27
|
does_rambafile_exist = Dir[RAMBAFILE_NAME].count > 0
|
@@ -51,6 +52,7 @@ module Generamba::CLI
|
|
51
52
|
code_module = CodeModule.new(module_name, module_description, rambafile, options)
|
52
53
|
|
53
54
|
DependencyChecker.check_all_required_dependencies_has_in_podfile(template.dependencies, code_module.podfile_path)
|
55
|
+
DependencyChecker.check_all_required_dependencies_has_in_cartfile(template.dependencies, code_module.cartfile_path)
|
54
56
|
|
55
57
|
project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
|
56
58
|
module_group_already_exists = XcodeprojHelper.module_with_group_path_already_exists(project, code_module.module_group_path)
|
@@ -7,7 +7,19 @@ module Generamba::CLI
|
|
7
7
|
|
8
8
|
desc 'version', 'Prints out Generamba current version'
|
9
9
|
def version
|
10
|
-
|
10
|
+
options = {}
|
11
|
+
options['Version'] = Generamba::VERSION.green
|
12
|
+
options['Release date'] = Generamba::RELEASE_DATE.green
|
13
|
+
options['Change notes'] = Generamba::RELEASE_LINK.green
|
14
|
+
|
15
|
+
values = []
|
16
|
+
|
17
|
+
options.each do |title, value|
|
18
|
+
values.push("#{title}: #{value}")
|
19
|
+
end
|
20
|
+
|
21
|
+
output = values.join("\n")
|
22
|
+
puts(output)
|
11
23
|
end
|
12
24
|
end
|
13
25
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Generamba
|
2
2
|
|
3
|
+
SLASH_REGEX = /^\/|\/$/
|
4
|
+
|
3
5
|
# Represents currently generating code module
|
4
6
|
class CodeModule
|
5
7
|
attr_reader :name,
|
@@ -16,7 +18,9 @@ module Generamba
|
|
16
18
|
:test_group_path,
|
17
19
|
:project_targets,
|
18
20
|
:test_targets,
|
19
|
-
:podfile_path
|
21
|
+
:podfile_path,
|
22
|
+
:cartfile_path,
|
23
|
+
:custom_parameters
|
20
24
|
|
21
25
|
def initialize(name, description, rambafile, options)
|
22
26
|
# Base initialization
|
@@ -48,23 +52,49 @@ module Generamba
|
|
48
52
|
@test_targets = [rambafile[TEST_TARGET_KEY]] if rambafile[TEST_TARGET_KEY] != nil
|
49
53
|
@test_targets = rambafile[TEST_TARGETS_KEY] if rambafile[TEST_TARGETS_KEY] != nil
|
50
54
|
|
55
|
+
# Custom parameters
|
56
|
+
@custom_parameters = options[:custom_parameters]
|
57
|
+
|
51
58
|
# Options adaptation
|
52
59
|
@author = options[:author] if options[:author]
|
53
60
|
@project_targets = options[:module_targets].split(',') if options[:module_targets]
|
54
61
|
@test_targets = options[:test_targets].split(',') if options[:test_targets]
|
55
62
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
63
|
+
if options[:module_file_path]
|
64
|
+
@module_file_path = options[:module_file_path].gsub(SLASH_REGEX, '')
|
65
|
+
@module_file_path = Pathname.new(@module_file_path).join(@name)
|
66
|
+
end
|
67
|
+
|
68
|
+
if options[:module_group_path]
|
69
|
+
@module_group_path = options[:module_group_path].gsub(SLASH_REGEX, '')
|
70
|
+
@module_group_path = Pathname.new(@module_group_path).join(@name)
|
71
|
+
end
|
72
|
+
|
73
|
+
if options[:test_file_path]
|
74
|
+
@test_file_path = options[:test_file_path].gsub(SLASH_REGEX, '')
|
75
|
+
@test_file_path = Pathname.new(@test_file_path).join(@name)
|
76
|
+
end
|
77
|
+
|
78
|
+
if options[:test_group_path]
|
79
|
+
@test_group_path = options[:test_group_path].gsub(SLASH_REGEX, '')
|
80
|
+
@test_group_path = Pathname.new(@test_group_path).join(@name)
|
81
|
+
end
|
60
82
|
|
61
83
|
# The priority is given to `module_path` and 'test_path' options
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
84
|
+
if options[:module_path]
|
85
|
+
@module_path = options[:module_path].gsub(SLASH_REGEX, '')
|
86
|
+
@module_file_path = Pathname.new(@module_path).join(@name)
|
87
|
+
@module_group_path = Pathname.new(@module_path).join(@name)
|
88
|
+
end
|
89
|
+
|
90
|
+
if options[:test_path]
|
91
|
+
@test_path = options[:test_path].gsub(SLASH_REGEX, '')
|
92
|
+
@test_file_path = Pathname.new(@test_path).join(@name)
|
93
|
+
@test_group_path = Pathname.new(@test_path).join(@name)
|
94
|
+
end
|
66
95
|
|
67
96
|
@podfile_path = rambafile[PODFILE_PATH_KEY] if rambafile[PODFILE_PATH_KEY] != nil
|
97
|
+
@cartfile_path = rambafile[CARTFILE_PATH_KEY] if rambafile[CARTFILE_PATH_KEY] != nil
|
68
98
|
end
|
69
99
|
end
|
70
100
|
end
|
@@ -38,7 +38,8 @@ module Generamba
|
|
38
38
|
'date' => Time.now.strftime('%d/%m/%Y'),
|
39
39
|
'developer' => developer,
|
40
40
|
'module_info' => module_info,
|
41
|
-
'prefix' => code_module.prefix
|
41
|
+
'prefix' => code_module.prefix,
|
42
|
+
'custom_parameters' => code_module.custom_parameters
|
42
43
|
}
|
43
44
|
|
44
45
|
module_info['file_basename'] = file_basename
|
@@ -5,7 +5,7 @@ module Generamba
|
|
5
5
|
# Provides methods for check dependencies from rambaspec in podfile
|
6
6
|
class DependencyChecker
|
7
7
|
|
8
|
-
# Check
|
8
|
+
# Check Podfile for dependencies
|
9
9
|
# @param dependencies [Array] Array of dependencies name
|
10
10
|
# @param podfile_path [String] String of Podfile path
|
11
11
|
#
|
@@ -31,6 +31,28 @@ module Generamba
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
# Check Cartfile for dependencies
|
35
|
+
# @param dependencies [Array] Array of dependencies name
|
36
|
+
# @param cartfile_path [String] String of Podfile path
|
37
|
+
#
|
38
|
+
# @return [void]
|
39
|
+
def self.check_all_required_dependencies_has_in_cartfile(dependencies, cartfile_path)
|
40
|
+
return if !dependencies or dependencies.count == 0 or !cartfile_path
|
41
|
+
|
42
|
+
cartfile_string = File.read(cartfile_path)
|
43
|
+
|
44
|
+
not_existing_dependency = []
|
45
|
+
dependencies.each do |dependency_name|
|
46
|
+
unless cartfile_string.include?(dependency_name)
|
47
|
+
not_existing_dependency.push(dependency_name)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if not_existing_dependency.count > 0
|
52
|
+
puts "[Warning] Dependencies #{not_existing_dependency} missed in Cartfile".yellow
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
34
56
|
end
|
35
57
|
|
36
58
|
end
|
@@ -20,7 +20,7 @@ module Generamba
|
|
20
20
|
#
|
21
21
|
# @return [void]
|
22
22
|
def self.add_file_to_project_and_targets(project, targets_name, group_path, file_path, file_type = nil)
|
23
|
-
module_group = self.
|
23
|
+
module_group = self.retrieve_group_or_create_if_needed(group_path, project, true)
|
24
24
|
xcode_file = module_group.new_file(File.absolute_path(file_path))
|
25
25
|
|
26
26
|
file_name = File.basename(file_path)
|
@@ -34,10 +34,21 @@ module Generamba
|
|
34
34
|
file_type = 'resource'
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
38
|
-
|
37
|
+
|
38
|
+
if file_type != nil
|
39
|
+
self.add_file_to_target(xcode_target, xcode_file, file_type)
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
43
|
+
|
44
|
+
# Adds a provided directory to a specific Project
|
45
|
+
# @param project [Xcodeproj::Project] The target xcodeproj file
|
46
|
+
# @param group_path [Pathname] The Xcode group path for current directory
|
47
|
+
#
|
48
|
+
# @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
|
41
52
|
|
42
53
|
# Adds xcode file to target based on it's type
|
43
54
|
# @param target [Xcodeproj::AbstractTarget] xcode target to use
|
@@ -77,7 +88,7 @@ module Generamba
|
|
77
88
|
#
|
78
89
|
# @return [Void]
|
79
90
|
def self.clear_group(project, targets_name, group_path)
|
80
|
-
module_group = self.
|
91
|
+
module_group = self.retrieve_group_or_create_if_needed(group_path, project, false)
|
81
92
|
return unless module_group
|
82
93
|
|
83
94
|
files_path = self.files_path_from_group(module_group, project)
|
@@ -96,7 +107,7 @@ module Generamba
|
|
96
107
|
#
|
97
108
|
# @return [TrueClass or FalseClass]
|
98
109
|
def self.module_with_group_path_already_exists(project, group_path)
|
99
|
-
module_group = self.
|
110
|
+
module_group = self.retrieve_group_or_create_if_needed(group_path, project, false)
|
100
111
|
return module_group == nil ? false : true
|
101
112
|
end
|
102
113
|
|
@@ -108,18 +119,19 @@ module Generamba
|
|
108
119
|
# @param create_group_if_not_exists [TrueClass or FalseClass] If true notexistent group will be created
|
109
120
|
#
|
110
121
|
# @return [PBXGroup]
|
111
|
-
def self.
|
122
|
+
def self.retrieve_group_or_create_if_needed(group_path, project, create_group_if_not_exists)
|
112
123
|
group_names = path_names_from_path(group_path)
|
113
124
|
|
114
125
|
final_group = project
|
115
126
|
|
116
127
|
group_names.each do |group_name|
|
117
128
|
next_group = final_group[group_name]
|
129
|
+
|
118
130
|
unless next_group
|
119
131
|
unless create_group_if_not_exists
|
120
132
|
return nil
|
121
133
|
end
|
122
|
-
|
134
|
+
|
123
135
|
new_group_path = group_name
|
124
136
|
next_group = final_group.new_group(group_name, new_group_path)
|
125
137
|
end
|
@@ -67,24 +67,30 @@ module Generamba
|
|
67
67
|
|
68
68
|
XcodeprojHelper.clear_group(project, targets, group_path)
|
69
69
|
files.each do |file|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
file_type = file[TEMPLATE_FILE_FILETYPE_KEY]
|
70
|
+
unless file[TEMPLATE_FILE_PATH_KEY]
|
71
|
+
directory_name = file[TEMPLATE_NAME_KEY].gsub(/^\/|\/$/, '')
|
72
|
+
file_group = dir_path.join(directory_name)
|
73
|
+
|
74
|
+
FileUtils.mkdir_p file_group
|
75
|
+
XcodeprojHelper.add_group_to_project(project, file_group)
|
76
|
+
else
|
77
|
+
file_group = File.dirname(file[TEMPLATE_NAME_KEY])
|
78
|
+
|
79
|
+
# Generating the content of the code file and it's name
|
80
|
+
file_name, file_content = ContentGenerator.create_file(file, code_module, template)
|
81
|
+
file_path = dir_path.join(file_group).join(file_name)
|
85
82
|
|
86
|
-
|
87
|
-
|
83
|
+
# Creating the file in the filesystem
|
84
|
+
FileUtils.mkdir_p File.dirname(file_path)
|
85
|
+
File.open(file_path, 'w+') do |f|
|
86
|
+
f.write(file_content)
|
87
|
+
end
|
88
|
+
|
89
|
+
file_type = file[TEMPLATE_FILE_FILETYPE_KEY]
|
90
|
+
|
91
|
+
# Creating the file in the Xcode project
|
92
|
+
XcodeprojHelper.add_file_to_project_and_targets(project, targets, group_path.join(file_group), file_path, file_type)
|
93
|
+
end
|
88
94
|
end
|
89
95
|
end
|
90
96
|
end
|
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: 0.
|
4
|
+
version: 1.0.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-07-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 1.2.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 1.2.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: liquid
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,14 +74,14 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - '='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
77
|
+
version: 1.0.1
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - '='
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 0.
|
84
|
+
version: 1.0.1
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: terminal-table
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,6 +152,20 @@ dependencies:
|
|
152
152
|
- - "~>"
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: 0.6.1
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: activesupport
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - "~>"
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 4.2.7
|
162
|
+
type: :development
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - "~>"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 4.2.7
|
155
169
|
description: Generamba is a powerful and easy-to-use Xcode code generator. It provides
|
156
170
|
a project-based configuration, flexible templates system, the ability to generate
|
157
171
|
code and tests simultaneously.
|