Class: Compass::Commands::CleanProject

Inherits:
UpdateProject show all
Defined in:
lib/compass/commands/clean_project.rb

Instance Attribute Summary

Attributes inherited from ProjectBase

#options, #project_name

Attributes inherited from Base

#options, #working_path

Attributes included from Actions

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UpdateProject

absolutize, #check_for_sass_files!, #compiler_options, #new_compiler_instance, #new_config?, #prepare_project!, #transfer_options

Methods inherited from ProjectBase

#execute

Methods inherited from Base

#execute, #failed!, register, #successful?

Methods included from Actions

#basename, #copy, #directory, #log_action, #process_erb, #relativize, #remove, #separate, #strip_trailing_separator, #write_file

Constructor Details

#initialize(working_path, options) ⇒ CleanProject

Returns a new instance of CleanProject.



25
26
27
28
# File 'lib/compass/commands/clean_project.rb', line 25

def initialize(working_path, options)
  super
  assert_project_directory_exists!
end

Class Method Details

.description(command) ⇒ Object



56
57
58
# File 'lib/compass/commands/clean_project.rb', line 56

def description(command)
  "Remove generated files and the sass cache"
end

.option_parser(arguments) ⇒ Object



43
44
45
46
47
48
# File 'lib/compass/commands/clean_project.rb', line 43

def option_parser(arguments)
  parser = Compass::Exec::CommandOptionParser.new(arguments)
  parser.extend(Compass::Exec::GlobalOptionsParser)
  parser.extend(Compass::Exec::ProjectOptionsParser)
  parser.extend(CleanProjectOptionsParser)
end

.parse!(arguments) ⇒ Object



60
61
62
63
64
65
# File 'lib/compass/commands/clean_project.rb', line 60

def parse!(arguments)
  parser = option_parser(arguments)
  parser.parse!
  parse_arguments!(parser, arguments)
  parser.options
end

.parse_arguments!(parser, arguments) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/compass/commands/clean_project.rb', line 67

def parse_arguments!(parser, arguments)
  if arguments.size > 0
    parser.options[:project_name] = arguments.shift if File.directory?(arguments.first)
    unless arguments.empty?
      parser.options[:sass_files] = arguments.dup
      parser.options[:force] = true
    end
  end
end

.primaryObject



54
# File 'lib/compass/commands/clean_project.rb', line 54

def primary; true; end

.usageObject



50
51
52
# File 'lib/compass/commands/clean_project.rb', line 50

def usage
  option_parser([]).to_s
end

Instance Method Details

#determine_cache_locationObject



38
39
40
# File 'lib/compass/commands/clean_project.rb', line 38

def determine_cache_location
  Compass.configuration.cache_path || Sass::Plugin.options[:cache_location] || File.join(working_path, ".sass-cache")
end

#performObject



30
31
32
33
34
35
36
# File 'lib/compass/commands/clean_project.rb', line 30

def perform
  compiler = new_compiler_instance
  compiler.clean!
  Compass::SpriteImporter.find_all_sprite_map_files(Compass.configuration.generated_images_path).each do |sprite|
    remove sprite
  end
end