Skip to content

Commit

Permalink
Merge pull request #146 from rambler-ios/feature/task-126
Browse files Browse the repository at this point in the history
[RESOLVED] Added question in setup command #126
  • Loading branch information
etolstoy authored Sep 3, 2016
2 parents 2779bc1 + 7158c58 commit c11636a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 39 deletions.
74 changes: 42 additions & 32 deletions lib/generamba/cli/setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,58 @@ def setup
project_target = ask_index("Select the appropriate target for adding your MODULES (type the index):\n" + targets_prompt,project.targets)
include_tests = yes?('Are you using unit-tests in this project? (yes/no)')

test_target = nil

if include_tests
test_target = ask_index("Select the appropriate target for adding your TESTS (type the index):\n" + targets_prompt,project.targets)
end

should_use_same_paths = yes?('Do you want to use the same paths for your files both in Xcode and the filesystem? (yes/no)')
if should_use_same_paths
project_group_path = ask('The default path for creating new modules:')
project_file_path = project_group_path
should_add_all_modules_by_one_path = yes?('Do you want to add all your modules by one path? (yes/no)')

project_file_path = nil
project_group_path = nil

test_file_path = nil
test_group_path = nil

if include_tests
test_group_path = ask('The default path for creating tests:')
test_file_path = test_group_path
if should_add_all_modules_by_one_path || include_tests
should_use_same_paths = false

if should_add_all_modules_by_one_path
should_use_same_paths = yes?('Do you want to use the same paths for your files both in Xcode and the filesystem? (yes/no)')
end
else
project_group_path = ask('The default path for creating new modules (in Xcode groups):')
project_file_path = ask('The default path for creating new modules (in the filesystem):')

if include_tests
test_group_path = ask('The default path for creating tests (in Xcode groups):')
test_file_path = ask('The default path for creating tests (in the filesystem):')
if should_use_same_paths
if should_add_all_modules_by_one_path
project_group_path = ask('The default path for creating new modules:')
project_file_path = project_group_path
end

if include_tests
test_group_path = ask('The default path for creating tests:')
test_file_path = test_group_path
end
else
if should_add_all_modules_by_one_path
project_group_path = ask('The default path for creating new modules (in Xcode groups):')
project_file_path = ask('The default path for creating new modules (in the filesystem):')
end

if include_tests
test_group_path = ask('The default path for creating tests (in Xcode groups):')
test_file_path = ask('The default path for creating tests (in the filesystem):')
end
end
end

using_pods = yes?('Are you using Cocoapods? (yes/no)')
if using_pods
properties[PODFILE_PATH_KEY] = ask_file_with_path('Podfile',
'Podfile')
properties[PODFILE_PATH_KEY] = ask_file_with_path('Podfile', 'Podfile')
end

using_carthage = yes?('Are you using Carthage? (yes/no)')
if using_carthage
properties[CARTFILE_PATH_KEY] = ask_file_with_path('Cartfile',
'Cartfile')
properties[CARTFILE_PATH_KEY] = ask_file_with_path('Cartfile', 'Cartfile')
end

should_add_templates = yes?('Do you want to add some well known templates to the Rambafile? (yes/no)')
Expand All @@ -79,21 +98,12 @@ def setup
]
end

properties[PROJECT_TARGET_KEY] = project_target.name
properties[PROJECT_FILE_PATH_KEY] = project_file_path
properties[PROJECT_GROUP_PATH_KEY] = project_group_path

if test_target
properties[TEST_TARGET_KEY] = test_target.name
end

if test_file_path
properties[TEST_FILE_PATH_KEY] = test_file_path
end

if test_group_path
properties[TEST_GROUP_PATH_KEY] = test_group_path
end
properties[PROJECT_TARGET_KEY] = project_target.name if project_target
properties[PROJECT_FILE_PATH_KEY] = project_file_path if project_file_path
properties[PROJECT_GROUP_PATH_KEY] = project_group_path if project_group_path
properties[TEST_TARGET_KEY] = test_target.name if test_target
properties[TEST_FILE_PATH_KEY] = test_file_path if test_file_path
properties[TEST_GROUP_PATH_KEY] = test_group_path if test_group_path

PrintTable.print_values(
values: properties,
Expand Down
15 changes: 8 additions & 7 deletions lib/generamba/code_generation/Rambafile.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ project_name: {{ project_name }}
xcodeproj_path: {{ xcodeproj_path }}
{% if prefix != "" %}prefix: {{ prefix }}{% endif %}

### Code generation settings section
# The main project target name
project_target: {{ project_target }}
{% 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
{% if project_target != nil and project_target != "" %}# The main project target name
project_target: {{ project_target }}{% endif %}

# The file path for new modules
project_file_path: {{ project_file_path }}
{% if project_file_path != nil and project_file_path != "" %}# The file path for new modules
project_file_path: {{ project_file_path }}{% endif %}

# The Xcode group path to new modules
project_group_path: {{ project_group_path }}
{% if project_group_path != nil and project_group_path != "" %}# The Xcode group path to new modules
project_group_path: {{ project_group_path }}{% endif %}
{% endif %}

{% 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
{% if test_target != nil and test_target != "" %}# The tests target name
Expand Down

0 comments on commit c11636a

Please sign in to comment.