Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 122 lines (104 sloc) 3.235 kB
c6f6a28 @tchak Initial commit
tchak authored
1 require "rake-pipeline-web-filters"
5b1ed8f @tchak upgrade to new tool chain
tchak authored
2 require "json"
3 require "uglifier"
c6f6a28 @tchak Initial commit
tchak authored
4
5b1ed8f @tchak upgrade to new tool chain
tchak authored
5 class EmberProductionFilter < Rake::Pipeline::Filter
6 def generate_output(inputs, output)
7 inputs.each do |input|
8 result = File.read(input.fullpath)
9 result.gsub!(%r{^(\s)+ember_(assert|deprecate|warn)\((.*)\).*$}, "")
10 output.write result
11 end
12 end
13 end
c6f6a28 @tchak Initial commit
tchak authored
14
5b1ed8f @tchak upgrade to new tool chain
tchak authored
15 class EmberLicenseFilter < Rake::Pipeline::Filter
16 def generate_output(inputs, output)
17 inputs.each do |input|
18 file = File.read(input.fullpath)
19 license = File.read("generators/license.js")
20 output.write "#{license}\n\n#{file}"
21 end
22 end
23 end
c6f6a28 @tchak Initial commit
tchak authored
24
5b1ed8f @tchak upgrade to new tool chain
tchak authored
25 class JSHintRC < Rake::Pipeline::Filter
26 def generate_output(inputs, output)
27 inputs.each do |input|
28 file = File.read(input.fullpath)
29 jshintrc = File.read(".jshintrc")
30 output.write "var JSHINTRC = #{jshintrc};\n\n#{file}"
31 end
c6f6a28 @tchak Initial commit
tchak authored
32 end
33 end
34
5b1ed8f @tchak upgrade to new tool chain
tchak authored
35 distros = {
36 :full => %w(ember-browser ember-searchable ember-utils ember-geolocation ember-orientation ember-responder ember-validators ember-form ember-datetime ember-history ember-overlay),
37 :utils => %w(ember-browser ember-searchable ember-utils),
38 :mobile => %w(ember-geolocation ember-orientation),
39 :form => %w(ember-responder ember-validators ember-form),
40 :datetime => %w(ember-datetime),
41 :history => %w(ember-history),
42 :overlay => %w(ember-overlay)
43 }
44
45 output "dist"
46
47 input "packages" do
48 output "tests"
49
50 match "*/tests/**/*.js" do
51 minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
52 id = input.path.dup
53 id.sub!(/\.js$/, '')
54 id.sub!(/\/main$/, '')
55 id.sub!('/tests', '/~tests')
56 id
57 }
58
59 concat "ember-addons-tests.js"
60 end
61
62 match "ember-addons-tests.js" do
63 filter JSHintRC
64 end
c6f6a28 @tchak Initial commit
tchak authored
65 end
66
5b1ed8f @tchak upgrade to new tool chain
tchak authored
67 input "packages" do
68 match "*/lib/**/*.js" do
69 minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
70 id = input.path.dup
71 id.sub!('/lib/', '/')
72 id.sub!(/\.js$/, '')
73 id.sub!(/\/main$/, '')
74 id
75 }
76
77 concat "ember-addons-spade.js"
78 end
c6f6a28 @tchak Initial commit
tchak authored
79 end
80
5b1ed8f @tchak upgrade to new tool chain
tchak authored
81 input "packages" do
82 match "*/lib/**/main.js" do
83 neuter(
84 :additional_dependencies => proc { |input|
85 Dir.glob(File.join(File.dirname(input.fullpath),'**','*.js'))
86 },
87 :path_transform => proc { |path, input|
88 package, path = path.split('/', 2)
89 current_package = input.path.split('/', 2)[0]
90 current_package == package && path ? File.join(package, "lib", "#{path}.js") : nil
91 },
92 :closure_wrap => true
93 ) do |filename|
94 File.join("modules/", filename.gsub('/lib/main.js', '.js'))
95 end
96 end
c6f6a28 @tchak Initial commit
tchak authored
97 end
98
5b1ed8f @tchak upgrade to new tool chain
tchak authored
99 distros.each do |name, modules|
100 name = name == :full ? "ember-addons" : "ember-#{name}"
101
102 input "dist/modules" do
103 module_paths = modules.map{|m| "#{m}.js" }
104 match "{#{module_paths.join(',')}}" do
105 concat(module_paths){ ["#{name}.js", "#{name}.prod.js"] }
106 end
107
108 # Strip dev code
109 match "#{name}.prod.js" do
110 filter(EmberProductionFilter) { ["#{name}.prod.js", "#{name}.min.js"] }
111 end
112
113 # Minify
114 match "#{name}.min.js" do
115 uglify{ "#{name}.min.js" }
116 filter EmberLicenseFilter
117 end
118 end
119 end
c6f6a28 @tchak Initial commit
tchak authored
120
121 # vim: filetype=ruby
Something went wrong with that request. Please try again.