Class: Generamba::CatalogTerminator

Inherits:
Object
  • Object
show all
Defined in:
lib/generamba/template/helpers/catalog_terminator.rb

Overview

Provides a functionality to terminate all previously installed catalogs

Returns:

  • (Void)

Instance Method Summary collapse

Instance Method Details

#remove_all_catalogsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generamba/template/helpers/catalog_terminator.rb', line 7

def remove_all_catalogs
  catalogs_path = Pathname.new(ENV['HOME'])
                      .join(GENERAMBA_HOME_DIR)
                      .join(CATALOGS_DIR)
  if Dir.exist?(catalogs_path) == false
    FileUtils.mkdir_p catalogs_path
  end
  catalogs_path.children.select { |child|
    child.directory? && child.split.last.to_s[0] != '.'
  }.each { |catalog_path|
    FileUtils.rm_rf(catalog_path)
  }
end