class Compass::Commands::ProjectBase

Attributes

options[RW]
project_directory[RW]
project_name[RW]

Public Class Methods

new(working_path, options = {}) click to toggle source
Calls superclass method Compass::Commands::Base.new
# File lib/compass/commands/project_base.rb, line 11
def initialize(working_path, options = {})
  super(working_path, options)
  self.project_name = determine_project_name(working_path, options)
  Compass.add_configuration({:project_path => determine_project_directory(working_path, options)}, "implied")
  configure!
end

Public Instance Methods

execute() click to toggle source
Calls superclass method Compass::Commands::Base#execute
# File lib/compass/commands/project_base.rb, line 18
def execute
  super
end

Protected Instance Methods

add_project_configuration() click to toggle source
# File lib/compass/commands/project_base.rb, line 30
def add_project_configuration
  defaults = Compass.configuration_for(options, "cli_defaults")
  if options[:project_type]
    project_type_config = Compass.configuration_for(options[:project_type])
    project_type_config.inherit_from!(Compass.default_configuration)
    defaults.inherit_from!(project_type_config)
  end
  Compass.add_project_configuration(options[:configuration_file], :defaults => defaults) do
    options[:project_type]
  end
end
assert_project_directory_exists!() click to toggle source
# File lib/compass/commands/project_base.rb, line 62
def assert_project_directory_exists!
  if File.exists?(project_directory) && !File.directory?(project_directory)
    raise Compass::FilesystemConflict.new("#{project_directory} is not a directory.")
  elsif !File.directory?(project_directory)
    raise Compass::Error.new("#{project_directory} does not exist.")
  end
end
configure!() click to toggle source
# File lib/compass/commands/project_base.rb, line 24
def configure!
  add_project_configuration
  Compass.add_configuration(options, "command_line")
  Compass.discover_extensions! unless skip_extension_discovery?
end
project_css_subdirectory() click to toggle source
# File lib/compass/commands/project_base.rb, line 50
def project_css_subdirectory
  Compass.configuration.css_dir
end
project_images_subdirectory() click to toggle source
# File lib/compass/commands/project_base.rb, line 58
def project_images_subdirectory
  Compass.configuration.images_dir
end
project_src_subdirectory() click to toggle source
# File lib/compass/commands/project_base.rb, line 54
def project_src_subdirectory
  Compass.configuration.sass_dir
end
projectize(path) click to toggle source
# File lib/compass/commands/project_base.rb, line 42
def projectize(path)
  Compass.projectize(path)
end

Private Instance Methods

absolute_path?(path) click to toggle source
# File lib/compass/commands/project_base.rb, line 92
def absolute_path?(path)
  # Pretty basic implementation
  path.index(File::SEPARATOR) == 0 || path.index(':') == 1
end
determine_project_directory(working_path, options) click to toggle source
# File lib/compass/commands/project_base.rb, line 80
def determine_project_directory(working_path, options)
  if options[:project_name]
    if absolute_path?(options[:project_name])
      options[:project_name]
    else
      File.join(working_path, options[:project_name])
    end
  else
    working_path
  end
end
determine_project_name(working_path, options) click to toggle source
# File lib/compass/commands/project_base.rb, line 72
def determine_project_name(working_path, options)
  if options[:project_name]
    File.basename(strip_trailing_separator(options[:project_name]))
  else
    File.basename(working_path)
  end
end
skip_extension_discovery?() click to toggle source
# File lib/compass/commands/project_base.rb, line 97
def skip_extension_discovery?
  false
end