Class: Compass::Commands::UpdateProject
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) ⇒ UpdateProject
Returns a new instance of UpdateProject.
36
37
38
39
|
# File 'lib/compass/commands/update_project.rb', line 36
def initialize(working_path, options)
super
assert_project_directory_exists! unless dry_run?
end
|
Class Method Details
.description(command) ⇒ Object
116
117
118
|
# File 'lib/compass/commands/update_project.rb', line 116
def description(command)
"Compile Sass stylesheets to CSS"
end
|
.option_parser(arguments) ⇒ Object
.parse!(arguments) ⇒ Object
120
121
122
123
124
125
|
# File 'lib/compass/commands/update_project.rb', line 120
def parse!(arguments)
parser = option_parser(arguments)
parser.parse!
parse_arguments!(parser, arguments)
parser.options
end
|
.parse_arguments!(parser, arguments) ⇒ Object
127
128
129
130
131
132
133
134
135
|
# File 'lib/compass/commands/update_project.rb', line 127
def parse_arguments!(parser, arguments)
if arguments.size > 0
parser.options[:project_name] = arguments.shift if File.directory?(arguments.first)
unless arguments.empty?
parser.options[:sass_files] = arguments.dup
parser.options[:force] = true
end
end
end
|
.primary ⇒ Object
114
|
# File 'lib/compass/commands/update_project.rb', line 114
def primary; true; end
|
.usage ⇒ Object
110
111
112
|
# File 'lib/compass/commands/update_project.rb', line 110
def usage
option_parser([]).to_s
end
|
Instance Method Details
#check_for_sass_files!(compiler) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/compass/commands/update_project.rb', line 49
def check_for_sass_files!(compiler)
if compiler.sass_files.empty? && !dry_run?
message = "Nothing to compile. If you're trying to start a new project, you have left off the directory argument.\n"
message << "Run \"compass -h\" to get help."
raise Compass::Error, message
end
end
|
#determine_cache_location ⇒ Object
98
99
100
|
# File 'lib/compass/commands/update_project.rb', line 98
def determine_cache_location
Compass.configuration.cache_path || Sass::Plugin.options[:cache_location] || File.join(working_path, ".sass-cache")
end
|
#dry_run? ⇒ Boolean
57
58
59
|
# File 'lib/compass/commands/update_project.rb', line 57
def dry_run?
options[:dry_run]
end
|
#explicit_sass_files ⇒ Object
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/compass/commands/update_project.rb', line 87
def explicit_sass_files
return unless options[:sass_files]
options[:sass_files].map do |sass_file|
if absolute_path? sass_file
sass_file
else
File.join(Dir.pwd, sass_file)
end
end
end
|
#new_compiler_instance(additional_options = {}) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/compass/commands/update_project.rb', line 61
def new_compiler_instance(additional_options = {})
@compiler_opts ||= begin
compiler_opts = {:sass => Compass.sass_engine_options}
compiler_opts.merge!(options)
compiler_opts[:sass_files] = explicit_sass_files
compiler_opts[:cache_location] = determine_cache_location
if options.include?(:debug_info) && options[:debug_info]
compiler_opts[:sass][:debug_info] = options.delete(:debug_info)
end
compiler_opts
end
@memory_store ||= Sass::CacheStores::Memory.new
@backing_store ||= compiler_opts[:cache_store]
@backing_store ||= Sass::CacheStores::Filesystem.new(determine_cache_location)
@cache_store ||= Sass::CacheStores::Chain.new(@memory_store, @backing_store)
@memory_store.reset!
Compass::Compiler.new(
working_path,
Compass.configuration.sass_path,
Compass.configuration.css_path,
@compiler_opts.merge(:cache_store => @cache_store).merge(additional_options)
)
end
|
41
42
43
44
45
46
47
|
# File 'lib/compass/commands/update_project.rb', line 41
def perform
compiler = new_compiler_instance
check_for_sass_files!(compiler)
compiler.clean! if compiler.new_config?
error_count = compiler.run
failed! if error_count > 0
end
|