145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/forge/builder.rb', line 145
def build_assets
[['style.css'], ['javascripts', 'theme.js'], ['javascripts', 'admin.js']].each do |asset|
destination = File.join(@project.build_path, asset)
sprocket = @sprockets.find_asset(asset.last)
begin
@task.shell.mute do
FileUtils.mkdir_p(File.dirname(destination)) unless File.directory?(File.dirname(destination))
sprocket.write_to(destination) unless sprocket.nil?
if @project.config[:compress_js] && destination.end_with?('.js')
require "yui/compressor"
sprockets_output = File.open(destination, 'r').read
File.open(destination, 'w') do |file|
file.write(YUI::JavaScriptCompressor.new.compress(sprockets_output))
end
end
end
rescue Exception => e
@task.say "Error while building #{asset.last}:"
@task.say e.message, Thor::Shell::Color::RED
File.open(destination, 'w') do |file|
file.puts(e.message)
end
init_sprockets
end
end
FileUtils.cp_r(File.join(@assets_path, 'images'), @project.build_path) if File.exists?(File.join(@assets_path, 'images'))
Dir.glob(File.join(@project.build_path, 'images', '*')).each do |filename|
if filename.index(/screenshot\.(png|jpg|jpeg|gif)/)
FileUtils.mv(filename, @project.build_path + File::SEPARATOR )
end
end
end
|