Class: Compass::Exec::SwitchUI

### Home Classes Methods

### In Files

- lib/compass/exec/switch_ui.rb

### Parent

Object

### Methods

- ::new
- #do_command
- #parse!
- #perform!
- #run!
- #set_opts
- #trim_trailing_separator

### Included Modules

- Compass::Exec::GlobalOptionsParser
- Compass::Exec::ProjectOptionsParser

### Class/Module Index

Quicksearch

- Compass
- Compass::Actions
- Compass::AppIntegration
- Compass::AppIntegration::Helpers
- Compass::AppIntegration::Rails
- Compass::AppIntegration::StandAlone
- Compass::AppIntegration::StandAlone::ConfigurationDefaults
- Compass::AppIntegration::StandAlone::Installer
- Compass::BrowserSupport
- Compass::Commands
- Compass::Commands::Base
- Compass::Commands::CleanProject
- Compass::Commands::CleanProjectOptionsParser
- Compass::Commands::CompileProjectOptionsParser
- Compass::Commands::ConfigurationOptionsParser
- Compass::Commands::CreateProject
- Compass::Commands::CreateProjectOptionsParser
- Compass::Commands::Default
- Compass::Commands::DefaultOptionsParser
- Compass::Commands::ExtensionCommand
- Compass::Commands::ExtensionOptionsParser
- Compass::Commands::ExtensionsOptionParser
- Compass::Commands::GenerateGridBackground
- Compass::Commands::GridBackgroundOptionsParser
- Compass::Commands::Help
- Compass::Commands::HelpOptionsParser
- Compass::Commands::Imports
- Compass::Commands::InstallerCommand
- Compass::Commands::Interactive
- Compass::Commands::InteractiveOptionsParser
- Compass::Commands::ListFrameworks
- Compass::Commands::MemoryDebugger
- Compass::Commands::PrintVersion
- Compass::Commands::ProjectBase
- Compass::Commands::ProjectStats
- Compass::Commands::Registry
- Compass::Commands::Sprite
- Compass::Commands::SpriteOptionsParser
- Compass::Commands::StampPattern
- Compass::Commands::StampPatternOptionsParser
- Compass::Commands::StatsOptionsParser
- Compass::Commands::StructureOptionsParser
- Compass::Commands::UnpackExtension
- Compass::Commands::UpdateProject
- Compass::Commands::ValidateProject
- Compass::Commands::ValidationOptionsParser
- Compass::Commands::VersionOptionsParser
- Compass::Commands::WatchProject
- Compass::Commands::WatchProjectOptionsParser
- Compass::Commands::WriteConfiguration
- Compass::Compiler
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Comments
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::FileData
- Compass::Configuration::Helpers
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Serialization
- Compass::Error
- Compass::Exec
- Compass::Exec::CommandOptionParser
- Compass::Exec::GlobalOptionsParser
- Compass::Exec::Helpers
- Compass::Exec::ProjectOptionsParser
- Compass::Exec::SubCommandUI
- Compass::Exec::SwitchUI
- Compass::FilesystemConflict
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::GridBuilder
- Compass::Installers
- Compass::Installers::BareInstaller
- Compass::Installers::Base
- Compass::Installers::Manifest
- Compass::Installers::Manifest::Entry
- Compass::Installers::ManifestInstaller
- Compass::Installers::TemplateContext
- Compass::Logger
- Compass::MissingDependency
- Compass::NullLogger
- Compass::PNG
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::SassExtensions::Functions::Colors
- Compass::SassExtensions::Functions::Constants
- Compass::SassExtensions::Functions::CrossBrowserSupport
- Compass::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::SassExtensions::Functions::Display
- Compass::SassExtensions::Functions::Enumerate
- Compass::SassExtensions::Functions::Env
- Compass::SassExtensions::Functions::FontFiles
- Compass::SassExtensions::Functions::GradientSupport
- Compass::SassExtensions::Functions::GradientSupport::Assertions
- Compass::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::SassExtensions::Functions::GradientSupport::Functions
- Compass::SassExtensions::Functions::GradientSupport::Gradient
- Compass::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::SassExtensions::Functions::ImageSize
- Compass::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::SassExtensions::Functions::ImageSize::JPEG
- Compass::SassExtensions::Functions::InlineImage
- Compass::SassExtensions::Functions::Lists
- Compass::SassExtensions::Functions::Math
- Compass::SassExtensions::Functions::Selectors
- Compass::SassExtensions::Functions::Sprites
- Compass::SassExtensions::Functions::Sprites::VariableReader
- Compass::SassExtensions::Functions::Urls
- Compass::SassExtensions::Functions::Urls::FontUrl
- Compass::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::SassExtensions::Functions::Urls::ImageUrl
- Compass::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::SassExtensions::Sprites
- Compass::SassExtensions::Sprites::ChunkyPngEngine
- Compass::SassExtensions::Sprites::Engine
- Compass::SassExtensions::Sprites::Image
- Compass::SassExtensions::Sprites::ImageMethods
- Compass::SassExtensions::Sprites::ImageRow
- Compass::SassExtensions::Sprites::LayoutMethods
- Compass::SassExtensions::Sprites::RowFitter
- Compass::SassExtensions::Sprites::SpriteMap
- Compass::SassExtensions::Sprites::SpriteMethods
- Compass::SpriteException
- Compass::SpriteImporter
- Compass::Sprites
- Compass::Sprites::Binding
- Compass::Stats
- Compass::Stats::CssFile
- Compass::Stats::SassFile
- Compass::Stats::StatsVisitor
- Compass::TestCase
- Compass::Util
- Compass::Version
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Tree
- Sass::Tree::Node
- QuickCache

No matching classes.

# Compass::Exec::SwitchUI

### Attributes

args[RW]
options[RW]
opts[RW]

### Public Class Methods

new(args) click to toggle source

    # File lib/compass/exec/switch_ui.rb, line 10
    def initialize(args)
      self.args = args
      self.options = {}
      parse!
    end

### Public Instance Methods

run!() click to toggle source

    # File lib/compass/exec/switch_ui.rb, line 16
    def run!
      begin
        perform!
      rescue Exception => e
        raise e if e.is_a? SystemExit
        if e.is_a?(::Compass::Error) || e.is_a?(OptionParser::ParseError)
          $stderr.puts e.message
        else
          ::Compass::Exec::Helpers.report_error(e, @options)
        end
        return 1
      end
      return 0
    end

### Protected Instance Methods

do_command(command) click to toggle source

    # File lib/compass/exec/switch_ui.rb, line 172
    def do_command(command)
      command_class_name = command.to_s.split(/_/).map{|p| p.capitalize}.join('')
      command_class = eval("::Compass::Commands::#{command_class_name}")
      command_class.new(Dir.getwd, options).execute
    end

parse!() click to toggle source

    # File lib/compass/exec/switch_ui.rb, line 41
    def parse!
      self.opts = OptionParser.new(&method(:set_opts))
      self.opts.parse!(self.args)
      if self.args.size > 0
        self.options[:project_name] = trim_trailing_separator(self.args.shift)
      end
      self.options[:command] ||= self.options[:project_name] ? :create_project : :update_project
      self.options[:framework] ||= :compass
    end

perform!() click to toggle source

    # File lib/compass/exec/switch_ui.rb, line 33
    def perform!
      if options[:command]
        do_command(options[:command])
      else
        puts self.opts
      end
    end

set_opts(opts) click to toggle source

    # File lib/compass/exec/switch_ui.rb, line 55
    def set_opts(opts)
      opts.banner = Usage: compass [options] [project]Description:The compass command line tool will help you create and manage the stylesheets for your project.To get started on a stand-alone project based on blueprint:  compass -f blueprint my_compass_projectWhen you change any sass files, you must recompile your project using --update or --watch.
      opts.separator ''
      opts.separator 'Mode Options(only specify one):'

      opts.on('-i', '--install', :NONE, "Create a new compass project.",
                                        "  The default mode when a project is provided.") do
        self.options[:command] = :create_project
      end

      opts.on('-u', '--update', :NONE, 'Update the current project.',
                                       '  This is the default when no project is provided.') do
        self.options[:command] = :update_project
      end

      opts.on('-w', '--watch', :NONE, 'Monitor the current project for changes and update') do
        self.options[:command] = :watch_project
        self.options[:quiet] = true
      end

      opts.on('-p', '--pattern PATTERN', 'Stamp out a pattern into the current project.',
                                         '  Must be used with -f.') do |pattern|
        self.options[:command] = :stamp_pattern
        self.options[:pattern] = pattern
      end

      opts.on('-h', '--help') do
        self.options[:command] = :help
        self.options[:help_command] = :help
      end

      opts.on('--write-configuration', "Write the current configuration to the configuration file.") do
        self.options[:command] = :write_configuration
      end

      opts.on('--list-frameworks', "List compass frameworks available to use.") do
        self.options[:command] = :list_frameworks
      end

      opts.on('--validate', :NONE, 'Validate your project\s compiled css. Requires Java.') do
        self.options[:command] = :validate_project
      end

      opts.on('--grid-img [DIMENSIONS]', 'Generate a background image to test grid alignment.',
                                         '  Dimension is given as <column_width>+<gutter_width>x<height>.',
                                         '  Defaults to 30+10x20. Height is optional.') do |dimensions|
        self.options[:grid_dimensions] = dimensions || "30+10"
        self.options[:command] = :generate_grid_background
      end

      opts.separator ''
      opts.separator 'Install/Pattern Options:'

      opts.on('-f FRAMEWORK', '--framework FRAMEWORK', 'Use the specified framework. Only one may be specified.') do |framework|
        self.options[:framework] = framework
      end

      opts.on('-n', '--pattern-name NAME', 'The name to use when stamping a pattern.',
                                           '  Must be used in combination with -p.') do |name|
        self.options[:pattern_name] = name
      end

      opts.on("-x", "--syntax SYNTAX", [:sass, :scss], "Specify the syntax to use when generating stylesheets.", "One of sass or scss. Defaults to scss.") do |syntax|
        self.options[:preferred_syntax] = syntax
      end

      opts.on('--rails', "Sets the app type to a rails project (same as --app rails).") do
        self.options[:project_type] = :rails
      end

      opts.on('--app APP_TYPE', 'Specify the kind of application to integrate with.') do |project_type|
        self.options[:project_type] = project_type.to_sym
      end

      opts.separator ''
      opts.separator 'Configuration Options:'

      set_project_options(opts)

      opts.separator ''
      opts.separator 'General Options:'

      set_global_options(opts)

      opts.on('--imports', :NONE, 'Emit an imports suitable for passing to the sass command-line.',
                                  '  Example: sass `compass --imports`',
                                  '  Note: Compass\s Sass extensions will not be available.') do
        print ::Compass::Frameworks::ALL.map{|f| "-I #{f.stylesheets_directory}"}.join(' ')
        exit
      end

      opts.on('--install-dir', :NONE, 'Emit the location where compass is installed.') do
        puts ::Compass.base_directory
        exit
      end

      opts.on_tail("-v", "--version", "Print version") do
        self.options[:command] = :print_version
      end

      opts.on('--boring', :NONE, 'Turn off colorized output.') do
        self.options[:color_output] = false
      end

    end

trim_trailing_separator(path) click to toggle source

    # File lib/compass/exec/switch_ui.rb, line 51
    def trim_trailing_separator(path)
      path[-1..-1] == File::SEPARATOR ? path[0..-2] : path
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.