Class: Compass::Commands::UnpackExtension
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 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) ⇒ UnpackExtension
Returns a new instance of UnpackExtension.
30
31
32
33
|
# File 'lib/compass/commands/unpack_extension.rb', line 30
def initialize(working_path, options)
super
assert_project_directory_exists!
end
|
Class Method Details
.description(command) ⇒ Object
95
96
97
|
# File 'lib/compass/commands/unpack_extension.rb', line 95
def description(command)
"Copy an extension into your extensions folder."
end
|
.option_parser(arguments) ⇒ Object
.parse!(arguments) ⇒ Object
99
100
101
102
103
104
|
# 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) ⇒ Object
106
107
108
109
110
111
112
113
114
|
# 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 ⇒ Object
91
92
93
|
# File 'lib/compass/commands/unpack_extension.rb', line 91
def usage
option_parser([]).to_s
end
|
Instance Method Details
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# 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) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# 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? ⇒ Boolean
78
79
80
|
# File 'lib/compass/commands/unpack_extension.rb', line 78
def skip_extension_discovery?
true
end
|