Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented new question, about need tests in generamba setup #87

Merged
merged 2 commits into from
Jan 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions lib/generamba/cli/setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,29 @@ def setup
targets_prompt = ''
project.targets.each_with_index { |element, i| targets_prompt += ("#{i}. #{element.name}" + "\n") }
project_target = ask_index("Select the appropriate target for adding your MODULES (type the index):\n" + targets_prompt,project.targets)
test_target = ask_index("Select the appropriate target for adding your TESTS (type the index):\n" + targets_prompt,project.targets)
include_tests = yes?('Are you using unit-tests in this project? (yes/no)')

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

test_group_path = ask('The default path for creating tests:')
test_file_path = test_group_path
if include_tests
test_group_path = ask('The default path for creating tests:')
test_file_path = test_group_path
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):')

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 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

using_pods = yes?('Are you using Cocoapods? (yes/no)')
Expand All @@ -65,9 +73,18 @@ def setup
properties[PROJECT_TARGET_KEY] = project_target.name
properties[PROJECT_FILE_PATH_KEY] = project_file_path
properties[PROJECT_GROUP_PATH_KEY] = project_group_path
properties[TEST_TARGET_KEY] = test_target.name
properties[TEST_FILE_PATH_KEY] = test_file_path
properties[TEST_GROUP_PATH_KEY] = test_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

Generamba::RambafileGenerator.create_rambafile(properties)
puts('Rambafile successfully created! Now add some templates to the Rambafile and run `generamba template install`.'.green)
Expand Down
9 changes: 5 additions & 4 deletions lib/generamba/code_generation/Rambafile.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ project_file_path: {{ project_file_path }}
# The Xcode group path to new modules
project_group_path: {{ project_group_path }}

{% if test_target != "" or test_file_path != "" or test_group_path != "" %}### Tests generation settings section{% endif %}
{% if test_target != "" %}# The tests target name
{% 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
test_target: {{ test_target }}{% endif %}

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

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

{% if podfile_path != nil or cartfile_path != nil %}### Dependencies settings section{% endif %}
{% if podfile_path != nil %}podfile_path: {{ podfile_path }}{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion lib/generamba/code_generation/rambafile_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RambafileGenerator
# @return void
def self.create_rambafile(properties)
template = Tilt.new(File.dirname(__FILE__) + '/Rambafile.liquid')
output = template.render(properties)
output = template.render(properties).gsub!(/[\n]{3,}/, "\n\n");

File.open(RAMBAFILE_NAME, 'w+') {|f|
f.write(output)
Expand Down