Skip to content

Commit

Permalink
[RESOLVED] Updated gen command parameters table #142
Browse files Browse the repository at this point in the history
  • Loading branch information
Beniamin Sarkisyan committed Sep 3, 2016
1 parent c75786b commit d73cb41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/generamba/cli/gen_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def gen(module_name, template_name)

rambafile = YAML.load_file(RAMBAFILE_NAME)

parameters = GenCommandTableParametersFormatter.prepare_parameters_for_displaying(rambafile)
template = ModuleTemplate.new(template_name)
code_module = CodeModule.new(module_name, module_description, rambafile, options)

parameters = GenCommandTableParametersFormatter.prepare_parameters_for_displaying(code_module, template_name)
PrintTable.print_values(
values: parameters,
title: "Summary for gen #{module_name}"
)

template = ModuleTemplate.new(template_name)
code_module = CodeModule.new(module_name, module_description, rambafile, options)

DependencyChecker.check_all_required_dependencies_has_in_podfile(template.dependencies, code_module.podfile_path)
DependencyChecker.check_all_required_dependencies_has_in_cartfile(template.dependencies, code_module.cartfile_path)

Expand Down
26 changes: 20 additions & 6 deletions lib/generamba/helpers/gen_command_table_parameters_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
module Generamba
# Provides methods for prepare parameters for displaying in table.
class GenCommandTableParametersFormatter
require 'json'

# This method prepared parameter for displaying
def self.prepare_parameters_for_displaying(parameters)
params = parameters.clone
def self.prepare_parameters_for_displaying(code_module, template_name)
params = {}

params['Targets'] = code_module.project_targets.join(',')
params['Module path'] = code_module.module_file_path

if code_module.module_file_path != code_module.module_group_path
params['Module group path'] = code_module.module_group_path
end

templates = []
params['Test targets'] = code_module.test_targets.join(',') if code_module.test_targets
params['Test file path'] = code_module.test_file_path if code_module.test_file_path

params['templates'].each do |param|
templates.push(param['name'])
if code_module.test_file_path != code_module.test_group_path
params['Test group path'] = code_module.test_group_path
end

params['templates'] = templates.join("\n")
params['Template'] = template_name

if code_module.custom_parameters
params['Custom parameters'] = code_module.custom_parameters.to_json
end

params
end
Expand Down

0 comments on commit d73cb41

Please sign in to comment.