generamba 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50fbd6916f61f027113fed9afaa21334582e1487
4
- data.tar.gz: 3f1d2d9aa01233d3ac1eb9502ca8acb01c1eab35
3
+ metadata.gz: 26c38791a3b444b271d70177be32f673d9c40adb
4
+ data.tar.gz: c6c5052b488f919e873dd2522ae29839accaff39
5
5
  SHA512:
6
- metadata.gz: f6b424caf3eb315a22af4aa06b1204feb32ed60d05f01810c577156259b961f13b6753c00825d3515bf43f80d6ccf3ecf5ca14218b24da11b83cb52dea5466dc
7
- data.tar.gz: bafea13e2d3abe422cb824d82fbee0d0884f0844aa540978dcd36c6e2fdb6e076b66ece4a780d6d4095794393d3e19b7d1e5c16454a52d22f4f79429995d38c1
6
+ metadata.gz: 906ce76cc09b5c08321f42d03d91bd391482818bdf4fa8b252857905d517bad494b89cced56278e3209a46884539c2bf5a0f086e50ffd31a8712880aa4440693
7
+ data.tar.gz: 0d62fadb4919f0d1420e704cdcde37e875c43d7be692e34dd9ee3fb3e9dffb85b3e239cf156610b39cba9396f27f04f4ec7ca28abea957da776b5c9ac9e392f5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Change Log
2
2
 
3
+ ## [1.1.0](https://github.com/rambler-ios/Generamba/tree/1.1.0) (2016-09-05)
4
+ [Full Changelog](https://github.com/rambler-ios/Generamba/compare/1.0.0...1.1.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Refactoring rambafile and module validation [\#144](https://github.com/rambler-ios/Generamba/issues/144)
9
+ - Update gen command parameters table [\#142](https://github.com/rambler-ios/Generamba/issues/142)
10
+ - If statement in .rambaspec [\#128](https://github.com/rambler-ios/Generamba/issues/128)
11
+ - Ask user, he want create all modules by one path? [\#126](https://github.com/rambler-ios/Generamba/issues/126)
12
+
13
+ **Fixed bugs:**
14
+
15
+ - Generates files with a wrongs paths. [\#138](https://github.com/rambler-ios/Generamba/issues/138)
16
+ - Install templates from git repo is broken? [\#135](https://github.com/rambler-ios/Generamba/issues/135)
17
+ - Error creating the Xcode group path to new modules [\#129](https://github.com/rambler-ios/Generamba/issues/129)
18
+
19
+ **Closed issues:**
20
+
21
+ - Error: `parse': \(Rambafile\): block sequence entries are not allowed [\#127](https://github.com/rambler-ios/Generamba/issues/127)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - \[RESOLVED\] Added question in setup command \#126 [\#146](https://github.com/rambler-ios/Generamba/pull/146) ([Beniamiiin](https://github.com/Beniamiiin))
26
+ - \[RESOLVED\] Updated logic of rambafile and module validation \#144 [\#145](https://github.com/rambler-ios/Generamba/pull/145) ([Beniamiiin](https://github.com/Beniamiiin))
27
+ - \[RESOLVED\] Updated gen command parameters table \#142 [\#143](https://github.com/rambler-ios/Generamba/pull/143) ([Beniamiiin](https://github.com/Beniamiiin))
28
+ - \[RESOLVED\] Added ability use custom parameters in rambaspec \#128 [\#141](https://github.com/rambler-ios/Generamba/pull/141) ([Beniamiiin](https://github.com/Beniamiiin))
29
+ - \[FIXED\] Fixed bug \#138 [\#140](https://github.com/rambler-ios/Generamba/pull/140) ([Beniamiiin](https://github.com/Beniamiiin))
30
+ - Added product\_module\_name to code\_module [\#139](https://github.com/rambler-ios/Generamba/pull/139) ([mogol](https://github.com/mogol))
31
+ - A little refactoring [\#137](https://github.com/rambler-ios/Generamba/pull/137) ([Beniamiiin](https://github.com/Beniamiiin))
32
+ - Support Ruby 2.3.1 [\#134](https://github.com/rambler-ios/Generamba/pull/134) ([ivaravko](https://github.com/ivaravko))
33
+ - Helpers code style [\#133](https://github.com/rambler-ios/Generamba/pull/133) ([ivaravko](https://github.com/ivaravko))
34
+ - Adds Code Climate config [\#132](https://github.com/rambler-ios/Generamba/pull/132) ([ivaravko](https://github.com/ivaravko))
35
+
3
36
  ## [1.0.0](https://github.com/rambler-ios/Generamba/tree/1.0.0) (2016-07-23)
4
37
  [Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.8...1.0.0)
5
38
 
@@ -10,17 +43,14 @@
10
43
  - Gem dependency of cocoapods-core-0.39.0 [\#114](https://github.com/rambler-ios/Generamba/issues/114)
11
44
  - Remove adding module name in module\_group\_path if it set from cli [\#98](https://github.com/rambler-ios/Generamba/issues/98)
12
45
  - 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)
46
+ - Automatic tests generation based on protocols and class interfaces [\#71](https://github.com/rambler-ios/Generamba/issues/71)
47
+ - Track all modules created by Generamba [\#70](https://github.com/rambler-ios/Generamba/issues/70)
14
48
 
15
49
  **Fixed bugs:**
16
50
 
17
51
  - Can't add file with type . Only 'source' and 'resource' are acceptable [\#116](https://github.com/rambler-ios/Generamba/issues/116)
18
52
  - 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
53
 
20
- **Closed issues:**
21
-
22
- - Generamba as file converter [\#41](https://github.com/rambler-ios/Generamba/issues/41)
23
-
24
54
  ## [0.7.8](https://github.com/rambler-ios/Generamba/tree/0.7.8) (2016-05-16)
25
55
  [Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.7...0.7.8)
26
56
 
@@ -66,6 +96,7 @@
66
96
 
67
97
  **Implemented enhancements:**
68
98
 
99
+ - Asks the user if he needed tests in `generamba setup` command [\#85](https://github.com/rambler-ios/Generamba/issues/85)
69
100
  - Improve the visualization of commands with parameters [\#69](https://github.com/rambler-ios/Generamba/issues/69)
70
101
  - Can we introduce something similar to view partials in rails \(for duplicated parts of views\) [\#62](https://github.com/rambler-ios/Generamba/issues/62)
71
102
 
@@ -88,6 +119,7 @@
88
119
  **Closed issues:**
89
120
 
90
121
  - Can we use constants from rambafile in templates? [\#81](https://github.com/rambler-ios/Generamba/issues/81)
122
+ - Arguments for `generamba gen Name modulename` [\#80](https://github.com/rambler-ios/Generamba/issues/80)
91
123
 
92
124
  ## [0.7.2](https://github.com/rambler-ios/Generamba/tree/0.7.2) (2016-01-10)
93
125
  [Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.7.1...0.7.2)
@@ -100,6 +132,7 @@
100
132
  **Fixed bugs:**
101
133
 
102
134
  - Don't set target in swift projects [\#65](https://github.com/rambler-ios/Generamba/issues/65)
135
+ - Errors if default path is empty [\#64](https://github.com/rambler-ios/Generamba/issues/64)
103
136
  - Default template set can not be used [\#60](https://github.com/rambler-ios/Generamba/issues/60)
104
137
  - Incorrect behavior when generate module which already exists [\#52](https://github.com/rambler-ios/Generamba/issues/52)
105
138
 
@@ -114,7 +147,7 @@
114
147
 
115
148
  **Implemented enhancements:**
116
149
 
117
- - Remove the Settingslogic dependency [\#42](https://github.com/rambler-ios/Generamba/issues/42)
150
+ - Podfile path setup during generamba setup needs clarification [\#50](https://github.com/rambler-ios/Generamba/issues/50)
118
151
 
119
152
  **Fixed bugs:**
120
153
 
@@ -127,17 +160,9 @@
127
160
  ## [0.7.0](https://github.com/rambler-ios/Generamba/tree/0.7.0) (2015-12-13)
128
161
  [Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.6.2...0.7.0)
129
162
 
130
- **Fixed bugs:**
131
-
132
- - undefined method `each' for nil:NilClass \(NoMethodError\) [\#37](https://github.com/rambler-ios/Generamba/issues/37)
133
-
134
163
  ## [0.6.2](https://github.com/rambler-ios/Generamba/tree/0.6.2) (2015-11-25)
135
164
  [Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.6.1...0.6.2)
136
165
 
137
- **Fixed bugs:**
138
-
139
- - Can't install template from git repo [\#36](https://github.com/rambler-ios/Generamba/issues/36)
140
-
141
166
  ## [0.6.1](https://github.com/rambler-ios/Generamba/tree/0.6.1) (2015-11-21)
142
167
  [Full Changelog](https://github.com/rambler-ios/Generamba/compare/0.6.0...0.6.1)
143
168
 
@@ -16,8 +16,8 @@ module Generamba::CLI
16
16
  method_option :description, :aliases => '-d', :desc => 'Provides a full description to the module'
17
17
  method_option :author, :desc => 'Specifies the author name for generated module'
18
18
  method_option :project_targets, :desc => 'Specifies project targets for adding new module files'
19
- method_option :module_file_path, :desc => 'Specifies a location in the filesystem for new files'
20
- method_option :module_group_path, :desc => 'Specifies a location in Xcode groups for new files'
19
+ method_option :project_file_path, :desc => 'Specifies a location in the filesystem for new files'
20
+ method_option :project_group_path, :desc => 'Specifies a location in Xcode groups for new files'
21
21
  method_option :module_path, :desc => 'Specifies a location (both in the filesystem and Xcode) for new files'
22
22
  method_option :test_targets, :desc => 'Specifies project targets for adding new test files'
23
23
  method_option :test_file_path, :desc => 'Specifies a location in the filesystem for new test files'
@@ -25,7 +25,6 @@ module Generamba::CLI
25
25
  method_option :test_path, :desc => 'Specifies a location (both in the filesystem and Xcode) for new test files'
26
26
  method_option :custom_parameters, :type => :hash, :default => {}, :desc => 'Specifies extra parameters in format `key1:value1 key2:value2` for usage during code generation'
27
27
  def gen(module_name, template_name)
28
-
29
28
  does_rambafile_exist = Dir[RAMBAFILE_NAME].count > 0
30
29
 
31
30
  unless does_rambafile_exist
@@ -58,7 +57,7 @@ module Generamba::CLI
58
57
  DependencyChecker.check_all_required_dependencies_has_in_cartfile(template.dependencies, code_module.cartfile_path)
59
58
 
60
59
  project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
61
- module_group_already_exists = XcodeprojHelper.module_with_group_path_already_exists(project, code_module.module_group_path)
60
+ module_group_already_exists = XcodeprojHelper.module_with_group_path_already_exists(project, code_module.project_group_path)
62
61
 
63
62
  if module_group_already_exists
64
63
  replace_exists_module = yes?("#{module_name} module already exists. Replace? (yes/no)")
@@ -3,7 +3,7 @@ module Generamba
3
3
  SLASH_REGEX = /^\/|\/$/
4
4
  C99IDENTIFIER = /[^\w]/
5
5
 
6
- PATH_TYPE_MODULE = 'module'
6
+ PATH_TYPE_PROJECT = 'project'
7
7
  PATH_TYPE_TEST = 'test'
8
8
 
9
9
  # Represents currently generating code module
@@ -17,8 +17,8 @@ module Generamba
17
17
  :project_name,
18
18
  :product_module_name,
19
19
  :xcodeproj_path,
20
- :module_file_path,
21
- :module_group_path,
20
+ :project_file_path,
21
+ :project_group_path,
22
22
  :test_file_path,
23
23
  :test_group_path,
24
24
  :project_targets,
@@ -37,10 +37,13 @@ module Generamba
37
37
 
38
38
  @prefix = rambafile[PROJECT_PREFIX_KEY]
39
39
  @project_name = rambafile[PROJECT_NAME_KEY]
40
- @product_module_name = rambafile[PRODUCT_MODULE_NAME_KEY] || @project_name.gsub(C99IDENTIFIER, '_')
40
+
41
+ @product_module_name = rambafile[PRODUCT_MODULE_NAME_KEY]
42
+ @product_module_name = @project_name.gsub(C99IDENTIFIER, '_') if !@product_module_name && @project_name
43
+
41
44
  @xcodeproj_path = rambafile[XCODEPROJ_PATH_KEY]
42
45
 
43
- setup_file_and_group_paths(rambafile[PROJECT_FILE_PATH_KEY], rambafile[PROJECT_GROUP_PATH_KEY], PATH_TYPE_MODULE)
46
+ setup_file_and_group_paths(rambafile[PROJECT_FILE_PATH_KEY], rambafile[PROJECT_GROUP_PATH_KEY], PATH_TYPE_PROJECT)
44
47
  setup_file_and_group_paths(rambafile[TEST_FILE_PATH_KEY], rambafile[TEST_GROUP_PATH_KEY], PATH_TYPE_TEST)
45
48
 
46
49
  @project_targets = [rambafile[PROJECT_TARGET_KEY]] if rambafile[PROJECT_TARGET_KEY]
@@ -57,17 +60,19 @@ module Generamba
57
60
  @project_targets = options[:project_targets].split(',') if options[:project_targets]
58
61
  @test_targets = options[:test_targets].split(',') if options[:test_targets]
59
62
 
60
- setup_file_and_group_paths(options[:module_file_path], options[:module_group_path], PATH_TYPE_MODULE)
63
+ setup_file_and_group_paths(options[:project_file_path], options[:project_group_path], PATH_TYPE_PROJECT)
61
64
  setup_file_and_group_paths(options[:test_file_path], options[:test_group_path], PATH_TYPE_TEST)
62
65
 
63
66
  # 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)
67
+ setup_file_and_group_paths(options[:module_path], options[:module_path], PATH_TYPE_PROJECT)
65
68
  setup_file_and_group_paths(options[:test_path], options[:test_path], PATH_TYPE_TEST)
66
69
 
67
70
  @podfile_path = rambafile[PODFILE_PATH_KEY] if rambafile[PODFILE_PATH_KEY]
68
71
  @cartfile_path = rambafile[CARTFILE_PATH_KEY] if rambafile[CARTFILE_PATH_KEY]
69
72
  end
70
73
 
74
+ private
75
+
71
76
  def setup_file_and_group_paths(file_path, group_path, path_type)
72
77
  if file_path || group_path
73
78
  variable_name = "#{path_type}_file_path"
@@ -7,11 +7,11 @@ module Generamba
7
7
  def self.prepare_parameters_for_displaying(code_module, template_name)
8
8
  params = {}
9
9
 
10
- params['Targets'] = code_module.project_targets.join(',')
11
- params['Module path'] = code_module.module_file_path
10
+ params['Targets'] = code_module.project_targets.join(',') if code_module.project_targets
11
+ params['Module path'] = code_module.project_file_path if code_module.project_file_path
12
12
 
13
- if code_module.module_file_path != code_module.module_group_path
14
- params['Module group path'] = code_module.module_group_path
13
+ if code_module.project_file_path != code_module.project_group_path
14
+ params['Module group path'] = code_module.project_group_path
15
15
  end
16
16
 
17
17
  params['Test targets'] = code_module.test_targets.join(',') if code_module.test_targets
@@ -23,7 +23,7 @@ module Generamba
23
23
 
24
24
  params['Template'] = template_name
25
25
 
26
- if code_module.custom_parameters
26
+ unless code_module.custom_parameters.empty?
27
27
  params['Custom parameters'] = code_module.custom_parameters.to_json
28
28
  end
29
29
 
@@ -8,6 +8,7 @@ module Generamba
8
8
  'name' => code_module.name,
9
9
  'description' => code_module.description,
10
10
  'project_name' => code_module.project_name,
11
+ 'product_module_name' => code_module.product_module_name,
11
12
  'project_targets' => code_module.project_targets,
12
13
  'test_targets' => code_module.test_targets
13
14
  }
@@ -2,18 +2,17 @@ module Generamba
2
2
  # Provides methods for validating module
3
3
  class ModuleValidator
4
4
 
5
+ TARGET_TYPE_PROJECT = 'project'
6
+ TARGET_TYPE_TEST = 'test'
7
+
5
8
  # Method validates module
6
9
  # @param code_module [CodeModule] The instance of CodeModule
7
10
  #
8
11
  # @return [Void]
9
12
  def validate(code_module)
10
13
  mandatory_fields = [COMPANY_KEY,
11
- PROJECT_PREFIX_KEY,
12
14
  PROJECT_NAME_KEY,
13
- XCODEPROJ_PATH_KEY,
14
- PROJECT_TARGETS_KEY,
15
- 'module_file_path',
16
- 'module_group_path']
15
+ XCODEPROJ_PATH_KEY]
17
16
 
18
17
  mandatory_fields.each do |field|
19
18
  unless code_module.instance_variable_get("@#{field}")
@@ -21,6 +20,65 @@ module Generamba
21
20
  exit
22
21
  end
23
22
  end
23
+
24
+ project_failure_fields = all_project_failure_fields(code_module)
25
+ test_failure_fields = all_test_failure_fields(code_module)
26
+ failure_fields = project_failure_fields + test_failure_fields
27
+
28
+ if failure_fields.count > 0
29
+ puts "Module is broken! *#{failure_fields}* field cannot be empty, because it is mandatory.".red
30
+ exit
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ # Method which return all project failure fields
37
+ # @param code_module [CodeModule] The instance of CodeModule
38
+ #
39
+ # @return [Array]
40
+ def all_project_failure_fields(code_module)
41
+ return [] if !code_module.project_targets && !code_module.project_file_path && !code_module.project_group_path
42
+
43
+ all_nil_mandatory_fields_for_target_type(TARGET_TYPE_PROJECT, code_module)
44
+ end
45
+
46
+ # Method which return all test failure fields
47
+ # @param code_module [CodeModule] The instance of CodeModule
48
+ #
49
+ # @return [Array]
50
+ def all_test_failure_fields(code_module)
51
+ return [] if !code_module.test_targets && !code_module.test_file_path && !code_module.test_group_path
52
+
53
+ all_nil_mandatory_fields_for_target_type(TARGET_TYPE_TEST, code_module)
54
+ end
55
+
56
+ # Method which return all failure fields for target_type
57
+ # @param target_type [String] "project" or "test"
58
+ # @param code_module [CodeModule] The instance of CodeModule
59
+ #
60
+ # @return [Array]
61
+ def all_nil_mandatory_fields_for_target_type(target_type, code_module)
62
+ fields = []
63
+
64
+ variable_name = "#{target_type}_targets"
65
+
66
+ unless code_module.instance_variable_get("@#{variable_name}")
67
+ target_const_value = Generamba.const_get(target_type.upcase + '_TARGET_KEY')
68
+ targets_const_value = Generamba.const_get(target_type.upcase + '_TARGETS_KEY')
69
+ fields.push(target_const_value)
70
+ fields.push(targets_const_value)
71
+ end
72
+
73
+ variable_name = "#{target_type}_file_path"
74
+ file_path_const_value = Generamba.const_get(target_type.upcase + '_FILE_PATH_KEY')
75
+ fields.push(file_path_const_value) unless code_module.instance_variable_get("@#{variable_name}")
76
+
77
+ variable_name = "#{target_type}_group_path"
78
+ group_path_const_value = Generamba.const_get(target_type.upcase + '_GROUP_PATH_KEY')
79
+ fields.push(group_path_const_value) unless code_module.instance_variable_get("@#{variable_name}")
80
+
81
+ fields
24
82
  end
25
83
 
26
84
  end
@@ -9,97 +9,10 @@ module Generamba
9
9
  file_contents = open(path).read
10
10
  preferences = file_contents.empty? ? {} : YAML.load(file_contents).to_hash
11
11
 
12
- mandatory_fields = [COMPANY_KEY,
13
- PROJECT_NAME_KEY,
14
- XCODEPROJ_PATH_KEY]
15
-
16
- mandatory_fields.each do |field|
17
- unless preferences[field]
18
- puts "Rambafile is broken! *#{field}* field cannot be empty, because it is mandatory. Either add it manually, or run *generamba setup*.".red
19
- exit
20
- end
21
- end
22
-
23
- project_failure_fields = all_project_failure_fields(preferences)
24
- test_failure_fields = all_test_failure_fields(preferences)
25
- failure_fields = project_failure_fields + test_failure_fields
26
-
27
- if failure_fields.count > 0
28
- puts "Rambafile is broken! Cannot find any of #{failure_fields} fields, one of them is mandatory. Either add it manually, or run *generamba setup*.".red
29
- exit
30
- end
31
-
32
12
  unless preferences[TEMPLATES_KEY]
33
13
  puts "You can't run *generamba gen* without any templates installed. Add their declarations to a Rambafile and run *generamba template install*.".red
34
14
  exit
35
15
  end
36
16
  end
37
-
38
- private
39
-
40
- # Method which return all project failure fields
41
- # @param preferences [Hash] Converted Rambafile
42
- #
43
- # @return [Array]
44
- def all_project_failure_fields(preferences)
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)
51
- end
52
-
53
- # Method which return all test failure fields
54
- # @param preferences [Hash] Converted Rambafile
55
- #
56
- # @return [Array]
57
- def all_test_failure_fields(preferences)
58
- target = preferences[TEST_TARGET_KEY]
59
- targets = preferences[TEST_TARGETS_KEY]
60
- file_path = preferences[TEST_FILE_PATH_KEY]
61
- group_path = preferences[TEST_GROUP_PATH_KEY]
62
-
63
- has_test_fields = target || targets || file_path || group_path
64
-
65
- return [] unless has_test_fields
66
-
67
- all_nil_mandatory_fields_for_target_type('test', preferences)
68
- end
69
-
70
- # Method which return all failure fields for target_type
71
- # @param target_type [String] "project" or "test"
72
- # @param preferences [Hash] Converted Rambafile
73
- #
74
- # @return [Array]
75
- def all_nil_mandatory_fields_for_target_type(target_type, preferences)
76
- target_type = target_type.upcase
77
-
78
- target_const_value = Generamba.const_get(target_type + '_TARGET_KEY')
79
- targets_const_value = Generamba.const_get(target_type + '_TARGETS_KEY')
80
-
81
- target = preferences[target_const_value]
82
- targets = preferences[targets_const_value]
83
-
84
- fields = []
85
-
86
- if !target && (!targets || (targets && targets.count == 0))
87
- fields.push(target_const_value)
88
- end
89
-
90
- file_path_const_value = Generamba.const_get(target_type + '_FILE_PATH_KEY')
91
-
92
- unless preferences[file_path_const_value]
93
- fields.push(file_path_const_value)
94
- end
95
-
96
- group_path_const_value = Generamba.const_get(target_type + '_GROUP_PATH_KEY')
97
-
98
- unless preferences[group_path_const_value]
99
- fields.push(group_path_const_value)
100
- end
101
-
102
- fields
103
- end
104
17
  end
105
18
  end
@@ -20,7 +20,10 @@ module Generamba
20
20
  #
21
21
  # @return [void]
22
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)
23
+ file_path = dir_path
24
+ file_path = file_path.join(file_group_path) if file_group_path
25
+ file_path = file_path.join(file_name) if file_name
26
+
24
27
  module_group = self.retrieve_group_or_create_if_needed(group_path, dir_path, file_group_path, project, true)
25
28
  xcode_file = module_group.new_file(File.absolute_path(file_path))
26
29
 
@@ -13,36 +13,31 @@ module Generamba
13
13
  project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
14
14
 
15
15
  # Configuring file paths
16
- FileUtils.mkdir_p code_module.module_file_path
17
-
18
- if code_module.test_file_path != nil
19
- FileUtils.mkdir_p code_module.test_file_path
20
- end
16
+ FileUtils.mkdir_p code_module.project_file_path if code_module.project_file_path
17
+ FileUtils.mkdir_p code_module.test_file_path if code_module.test_file_path
21
18
 
22
19
  # Creating code files
23
- puts('Creating code files...')
24
- process_files_if_needed(template.code_files,
25
- name,
26
- code_module,
27
- template,
28
- project,
29
- code_module.project_targets,
30
- code_module.module_group_path,
31
- code_module.module_file_path)
20
+ if code_module.project_targets && code_module.project_group_path && code_module.project_file_path
21
+ puts('Creating code files...')
22
+ process_files_if_needed(template.code_files,
23
+ code_module,
24
+ template,
25
+ project,
26
+ code_module.project_targets,
27
+ code_module.project_group_path,
28
+ code_module.project_file_path)
29
+ end
32
30
 
33
31
  # Creating test files
34
- included_tests = code_module.test_targets && code_module.test_group_path && code_module.test_file_path
35
-
36
- if included_tests
32
+ if code_module.test_targets && code_module.test_group_path && code_module.test_file_path
37
33
  puts('Creating test files...')
38
34
  process_files_if_needed(template.test_files,
39
- name,
40
- code_module,
41
- template,
42
- project,
43
- code_module.test_targets,
44
- code_module.test_group_path,
45
- code_module.test_file_path)
35
+ code_module,
36
+ template,
37
+ project,
38
+ code_module.test_targets,
39
+ code_module.test_group_path,
40
+ code_module.test_file_path)
46
41
  end
47
42
 
48
43
  # Saving the current changes in the Xcode project
@@ -50,13 +45,13 @@ module Generamba
50
45
 
51
46
  puts 'Module successfully created!'
52
47
  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
48
+ puts "Project file path: #{code_module.project_file_path}".green if code_module.project_file_path
49
+ puts "Project group path: #{code_module.project_group_path}".green if code_module.project_group_path
55
50
  puts "Test file path: #{code_module.test_file_path}".green if code_module.test_file_path
56
51
  puts "Test group path: #{code_module.test_group_path}".green if code_module.test_group_path
57
52
  end
58
53
 
59
- def process_files_if_needed(files, name, code_module, template, project, targets, group_path, dir_path)
54
+ def process_files_if_needed(files, code_module, template, project, targets, group_path, dir_path)
60
55
  # It's possible that current project doesn't test targets configured, so it doesn't need to generate tests.
61
56
  # The same is for files property - a template can have only test or project files
62
57
  if targets.count == 0 || files == nil || files.count == 0 || dir_path == nil || group_path == nil
@@ -76,12 +71,15 @@ module Generamba
76
71
  end
77
72
 
78
73
  file_group = File.dirname(file[TEMPLATE_NAME_KEY])
74
+ file_group = nil if file_group == '.'
79
75
 
80
76
  module_info = ModuleInfoGenerator.new(code_module)
81
77
 
82
78
  # Generating the content of the code file and it's name
83
79
  file_name, file_content = ContentGenerator.create_file(file, module_info.scope, template)
84
- file_path = dir_path.join(file_group).join(file_name)
80
+ file_path = dir_path
81
+ file_path = file_path.join(file_group) if file_group
82
+ file_path = file_path.join(file_name) if file_name
85
83
 
86
84
  # Creating the file in the filesystem
87
85
  FileUtils.mkdir_p File.dirname(file_path)
@@ -1,5 +1,5 @@
1
1
  module Generamba
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  RELEASE_DATE = '05.09.2016'
4
4
  RELEASE_LINK = "https://github.com/rambler-ios/Generamba/releases/tag/#{VERSION}"
5
5
  end
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.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egor Tolstoy