Class: Viperaptor::CLI::Template
- Inherits:
-
Thor
- Object
- Thor
- Viperaptor::CLI::Template
show all
- Includes:
- Viperaptor
- Defined in:
- lib/viperaptor/cli/template/template_group.rb,
lib/viperaptor/cli/template/template_list_command.rb,
lib/viperaptor/cli/template/template_create_command.rb,
lib/viperaptor/cli/template/template_search_command.rb,
lib/viperaptor/cli/template/template_install_command.rb
Constant Summary
Constants included
from Viperaptor
APP_HOME_DIR, AUTHOR_NAME_KEY, Viperaptor::C99IDENTIFIER, Viperaptor::CARTFILE_PATH_KEY, Viperaptor::CATALOGS_DIR, Viperaptor::CATALOGS_KEY, Viperaptor::COMPANY_KEY, Viperaptor::CUSTOM_PARAMETERS_KEY, PATH_TYPE_PROJECT, PATH_TYPE_TEST, PODFILE_PATH_KEY, PREDEFINED_CATALOG_REPOS, PRODUCT_MODULE_NAME_KEY, PROJECT_FILE_PATH_KEY, PROJECT_GROUP_PATH_KEY, PROJECT_NAME_KEY, PROJECT_PREFIX_KEY, PROJECT_TARGETS_KEY, PROJECT_TARGET_KEY, RAMBAFILE_NAME, RAMBASPEC_EXTENSION, RELEASE_DATE, RELEASE_LINK, SLASH_REGEX, TEMPLATES_FILTER_KEY, TEMPLATES_FOLDER, TEMPLATES_KEY, TEMPLATE_AUTHOR_KEY, TEMPLATE_CODE_FILES_KEY, TEMPLATE_CUSTOM_PARAMETERS_KEY, TEMPLATE_DECLARATION_BRANCH_KEY, TEMPLATE_DECLARATION_GIT_KEY, TEMPLATE_DECLARATION_LOCAL_KEY, TEMPLATE_DECLARATION_NAME_KEY, TEMPLATE_DEPENDENCIES_KEY, TEMPLATE_FILE_CUSTOM_NAME_KEY, TEMPLATE_FILE_IS_RESOURCE_KEY, TEMPLATE_FILE_NAME_KEY, TEMPLATE_FILE_PATH_KEY, TEMPLATE_LICENSE_KEY, TEMPLATE_NAME_KEY, TEMPLATE_SUMMARY_KEY, TEMPLATE_TEST_FILES_KEY, TEMPLATE_VERSION_KEY, TEMPLATE_VIPERAPTOR_KEY, TEST_FILE_PATH_KEY, TEST_GROUP_PATH_KEY, TEST_TARGETS_KEY, TEST_TARGET_KEY, USER_PREFERENCES_CATALOGS_KEY, USER_PREFERENCES_FILE, USER_PREFERENCES_TEMPLATES_HISTORY_KEY, USER_PREFERENCES_USERNAME_KEY, VERSION, XCODEPROJ_PATH_KEY
Instance Method Summary
collapse
Instance Method Details
#create(template_name) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/viperaptor/cli/template/template_create_command.rb', line 8
def create(template_name)
summary = ask('The brief description of your new template:')
author = ask('Who is the author of this template:')
license = ask('What license will be used (e.g. MIT):')
has_dependencies = yes?('Will your template contain any third-party dependencies (available via Cocoapods or Carthage)? (yes/no)')
if has_dependencies
dependencies = ask_loop('Enter the name of your dependency (empty string to stop):')
end
properties = {
TEMPLATE_NAME_KEY => template_name,
TEMPLATE_SUMMARY_KEY => summary,
TEMPLATE_AUTHOR_KEY => author,
TEMPLATE_LICENSE_KEY => license
}
if dependencies and !dependencies.empty?
properties[TEMPLATE_DEPENDENCIES_KEY] = dependencies
end
PrintTable.print_values(
values: properties,
title: "Summary for template create"
)
template_creator = Viperaptor::TemplateCreator.new
template_creator.create_template(properties)
puts("The template #{template_name} is successfully generated! Now add some file templates into it.".green)
end
|
#list ⇒ Object
9
10
11
12
13
14
|
# File 'lib/viperaptor/cli/template/template_list_command.rb', line 9
def list
templates = TemplateHelper.global_templates
templates.each do |template_name|
puts(template_name)
end
end
|
#search(term) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/viperaptor/cli/template/template_search_command.rb', line 9
def search(term)
downloader = CatalogDownloader.new
catalog_template_search_helper = CatalogTemplateSearchHelper.new
catalog_paths = downloader.update_all_catalogs_and_return_filepaths
templates = []
catalog_paths.each do |path|
templates += catalog_template_search_helper.search_templates_in_a_catalog(path, term)
templates = templates.uniq
end
templates.map { |template_name|
keywords = term.squeeze.strip.split(' ').compact.uniq
matcher = Regexp.new('(' + keywords.join('|') + ')')
template_name.gsub(matcher) { |match| "#{match}".yellow }
}.each { |template_name|
puts(template_name)
}
end
|