Class: Compass::Commands::UnpackExtension

### Home Classes Methods

### In Files

- lib/compass/commands/unpack_extension.rb

### Parent

Compass::Commands::ProjectBase

### Methods

- ::description
- ::new
- ::option_parser
- ::parse!
- ::parse_arguments!
- ::usage
- #perform
- #readme
- #skip_extension_discovery?

### Class/Module Index

Quicksearch

- Compass
- Compass::Actions
- Compass::AppIntegration
- Compass::AppIntegration::Helpers
- Compass::AppIntegration::StandAlone
- Compass::AppIntegration::StandAlone::ConfigurationDefaults
- Compass::AppIntegration::StandAlone::Installer
- 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::Help
- Compass::Commands::HelpOptionsParser
- Compass::Commands::Imports
- Compass::Commands::InstallerCommand
- Compass::Commands::Interactive
- Compass::Commands::InteractiveOptionsParser
- Compass::Commands::ListFrameworks
- 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::WriteConfiguration
- Compass::Compiler
- Compass::Configuration
- Compass::Configuration::Comments
- Compass::Configuration::Data
- Compass::Configuration::FileData
- Compass::Configuration::Helpers
- Compass::Configuration::Serialization
- Compass::Deprecation
- Compass::Exec
- Compass::Exec::CommandOptionParser
- Compass::Exec::GlobalOptionsParser
- Compass::Exec::Helpers
- Compass::Exec::ProjectOptionsParser
- Compass::Exec::SubCommandUI
- Compass::FilesystemConflict
- 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::SassCompiler
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::SassExtensions::Functions::SassDeclarationHelper
- Compass::SassExtensions::Functions::Sprites
- Compass::SassExtensions::Functions::Sprites::VariableReader
- 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::Images
- Compass::SassExtensions::Sprites::Layout
- Compass::SassExtensions::Sprites::Layout::Diagonal
- Compass::SassExtensions::Sprites::Layout::Horizontal
- Compass::SassExtensions::Sprites::Layout::Smart
- Compass::SassExtensions::Sprites::Layout::SpriteLayout
- Compass::SassExtensions::Sprites::Layout::Vertical
- 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::Version
- Sass
- Sass::Script
- Sass::Script::Functions
- QuickCache

No matching classes.

# Compass::Commands::UnpackExtension

### Public Class Methods

description(command) click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 95
    def description(command)
      "Copy an extension into your extensions folder."
    end

new(working_path, options) click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 30
    def initialize(working_path, options)
      super
      assert_project_directory_exists!
    end

option_parser(arguments) click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 84
    def option_parser(arguments)
      parser = Compass::Exec::CommandOptionParser.new(arguments)
      parser.extend(Compass::Exec::GlobalOptionsParser)
      parser.extend(Compass::Exec::ProjectOptionsParser)
      parser.extend(ExtensionOptionsParser)
    end

parse!(arguments) click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 99
    def parse!(arguments)
      parser = option_parser(arguments)
      parser.parse!
      parse_arguments!(parser, arguments)
      parser.options
    end

parse_arguments!(parser, arguments) click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 106
    def parse_arguments!(parser, arguments)
      if arguments.size == 1
        parser.options[:framework] = arguments.shift
      elsif arguments.size == 0
        raise Compass::Error, "Please specify an extension to unpack."
      else
        raise Compass::Error, "Too many arguments were specified."
      end
    end

usage() click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 91
    def usage
      option_parser([]).to_s
    end

### Public Instance Methods

perform() click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 35
    def perform
      framework = Compass::Frameworks[options[:framework]]
      unless framework
        raise Compass::Error, "No extension named \"#{options[:framework]}\" was found."
      end
      files = Dir["#{framework.path}/**/*"]
      extension_dir = File.join(Compass.configuration.extensions_path, framework.name)
      FileUtils.rm_rf extension_dir
      FileUtils.mkdir_p extension_dir
      write_file File.join(extension_dir, "DO_NOT_MODIFY"), readme(framework)
      files.each do |f|
        next if File.directory?(f)
        ending = f[(framework.path.size+1)..-1]
        destination = File.join(extension_dir, ending)
        FileUtils.mkdir_p(File.dirname(destination))
        copy f, destination
      end
      puts "\nYou have unpacked \"#{framework.name}\""
      puts
      puts readme(framework)
    end

readme(framework) click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 57
    def readme(framework)
      %{| This is a copy of the "#{framework.name}" extension.
         |
         | It now overrides the original which was found here:
         |
         | #{framework.path}
         |
         | Unpacking an extension is useful when you need to easily peruse the
         | extension's source. You might find yourself tempted to change the
         | stylesheets here. If you do this, you'll find it harder to take
         | updates from the original author. Sometimes this seems like a good
         | idea at the time, but in a few months, you'll probably regret it.
         |
         | In the future, if you take an update of this framework, you'll need to run
         |
         |     compass unpack #{framework.name}
         |
         | again or remove this unpacked extension.
         |}.gsub(/^\s*\| ?/,"")
    end

skip_extension_discovery?() click to toggle source

    # File lib/compass/commands/unpack_extension.rb, line 78
    def skip_extension_discovery?
      true
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.