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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50fbd6916f61f027113fed9afaa21334582e1487
|
4
|
+
data.tar.gz: 3f1d2d9aa01233d3ac1eb9502ca8acb01c1eab35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b424caf3eb315a22af4aa06b1204feb32ed60d05f01810c577156259b961f13b6753c00825d3515bf43f80d6ccf3ecf5ca14218b24da11b83cb52dea5466dc
|
7
|
+
data.tar.gz: bafea13e2d3abe422cb824d82fbee0d0884f0844aa540978dcd36c6e2fdb6e076b66ece4a780d6d4095794393d3e19b7d1e5c16454a52d22f4f79429995d38c1
|
data/.codeclimate.yml
ADDED
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
language: objective-c
|
2
|
+
osx_image: xcode7.3
|
3
|
+
|
4
|
+
cache:
|
5
|
+
bundler: true
|
6
|
+
|
7
|
+
bundler_args: --jobs 3 --retry 3
|
8
|
+
|
4
9
|
rvm:
|
5
10
|
- 2.2.1
|
11
|
+
- 2.3.1
|
12
|
+
|
13
|
+
before_install:
|
14
|
+
- gem update --system --no-doc --no-ri
|
15
|
+
- gem install bundler --no-doc --no-ri
|
16
|
+
|
17
|
+
script: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,45 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [1.0.0](https://github.com/rambler-ios/Generamba/tree/1.0.0) (2016-07-23)
|
4
|
+
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.8...1.0.0)
|
5
|
+
|
6
|
+
**Implemented enhancements:**
|
7
|
+
|
8
|
+
- Add more info to `generamba version` command [\#122](https://github.com/rambler-ios/Generamba/issues/122)
|
9
|
+
- Empty group in Xcode structure [\#118](https://github.com/rambler-ios/Generamba/issues/118)
|
10
|
+
- Gem dependency of cocoapods-core-0.39.0 [\#114](https://github.com/rambler-ios/Generamba/issues/114)
|
11
|
+
- Remove adding module name in module\_group\_path if it set from cli [\#98](https://github.com/rambler-ios/Generamba/issues/98)
|
12
|
+
- Check for missing Carthage dependencies [\#83](https://github.com/rambler-ios/Generamba/issues/83)
|
13
|
+
- Additional template parameters [\#46](https://github.com/rambler-ios/Generamba/issues/46)
|
14
|
+
|
15
|
+
**Fixed bugs:**
|
16
|
+
|
17
|
+
- Can't add file with type . Only 'source' and 'resource' are acceptable [\#116](https://github.com/rambler-ios/Generamba/issues/116)
|
18
|
+
- If option --module-group-path starts with '/' Generamba add folder with empty name in root folder [\#99](https://github.com/rambler-ios/Generamba/issues/99)
|
19
|
+
|
20
|
+
**Closed issues:**
|
21
|
+
|
22
|
+
- Generamba as file converter [\#41](https://github.com/rambler-ios/Generamba/issues/41)
|
23
|
+
|
24
|
+
## [0.7.8](https://github.com/rambler-ios/Generamba/tree/0.7.8) (2016-05-16)
|
25
|
+
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.7...0.7.8)
|
26
|
+
|
27
|
+
## [0.7.7](https://github.com/rambler-ios/Generamba/tree/0.7.7) (2016-05-10)
|
28
|
+
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.6...0.7.7)
|
29
|
+
|
30
|
+
**Implemented enhancements:**
|
31
|
+
|
32
|
+
- Project target name in module\_info [\#110](https://github.com/rambler-ios/Generamba/issues/110)
|
33
|
+
- Author setting setup [\#107](https://github.com/rambler-ios/Generamba/issues/107)
|
34
|
+
- Give a user more information about templates during `generamba setup` [\#86](https://github.com/rambler-ios/Generamba/issues/86)
|
35
|
+
|
36
|
+
## [0.7.6](https://github.com/rambler-ios/Generamba/tree/0.7.6) (2016-04-30)
|
37
|
+
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.5...0.7.6)
|
38
|
+
|
39
|
+
**Fixed bugs:**
|
40
|
+
|
41
|
+
- Failed adding files to project [\#96](https://github.com/rambler-ios/Generamba/issues/96)
|
42
|
+
|
3
43
|
## [0.7.5](https://github.com/rambler-ios/Generamba/tree/0.7.5) (2016-04-24)
|
4
44
|
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.4...0.7.5)
|
5
45
|
|
@@ -11,24 +51,21 @@
|
|
11
51
|
|
12
52
|
- Generamba generator: Could not find 'generamba' [\#103](https://github.com/rambler-ios/Generamba/issues/103)
|
13
53
|
- Layout issue in "Summary for gen module" [\#95](https://github.com/rambler-ios/Generamba/issues/95)
|
54
|
+
- Non human exception when wrong template name or catalog [\#77](https://github.com/rambler-ios/Generamba/issues/77)
|
55
|
+
- Error on empty template folder [\#76](https://github.com/rambler-ios/Generamba/issues/76)
|
14
56
|
|
15
57
|
**Closed issues:**
|
16
58
|
|
17
59
|
- Module Name in .rambaspec support [\#102](https://github.com/rambler-ios/Generamba/issues/102)
|
60
|
+
- \[WIP\] fix module\_group\_path option [\#100](https://github.com/rambler-ios/Generamba/issues/100)
|
18
61
|
- Generate with project and tests targets in command line [\#97](https://github.com/rambler-ios/Generamba/issues/97)
|
19
62
|
- Easy setup template path to local templates in Rambafile [\#94](https://github.com/rambler-ios/Generamba/issues/94)
|
20
63
|
|
21
|
-
**Merged pull requests:**
|
22
|
-
|
23
|
-
- Fixed \#104 [\#106](https://github.com/rambler-ios/Generamba/pull/106) ([Beniamiiin](https://github.com/Beniamiiin))
|
24
|
-
- Fixed \#95 [\#105](https://github.com/rambler-ios/Generamba/pull/105) ([Beniamiiin](https://github.com/Beniamiiin))
|
25
|
-
|
26
64
|
## [0.7.4](https://github.com/rambler-ios/Generamba/tree/0.7.4) (2016-02-21)
|
27
65
|
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.3...0.7.4)
|
28
66
|
|
29
67
|
**Implemented enhancements:**
|
30
68
|
|
31
|
-
- Asks the user if he needed tests in `generamba setup` command [\#85](https://github.com/rambler-ios/Generamba/issues/85)
|
32
69
|
- Improve the visualization of commands with parameters [\#69](https://github.com/rambler-ios/Generamba/issues/69)
|
33
70
|
- Can we introduce something similar to view partials in rails \(for duplicated parts of views\) [\#62](https://github.com/rambler-ios/Generamba/issues/62)
|
34
71
|
|
@@ -51,7 +88,6 @@
|
|
51
88
|
**Closed issues:**
|
52
89
|
|
53
90
|
- Can we use constants from rambafile in templates? [\#81](https://github.com/rambler-ios/Generamba/issues/81)
|
54
|
-
- Arguments for `generamba gen Name modulename` [\#80](https://github.com/rambler-ios/Generamba/issues/80)
|
55
91
|
|
56
92
|
## [0.7.2](https://github.com/rambler-ios/Generamba/tree/0.7.2) (2016-01-10)
|
57
93
|
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.1...0.7.2)
|
@@ -60,12 +96,10 @@
|
|
60
96
|
|
61
97
|
- --version command [\#54](https://github.com/rambler-ios/Generamba/issues/54)
|
62
98
|
- Incorrect behavior when generate module which already exists [\#52](https://github.com/rambler-ios/Generamba/issues/52)
|
63
|
-
- Add the ability to specify custom template catalogs in Rambafile [\#44](https://github.com/rambler-ios/Generamba/issues/44)
|
64
99
|
|
65
100
|
**Fixed bugs:**
|
66
101
|
|
67
102
|
- Don't set target in swift projects [\#65](https://github.com/rambler-ios/Generamba/issues/65)
|
68
|
-
- Errors if default path is empty [\#64](https://github.com/rambler-ios/Generamba/issues/64)
|
69
103
|
- Default template set can not be used [\#60](https://github.com/rambler-ios/Generamba/issues/60)
|
70
104
|
- Incorrect behavior when generate module which already exists [\#52](https://github.com/rambler-ios/Generamba/issues/52)
|
71
105
|
|
@@ -74,14 +108,12 @@
|
|
74
108
|
- Can generamba be used to generate swift modules? [\#61](https://github.com/rambler-ios/Generamba/issues/61)
|
75
109
|
- Git 1.2.9.1 [\#57](https://github.com/rambler-ios/Generamba/issues/57)
|
76
110
|
- Clarify generamba parameters usage [\#51](https://github.com/rambler-ios/Generamba/issues/51)
|
77
|
-
- Add documentation for liquid templates [\#48](https://github.com/rambler-ios/Generamba/issues/48)
|
78
111
|
|
79
112
|
## [0.7.1](https://github.com/rambler-ios/Generamba/tree/0.7.1) (2015-12-20)
|
80
113
|
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.0...0.7.1)
|
81
114
|
|
82
115
|
**Implemented enhancements:**
|
83
116
|
|
84
|
-
- Podfile path setup during generamba setup needs clarification [\#50](https://github.com/rambler-ios/Generamba/issues/50)
|
85
117
|
- Remove the Settingslogic dependency [\#42](https://github.com/rambler-ios/Generamba/issues/42)
|
86
118
|
|
87
119
|
**Fixed bugs:**
|
@@ -95,17 +127,8 @@
|
|
95
127
|
## [0.7.0](https://github.com/rambler-ios/Generamba/tree/0.7.0) (2015-12-13)
|
96
128
|
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.6.2...0.7.0)
|
97
129
|
|
98
|
-
**Implemented enhancements:**
|
99
|
-
|
100
|
-
- Add coloured output [\#28](https://github.com/rambler-ios/Generamba/issues/28)
|
101
|
-
- Add -filepath and -grouppath options for `generamba gen` command [\#27](https://github.com/rambler-ios/Generamba/issues/27)
|
102
|
-
- Add a `generamba template search` command [\#26](https://github.com/rambler-ios/Generamba/issues/26)
|
103
|
-
- Add a `generamba template list` command [\#25](https://github.com/rambler-ios/Generamba/issues/25)
|
104
|
-
- Add the if statements to the Rambafile.liquid [\#22](https://github.com/rambler-ios/Generamba/issues/22)
|
105
|
-
|
106
130
|
**Fixed bugs:**
|
107
131
|
|
108
|
-
- Non-informative error message when running `generamba template install` in the wrong directory [\#39](https://github.com/rambler-ios/Generamba/issues/39)
|
109
132
|
- undefined method `each' for nil:NilClass \(NoMethodError\) [\#37](https://github.com/rambler-ios/Generamba/issues/37)
|
110
133
|
|
111
134
|
## [0.6.2](https://github.com/rambler-ios/Generamba/tree/0.6.2) (2015-11-25)
|
@@ -114,37 +137,13 @@
|
|
114
137
|
**Fixed bugs:**
|
115
138
|
|
116
139
|
- Can't install template from git repo [\#36](https://github.com/rambler-ios/Generamba/issues/36)
|
117
|
-
- Can't find template by local fullpath [\#35](https://github.com/rambler-ios/Generamba/issues/35)
|
118
|
-
|
119
|
-
**Closed issues:**
|
120
|
-
|
121
|
-
- Need more information about dependencies [\#34](https://github.com/rambler-ios/Generamba/issues/34)
|
122
140
|
|
123
141
|
## [0.6.1](https://github.com/rambler-ios/Generamba/tree/0.6.1) (2015-11-21)
|
124
142
|
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.6.0...0.6.1)
|
125
143
|
|
126
|
-
**Fixed bugs:**
|
127
|
-
|
128
|
-
- The author name should be configured without `generamba setup` [\#31](https://github.com/rambler-ios/Generamba/issues/31)
|
129
|
-
- Sometimes Generamba fills in the wrong test target in the Rambafile [\#30](https://github.com/rambler-ios/Generamba/issues/30)
|
130
|
-
- Seems that Generamba doesn't add project name to the headers [\#29](https://github.com/rambler-ios/Generamba/issues/29)
|
131
|
-
|
132
|
-
**Closed issues:**
|
133
|
-
|
134
|
-
- Add a documentation for a .rambaspec file and overall template structure [\#24](https://github.com/rambler-ios/Generamba/issues/24)
|
135
|
-
|
136
144
|
## [0.6.0](https://github.com/rambler-ios/Generamba/tree/0.6.0) (2015-11-15)
|
137
145
|
[Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.5.0...0.6.0)
|
138
146
|
|
139
|
-
**Implemented enhancements:**
|
140
|
-
|
141
|
-
- Add a podfile\_path/cartfile\_path fields to a Rambafile [\#19](https://github.com/rambler-ios/Generamba/issues/19)
|
142
|
-
- Add a dependencies field to the .rambaspec [\#18](https://github.com/rambler-ios/Generamba/issues/18)
|
143
|
-
|
144
|
-
**Fixed bugs:**
|
145
|
-
|
146
|
-
- Duplicate file reference in project.pbxproj [\#20](https://github.com/rambler-ios/Generamba/issues/20)
|
147
|
-
|
148
147
|
## [0.5.0](https://github.com/rambler-ios/Generamba/tree/0.5.0) (2015-11-01)
|
149
148
|
|
150
149
|
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
*We keep evolving Generamba:* [changelog](https://github.com/rambler-ios/Generamba/blob/develop/CHANGELOG.md), [release notes](https://github.com/rambler-ios/Generamba/releases).
|
10
10
|
|
11
|
-
![Generamba Screenshot](
|
11
|
+
![Generamba Screenshot](https://habrastorage.org/files/b98/770/b37/b98770b37dc54de98daf0e22fea38478.gif)
|
12
12
|
|
13
13
|
### Key features
|
14
14
|
|
@@ -4,6 +4,8 @@ require 'generamba/helpers/rambafile_validator.rb'
|
|
4
4
|
require 'generamba/helpers/xcodeproj_helper.rb'
|
5
5
|
require 'generamba/helpers/dependency_checker.rb'
|
6
6
|
require 'generamba/helpers/gen_command_table_parameters_formatter.rb'
|
7
|
+
require 'generamba/helpers/module_validator.rb'
|
8
|
+
require 'generamba/helpers/module_info_generator.rb'
|
7
9
|
|
8
10
|
module Generamba::CLI
|
9
11
|
class Application < Thor
|
@@ -13,7 +15,7 @@ module Generamba::CLI
|
|
13
15
|
desc 'gen [MODULE_NAME] [TEMPLATE_NAME]', 'Creates a new VIPER module with a given name from a specific template'
|
14
16
|
method_option :description, :aliases => '-d', :desc => 'Provides a full description to the module'
|
15
17
|
method_option :author, :desc => 'Specifies the author name for generated module'
|
16
|
-
method_option :
|
18
|
+
method_option :project_targets, :desc => 'Specifies project targets for adding new module files'
|
17
19
|
method_option :module_file_path, :desc => 'Specifies a location in the filesystem for new files'
|
18
20
|
method_option :module_group_path, :desc => 'Specifies a location in Xcode groups for new files'
|
19
21
|
method_option :module_path, :desc => 'Specifies a location (both in the filesystem and Xcode) for new files'
|
@@ -37,20 +39,21 @@ module Generamba::CLI
|
|
37
39
|
setup_username_command = Generamba::CLI::SetupUsernameCommand.new
|
38
40
|
setup_username_command.setup_username
|
39
41
|
|
40
|
-
default_module_description = "#{module_name} module"
|
41
|
-
module_description = options[:description] ? options[:description] : default_module_description
|
42
|
-
|
43
42
|
rambafile = YAML.load_file(RAMBAFILE_NAME)
|
44
43
|
|
45
|
-
|
44
|
+
code_module = CodeModule.new(module_name, rambafile, options)
|
45
|
+
|
46
|
+
module_validator = ModuleValidator.new
|
47
|
+
module_validator.validate(code_module)
|
48
|
+
|
49
|
+
template = ModuleTemplate.new(template_name)
|
50
|
+
|
51
|
+
parameters = GenCommandTableParametersFormatter.prepare_parameters_for_displaying(code_module, template_name)
|
46
52
|
PrintTable.print_values(
|
47
53
|
values: parameters,
|
48
54
|
title: "Summary for gen #{module_name}"
|
49
55
|
)
|
50
56
|
|
51
|
-
template = ModuleTemplate.new(template_name)
|
52
|
-
code_module = CodeModule.new(module_name, module_description, rambafile, options)
|
53
|
-
|
54
57
|
DependencyChecker.check_all_required_dependencies_has_in_podfile(template.dependencies, code_module.podfile_path)
|
55
58
|
DependencyChecker.check_all_required_dependencies_has_in_cartfile(template.dependencies, code_module.cartfile_path)
|
56
59
|
|
@@ -65,7 +68,7 @@ module Generamba::CLI
|
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
68
|
-
generator = Generamba::ModuleGenerator.new
|
71
|
+
generator = Generamba::ModuleGenerator.new
|
69
72
|
generator.generate_module(module_name, code_module, template)
|
70
73
|
end
|
71
74
|
|
@@ -35,39 +35,58 @@ module Generamba::CLI
|
|
35
35
|
project_target = ask_index("Select the appropriate target for adding your MODULES (type the index):\n" + targets_prompt,project.targets)
|
36
36
|
include_tests = yes?('Are you using unit-tests in this project? (yes/no)')
|
37
37
|
|
38
|
+
test_target = nil
|
39
|
+
|
38
40
|
if include_tests
|
39
41
|
test_target = ask_index("Select the appropriate target for adding your TESTS (type the index):\n" + targets_prompt,project.targets)
|
40
42
|
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
should_add_all_modules_by_one_path = yes?('Do you want to add all your modules by one path? (yes/no)')
|
45
|
+
|
46
|
+
project_file_path = nil
|
47
|
+
project_group_path = nil
|
48
|
+
|
49
|
+
test_file_path = nil
|
50
|
+
test_group_path = nil
|
46
51
|
|
47
|
-
|
48
|
-
|
49
|
-
|
52
|
+
if should_add_all_modules_by_one_path || include_tests
|
53
|
+
should_use_same_paths = false
|
54
|
+
|
55
|
+
if should_add_all_modules_by_one_path
|
56
|
+
should_use_same_paths = yes?('Do you want to use the same paths for your files both in Xcode and the filesystem? (yes/no)')
|
50
57
|
end
|
51
|
-
else
|
52
|
-
project_group_path = ask('The default path for creating new modules (in Xcode groups):')
|
53
|
-
project_file_path = ask('The default path for creating new modules (in the filesystem):')
|
54
58
|
|
55
|
-
if
|
56
|
-
|
57
|
-
|
59
|
+
if should_use_same_paths
|
60
|
+
if should_add_all_modules_by_one_path
|
61
|
+
project_group_path = ask('The default path for creating new modules:')
|
62
|
+
project_file_path = project_group_path
|
63
|
+
end
|
64
|
+
|
65
|
+
if include_tests
|
66
|
+
test_group_path = ask('The default path for creating tests:')
|
67
|
+
test_file_path = test_group_path
|
68
|
+
end
|
69
|
+
else
|
70
|
+
if should_add_all_modules_by_one_path
|
71
|
+
project_group_path = ask('The default path for creating new modules (in Xcode groups):')
|
72
|
+
project_file_path = ask('The default path for creating new modules (in the filesystem):')
|
73
|
+
end
|
74
|
+
|
75
|
+
if include_tests
|
76
|
+
test_group_path = ask('The default path for creating tests (in Xcode groups):')
|
77
|
+
test_file_path = ask('The default path for creating tests (in the filesystem):')
|
78
|
+
end
|
58
79
|
end
|
59
80
|
end
|
60
81
|
|
61
82
|
using_pods = yes?('Are you using Cocoapods? (yes/no)')
|
62
83
|
if using_pods
|
63
|
-
properties[PODFILE_PATH_KEY] = ask_file_with_path('Podfile',
|
64
|
-
'Podfile')
|
84
|
+
properties[PODFILE_PATH_KEY] = ask_file_with_path('Podfile', 'Podfile')
|
65
85
|
end
|
66
86
|
|
67
87
|
using_carthage = yes?('Are you using Carthage? (yes/no)')
|
68
88
|
if using_carthage
|
69
|
-
properties[CARTFILE_PATH_KEY] = ask_file_with_path('Cartfile',
|
70
|
-
'Cartfile')
|
89
|
+
properties[CARTFILE_PATH_KEY] = ask_file_with_path('Cartfile', 'Cartfile')
|
71
90
|
end
|
72
91
|
|
73
92
|
should_add_templates = yes?('Do you want to add some well known templates to the Rambafile? (yes/no)')
|
@@ -79,21 +98,12 @@ module Generamba::CLI
|
|
79
98
|
]
|
80
99
|
end
|
81
100
|
|
82
|
-
properties[PROJECT_TARGET_KEY] = project_target.name
|
83
|
-
properties[PROJECT_FILE_PATH_KEY] = project_file_path
|
84
|
-
properties[PROJECT_GROUP_PATH_KEY] = project_group_path
|
85
|
-
|
86
|
-
if
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
if test_file_path
|
91
|
-
properties[TEST_FILE_PATH_KEY] = test_file_path
|
92
|
-
end
|
93
|
-
|
94
|
-
if test_group_path
|
95
|
-
properties[TEST_GROUP_PATH_KEY] = test_group_path
|
96
|
-
end
|
101
|
+
properties[PROJECT_TARGET_KEY] = project_target.name if project_target
|
102
|
+
properties[PROJECT_FILE_PATH_KEY] = project_file_path if project_file_path
|
103
|
+
properties[PROJECT_GROUP_PATH_KEY] = project_group_path if project_group_path
|
104
|
+
properties[TEST_TARGET_KEY] = test_target.name if test_target
|
105
|
+
properties[TEST_FILE_PATH_KEY] = test_file_path if test_file_path
|
106
|
+
properties[TEST_GROUP_PATH_KEY] = test_group_path if test_group_path
|
97
107
|
|
98
108
|
PrintTable.print_values(
|
99
109
|
values: properties,
|
@@ -6,15 +6,16 @@ project_name: {{ project_name }}
|
|
6
6
|
xcodeproj_path: {{ xcodeproj_path }}
|
7
7
|
{% if prefix != "" %}prefix: {{ prefix }}{% endif %}
|
8
8
|
|
9
|
-
### Code generation settings section
|
10
|
-
# The main project target name
|
11
|
-
project_target: {{ project_target }}
|
9
|
+
{% if (project_target != nil and project_target != "") or (project_file_path != nil and project_file_path != "") or (project_group_path != nil and project_group_path != "") %}### Code generation settings section
|
10
|
+
{% if project_target != nil and project_target != "" %}# The main project target name
|
11
|
+
project_target: {{ project_target }}{% endif %}
|
12
12
|
|
13
|
-
# The file path for new modules
|
14
|
-
project_file_path: {{ project_file_path }}
|
13
|
+
{% if project_file_path != nil and project_file_path != "" %}# The file path for new modules
|
14
|
+
project_file_path: {{ project_file_path }}{% endif %}
|
15
15
|
|
16
|
-
# The Xcode group path to new modules
|
17
|
-
project_group_path: {{ project_group_path }}
|
16
|
+
{% if project_group_path != nil and project_group_path != "" %}# The Xcode group path to new modules
|
17
|
+
project_group_path: {{ project_group_path }}{% endif %}
|
18
|
+
{% endif %}
|
18
19
|
|
19
20
|
{% if (test_target != nil and test_target != "") or (test_file_path != nil and test_file_path != "") or (test_group_path != nil and test_group_path != "") %}### Tests generation settings section
|
20
21
|
{% if test_target != nil and test_target != "" %}# The tests target name
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Generamba
|
2
2
|
|
3
3
|
SLASH_REGEX = /^\/|\/$/
|
4
|
+
C99IDENTIFIER = /[^\w]/
|
5
|
+
|
6
|
+
PATH_TYPE_MODULE = 'module'
|
7
|
+
PATH_TYPE_TEST = 'test'
|
4
8
|
|
5
9
|
# Represents currently generating code module
|
6
10
|
class CodeModule
|
@@ -11,6 +15,7 @@ module Generamba
|
|
11
15
|
:year,
|
12
16
|
:prefix,
|
13
17
|
:project_name,
|
18
|
+
:product_module_name,
|
14
19
|
:xcodeproj_path,
|
15
20
|
:module_file_path,
|
16
21
|
:module_group_path,
|
@@ -22,79 +27,69 @@ module Generamba
|
|
22
27
|
:cartfile_path,
|
23
28
|
:custom_parameters
|
24
29
|
|
25
|
-
def initialize(name,
|
30
|
+
def initialize(name, rambafile, options)
|
26
31
|
# Base initialization
|
27
32
|
@name = name
|
28
|
-
@description = description
|
29
|
-
|
30
|
-
if rambafile[AUTHOR_NAME_KEY] != nil
|
31
|
-
@author = rambafile[AUTHOR_NAME_KEY]
|
32
|
-
else
|
33
|
-
@author = UserPreferences.obtain_username
|
34
|
-
end
|
35
|
-
|
33
|
+
@description = options[:description] ? options[:description] : "#{name} module"
|
34
|
+
@author = rambafile[AUTHOR_NAME_KEY] ? rambafile[AUTHOR_NAME_KEY] : UserPreferences.obtain_username
|
36
35
|
@company = rambafile[COMPANY_KEY]
|
37
36
|
@year = Time.now.year.to_s
|
38
37
|
|
39
38
|
@prefix = rambafile[PROJECT_PREFIX_KEY]
|
40
39
|
@project_name = rambafile[PROJECT_NAME_KEY]
|
40
|
+
@product_module_name = rambafile[PRODUCT_MODULE_NAME_KEY] || @project_name.gsub(C99IDENTIFIER, '_')
|
41
41
|
@xcodeproj_path = rambafile[XCODEPROJ_PATH_KEY]
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
setup_file_and_group_paths(rambafile[PROJECT_FILE_PATH_KEY], rambafile[PROJECT_GROUP_PATH_KEY], PATH_TYPE_MODULE)
|
44
|
+
setup_file_and_group_paths(rambafile[TEST_FILE_PATH_KEY], rambafile[TEST_GROUP_PATH_KEY], PATH_TYPE_TEST)
|
45
45
|
|
46
|
-
@
|
47
|
-
@
|
46
|
+
@project_targets = [rambafile[PROJECT_TARGET_KEY]] if rambafile[PROJECT_TARGET_KEY]
|
47
|
+
@project_targets = rambafile[PROJECT_TARGETS_KEY] if rambafile[PROJECT_TARGETS_KEY]
|
48
48
|
|
49
|
-
@
|
50
|
-
@
|
51
|
-
|
52
|
-
@test_targets = [rambafile[TEST_TARGET_KEY]] if rambafile[TEST_TARGET_KEY] != nil
|
53
|
-
@test_targets = rambafile[TEST_TARGETS_KEY] if rambafile[TEST_TARGETS_KEY] != nil
|
49
|
+
@test_targets = [rambafile[TEST_TARGET_KEY]] if rambafile[TEST_TARGET_KEY]
|
50
|
+
@test_targets = rambafile[TEST_TARGETS_KEY] if rambafile[TEST_TARGETS_KEY]
|
54
51
|
|
55
52
|
# Custom parameters
|
56
53
|
@custom_parameters = options[:custom_parameters]
|
57
54
|
|
58
55
|
# Options adaptation
|
59
56
|
@author = options[:author] if options[:author]
|
60
|
-
@project_targets = options[:
|
57
|
+
@project_targets = options[:project_targets].split(',') if options[:project_targets]
|
61
58
|
@test_targets = options[:test_targets].split(',') if options[:test_targets]
|
59
|
+
|
60
|
+
setup_file_and_group_paths(options[:module_file_path], options[:module_group_path], PATH_TYPE_MODULE)
|
61
|
+
setup_file_and_group_paths(options[:test_file_path], options[:test_group_path], PATH_TYPE_TEST)
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
63
|
+
# The priority is given to `module_path` and 'test_path' options
|
64
|
+
setup_file_and_group_paths(options[:module_path], options[:module_path], PATH_TYPE_MODULE)
|
65
|
+
setup_file_and_group_paths(options[:test_path], options[:test_path], PATH_TYPE_TEST)
|
67
66
|
|
68
|
-
if
|
69
|
-
|
70
|
-
|
71
|
-
end
|
67
|
+
@podfile_path = rambafile[PODFILE_PATH_KEY] if rambafile[PODFILE_PATH_KEY]
|
68
|
+
@cartfile_path = rambafile[CARTFILE_PATH_KEY] if rambafile[CARTFILE_PATH_KEY]
|
69
|
+
end
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
71
|
+
def setup_file_and_group_paths(file_path, group_path, path_type)
|
72
|
+
if file_path || group_path
|
73
|
+
variable_name = "#{path_type}_file_path"
|
77
74
|
|
78
|
-
|
79
|
-
|
80
|
-
@test_group_path = Pathname.new(@test_group_path).join(@name)
|
81
|
-
end
|
75
|
+
if file_path || !instance_variable_get("@#{variable_name}")
|
76
|
+
file_path = group_path unless file_path
|
82
77
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
@module_group_path = Pathname.new(@module_path).join(@name)
|
88
|
-
end
|
78
|
+
variable_value = file_path.gsub(SLASH_REGEX, '')
|
79
|
+
variable_value = Pathname.new(variable_value).join(@name)
|
80
|
+
instance_variable_set("@#{variable_name}", variable_value)
|
81
|
+
end
|
89
82
|
|
90
|
-
|
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
|
83
|
+
variable_name = "#{path_type}_group_path"
|
95
84
|
|
96
|
-
|
97
|
-
|
85
|
+
if group_path || !instance_variable_get("@#{variable_name}")
|
86
|
+
group_path = file_path unless group_path
|
87
|
+
|
88
|
+
variable_value = group_path.gsub(SLASH_REGEX, '')
|
89
|
+
variable_value = Pathname.new(variable_value).join(@name)
|
90
|
+
instance_variable_set("@#{variable_name}", variable_value)
|
91
|
+
end
|
92
|
+
end
|
98
93
|
end
|
99
94
|
end
|
100
|
-
end
|
95
|
+
end
|
@@ -6,12 +6,12 @@ module Generamba
|
|
6
6
|
class ContentGenerator
|
7
7
|
|
8
8
|
# Generates and returns a filename and a body of a specific code file.
|
9
|
-
# @param file [
|
10
|
-
# @param
|
9
|
+
# @param file [Hash<String,String>] A hashmap with template's filename and filepath
|
10
|
+
# @param scope [Hash<String,String>] A hashmap with module info
|
11
11
|
# @param template [ModuleTemplate] The model describing a Generamba template used for code generation
|
12
12
|
#
|
13
13
|
# @return [String], [String] The generated file_name and body
|
14
|
-
def self.create_file(file,
|
14
|
+
def self.create_file(file, scope, template)
|
15
15
|
file_source = IO.read(template.template_path.join(file[TEMPLATE_FILE_PATH_KEY]))
|
16
16
|
Liquid::Template.file_system = Liquid::LocalFileSystem.new(template.template_path.join('snippets'), '%s.liquid')
|
17
17
|
|
@@ -20,28 +20,8 @@ module Generamba
|
|
20
20
|
|
21
21
|
file_basename = File.basename(file[TEMPLATE_FILE_NAME_KEY])
|
22
22
|
|
23
|
-
module_info =
|
24
|
-
|
25
|
-
'description' => code_module.description,
|
26
|
-
'project_name' => code_module.project_name,
|
27
|
-
'project_targets' => code_module.project_targets,
|
28
|
-
'test_targets' => code_module.test_targets
|
29
|
-
}
|
30
|
-
|
31
|
-
developer = {
|
32
|
-
'name' => code_module.author,
|
33
|
-
'company' => code_module.company
|
34
|
-
}
|
35
|
-
|
36
|
-
scope = {
|
37
|
-
'year' => code_module.year,
|
38
|
-
'date' => Time.now.strftime('%d/%m/%Y'),
|
39
|
-
'developer' => developer,
|
40
|
-
'module_info' => module_info,
|
41
|
-
'prefix' => code_module.prefix,
|
42
|
-
'custom_parameters' => code_module.custom_parameters
|
43
|
-
}
|
44
|
-
|
23
|
+
module_info = scope['module_info']
|
24
|
+
|
45
25
|
module_info['file_basename'] = file_basename
|
46
26
|
|
47
27
|
file_name = filename_template.render(scope)
|
@@ -55,9 +35,9 @@ module Generamba
|
|
55
35
|
end
|
56
36
|
|
57
37
|
def self.file_name_template(file)
|
58
|
-
template_default_text =
|
59
|
-
template_text = file[
|
38
|
+
template_default_text = '{{ prefix }}{{ module_info.name }}{{ module_info.file_basename }}'
|
39
|
+
template_text = file[TEMPLATE_FILE_CUSTOM_NAME_KEY] || template_default_text
|
60
40
|
return Liquid::Template.parse(template_text)
|
61
41
|
end
|
62
42
|
end
|
63
|
-
end
|
43
|
+
end
|
@@ -6,10 +6,18 @@ module Generamba
|
|
6
6
|
class ModuleTemplate
|
7
7
|
attr_reader :template_name, :template_path, :code_files, :test_files, :dependencies
|
8
8
|
|
9
|
-
def initialize(name)
|
9
|
+
def initialize(name, options = nil)
|
10
10
|
spec_path = TemplateHelper.obtain_spec(name)
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
unless options
|
13
|
+
spec = YAML.load_file(spec_path)
|
14
|
+
else
|
15
|
+
spec_source = IO.read(spec_path)
|
16
|
+
spec_template = Liquid::Template.parse(spec_source)
|
17
|
+
spec_content = spec_template.render(options)
|
18
|
+
spec = YAML.load(spec_content)
|
19
|
+
end
|
20
|
+
|
13
21
|
@code_files = spec[TEMPLATE_CODE_FILES_KEY]
|
14
22
|
@test_files = spec[TEMPLATE_TEST_FILES_KEY]
|
15
23
|
@template_name = spec[TEMPLATE_NAME_KEY]
|
@@ -12,6 +12,8 @@ module Generamba
|
|
12
12
|
PROJECT_FILE_PATH_KEY = 'project_file_path'
|
13
13
|
PROJECT_GROUP_PATH_KEY = 'project_group_path'
|
14
14
|
|
15
|
+
PRODUCT_MODULE_NAME_KEY = 'product_module_name'
|
16
|
+
|
15
17
|
TEST_TARGET_KEY = 'test_target'
|
16
18
|
TEST_TARGETS_KEY = 'test_targets'
|
17
19
|
TEST_FILE_PATH_KEY = 'test_file_path'
|
@@ -26,4 +28,4 @@ module Generamba
|
|
26
28
|
TEMPLATE_DECLARATION_LOCAL_KEY = 'local'
|
27
29
|
TEMPLATE_DECLARATION_GIT_KEY = 'git'
|
28
30
|
TEMPLATE_DECLARATION_BRANCH_KEY = 'branch'
|
29
|
-
end
|
31
|
+
end
|