-
-
Save shingara/153682 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
%w[rubygems sinatra jsmin cssmin].each{|l| require l} | |
configure :development do | |
set :js_proc, proc {|f| "\n/* '#{f}' */\n" + File.read(f)} | |
set :css_proc, proc {|f| "\n/* '#{f}' */\n" +File.read(f)} | |
end | |
configure :production do | |
set :js_proc, | |
proc{|f|"/* '#{File.basename(f)}' */\n" + JSMin.minify(File.read(f))} | |
set :css_proc, | |
proc{|f| "/* '#{File.basename(f)}' */\n"+ CSSMin.minify(File.read(f))} | |
end | |
def bundle(name, *files) | |
# All the needed variables | |
format = name.sub!(/.*\.(.*)$/, $1) | |
file = options.public + '/' + options.bundle | |
# Now, we read each file and concatenate it in an array | |
bundle = files.map { |f| options.public + "/#{f}.#{format}"} \ | |
.map { |f| options.send("#{format}_proc",f) }.join("\n") | |
# If it does not exist | |
FileUtils.mkdir_p(File.dirname(file) | |
File.open(file, 'a+').write(bundle) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment