Class: Fhcap::Tasks::Clean
- Defined in:
- lib/fhcap/tasks/clean.rb
Instance Attribute Summary
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
-
#initialize(options) ⇒ Clean
constructor
A new instance of Clean.
- #run ⇒ Object
Methods inherited from TaskBase
#ask_config, #color_pad, #exit_with_error, #set_color, #suppress_stdout, #table_header, #table_row, #with_progress
Methods included from KnifeHelper
#chef_server_config_for, #chef_server_config_hash_for, #chef_server_names, #knife_config, #knife_config_dir, #knife_config_file_for
Methods included from ProvidersHelper
#provider_availability_zones, #provider_config, #provider_credentials, #provider_for, #provider_names, #provider_names_for, #provider_regions, #provider_type, #providers_config
Methods included from ReposHelper
#find_cluster, #find_cluster_pwds, #find_cluster_pwds_with_repo, #find_cluster_with_repo, #find_data_bag, #find_data_bag_item, #find_environment, #find_repo_item, #find_role, #get_cookbook_deps, #get_cookbook_meta, #get_cookbook_versions, #get_cookbooks, #get_entry_dependencies, #get_modified_cookbooks, #is_dirty?, #modified?, #repo_cfg, #repo_clusters_dir, #repo_cookbook_paths, #repo_dir, #repo_names, #repo_paths, #repos_config, #repos_dir, #run_inside_repo_dir
Methods included from FhcapHelper
Constructor Details
#initialize(options) ⇒ Clean
Returns a new instance of Clean.
7 8 9 |
# File 'lib/fhcap/tasks/clean.rb', line 7 def initialize() super end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fhcap/tasks/clean.rb', line 11 def run if config.exists? repos = config[:repos] delete_files = repos.collect do |name, cfg| repo_dir(name) end.compact delete_files << config.config_file delete_files.each do |file| thor.say_status 'removing', file, :yellow end if thor.yes? "Continue (y/n)" delete_files.each do |file| thor.remove_file file end end else thor.say_status 'error', "No config file found #{config.config_file}", :red end end |