class 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
Calls superclass method
Compass::Commands::ProjectBase.new
# 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) %Q{| 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