Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: embedded-recor…
Fetching contributors…

Cannot retrieve contributors at this time

116 lines (98 sloc) 2.752 kB
require "rake-pipeline-web-filters"
require "json"
require "uglifier"
class EmberProductionFilter < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
result = File.read(input.fullpath)
result.gsub!(%r{^(\s)*Ember\.(assert|deprecate|warn)\((.*)\).*$}, "")
output.write result
end
end
end
class EmberLicenseFilter < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
file = File.read(input.fullpath)
license = File.read("generators/license.js")
output.write "#{license}\n\n#{file}"
end
end
end
class JSHintRC < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
file = File.read(input.fullpath)
jshintrc = File.read(".jshintrc")
output.write "var JSHINTRC = #{jshintrc};\n\n#{file}"
end
end
end
distros = {
:full => %w(ember-data)
}
output "dist"
input "packages" do
output "tests"
match "*/tests/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id.sub!('/tests', '/~tests')
id
}
concat "ember-data-tests.js"
end
match "ember-data-tests.js" do
filter JSHintRC
end
end
input "packages" do
match "*/lib/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id
}
concat "ember-data-spade.js"
end
end
input "packages" do
match "*/lib/**/main.js" do
neuter(
:additional_dependencies => proc { |input|
Dir.glob(File.join(File.dirname(input.fullpath),'**','*.js'))
},
:path_transform => proc { |path, input|
package, path = path.split('/', 2)
current_package = input.path.split('/', 2)[0]
current_package == package && path ? File.join(package, "lib", "#{path}.js") : nil
},
:closure_wrap => true
) do |filename|
File.join("modules/", filename.gsub('/lib/main.js', '.js'))
end
end
end
distros.each do |name, modules|
name = "ember-data"
input "dist/modules" do
module_paths = modules.map{|m| "#{m}.js" }
match "{#{module_paths.join(',')}}" do
concat(module_paths){ ["#{name}.js", "#{name}.prod.js"] }
end
# Strip dev code
match "#{name}.prod.js" do
filter(EmberProductionFilter) { ["#{name}.prod.js", "#{name}.min.js"] }
end
# Minify
match "#{name}.min.js" do
uglify{ "#{name}.min.js" }
filter EmberLicenseFilter
end
end
end
# vim: filetype=ruby
Jump to Line
Something went wrong with that request. Please try again.