Class: Bunto::Commands::Clean

Inherits:
Bunto::Command show all
Defined in:
lib/bunto/commands/clean.rb

Class Method Summary collapse

Methods inherited from Bunto::Command

add_build_options, configuration_from_options, inherited, process_site, subclasses

Class Method Details

.init_with_program(prog) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bunto/commands/clean.rb', line 5

def init_with_program(prog)
  prog.command(:clean) do |c|
    c.syntax "clean [subcommand]"
    c.description "Clean the site " \
          "(removes site output and metadata file) without building."

    add_build_options(c)

    c.action do |_, options|
      Bunto::Commands::Clean.process(options)
    end
  end
end

.process(options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/bunto/commands/clean.rb', line 19

def process(options)
  options = configuration_from_options(options)
  destination = options["destination"]
   = File.join(options["source"], ".bunto-metadata")
  sass_cache = File.join(options["source"], ".sass-cache")

  remove(destination, :checker_func => :directory?)
  remove(, :checker_func => :file?)
  remove(sass_cache, :checker_func => :directory?)
end

.remove(filename, checker_func: :file?) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/bunto/commands/clean.rb', line 30

def remove(filename, checker_func: :file?)
  if File.public_send(checker_func, filename)
    Bunto.logger.info "Cleaner:", "Removing #{filename}..."
    FileUtils.rm_rf(filename)
  else
    Bunto.logger.info "Cleaner:", "Nothing to do for #{filename}."
  end
end