Class: Textigniter::Scrub

Inherits:
Object
  • Object
show all
Defined in:
lib/textigniter/scrub.rb

Overview

The Scrub Class deletes the textigniter environment leaving intact any files and folders that you have added at the base level. It will remove any files that you have added to the public_html folder so be sure to back those up.

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Scrub

Returns a new instance of Scrub.



6
7
8
9
# File 'lib/textigniter/scrub.rb', line 6

def initialize(args)
  # Output start message
  STDOUT.puts "Scrubbing textigniter environment".yellow_on_black
end

Instance Method Details

#scrubObject

Scrub the directory



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/textigniter/scrub.rb', line 12

def scrub
  # Scrub the directory, no turning back
  scrub_directory("#{$twd}")
  scrub_directory("#{$base_path}/plugins")
  scrub_directory("#{$owd}")
  # Files to delete as well
  files = [ "#{$base_path}/README.textile", "#{$base_path}/config.yml" ]
  # Remove files specified
  FileUtils.rm files, :force => true
  # Output success message
  puts "Textigniter enivorment has been scrubbed ".yellow_on_black + "[OK]".green_on_black
end

#scrub_directory(directory = nil) ⇒ Object

Recursively remove directory and contents



26
27
28
29
30
31
32
33
34
35
# File 'lib/textigniter/scrub.rb', line 26

def scrub_directory(directory=nil)
  begin
    # remove the files and directories
    Find.find(directory) do |path|
      FileUtils.remove_dir(path, true)
      Find.prune
    end
  rescue
  end
end