Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 132 lines (113 sloc) 2.929 kb
4043134 Initial commit
Devin Torres authored
1 APPNAME = 'ember-skeleton'
2
3 require 'json'
4 require 'rake-pipeline-web-filters'
5
6 WebFilters = Rake::Pipeline::Web::Filters
7
8 class LoaderFilter < WebFilters::MinispadeFilter
9 def generate_output(inputs, output)
10 inputs.each do |input|
11 code = input.read
12 module_id = @module_id_generator.call(input)
13 contents = "function(require) {\n#{code}\n}"
14 ret = "\nloader.register('#{module_id}', #{contents});\n"
15 output.write ret
16 end
17 end
18 end
19
20 class EmberAssertFilter < Filter
21 def generate_output(inputs, output)
22 inputs.each do |input|
23 result = input.read
0d99398 Devin Torres Upgrade packages and use the latest Ember conventions
authored
24 result.gsub!(%r{^(\s)*Ember\.(assert|deprecate|warn)\((.*)\).*$}, '')
4043134 Initial commit
Devin Torres authored
25 output.write(result)
26 end
27 end
28 end
29
30 class HandlebarsFilter < Filter
31 def generate_output(inputs, output)
32 inputs.each do |input|
33 code = input.read.to_json
34 output.write "\nreturn Ember.Handlebars.compile(#{code});\n"
35 end
36 end
37 end
38
39 output 'assets'
40
a7c55ae Add README section on app structure
Devin Torres authored
41 input 'app' do
42 match 'lib/**/*.js' do
43 filter LoaderFilter,
44 :module_id_generator => proc { |input|
45 input.path.sub(/^lib\//, "#{APPNAME}/").sub(/\.js$/, '')
46 }
4043134 Initial commit
Devin Torres authored
47
a7c55ae Add README section on app structure
Devin Torres authored
48 if ENV['RAKEP_MODE'] == 'production'
49 filter EmberAssertFilter
50 uglify {|input| input}
51 end
52 concat 'app.js'
4043134 Initial commit
Devin Torres authored
53 end
54
a7c55ae Add README section on app structure
Devin Torres authored
55 match 'vendor/**/*.js' do
56 filter LoaderFilter,
57 :module_id_generator => proc { |input|
58 input.path.sub(/^vendor\//, '').sub(/\.js$/, '')
59 }
4043134 Initial commit
Devin Torres authored
60
a7c55ae Add README section on app structure
Devin Torres authored
61 if ENV['RAKEP_MODE'] == 'production'
62 filter EmberAssertFilter
63 uglify {|input| input}
64 end
65 concat %w[
66 vendor/jquery.js
67 vendor/ember.js
68 vendor/ember-data.js
69 ], 'app.js'
4043134 Initial commit
Devin Torres authored
70 end
71
a7c55ae Add README section on app structure
Devin Torres authored
72 match 'modules/**/*.js' do
73 if ENV['RAKEP_MODE'] == 'production'
74 filter EmberAssertFilter
75 uglify {|input| input}
76 end
77 concat 'app.js'
4043134 Initial commit
Devin Torres authored
78 end
79
a7c55ae Add README section on app structure
Devin Torres authored
80 match 'plugins/**/*.js' do
81 if ENV['RAKEP_MODE'] == 'production'
82 uglify {|input| input}
83 end
84 concat do |input|
85 input.sub(/plugins\//, '')
86 end
4043134 Initial commit
Devin Torres authored
87 end
88
a7c55ae Add README section on app structure
Devin Torres authored
89 match 'templates/**/*.handlebars' do
90 filter HandlebarsFilter
91 filter LoaderFilter,
92 :module_id_generator => proc { |input|
93 input.path.sub(/^templates\//, "#{APPNAME}/~templates/").sub(/\.handlebars$/, '')
94 }
95 if ENV['RAKEP_MODE'] == 'production'
96 uglify {|input| input}
97 end
98 concat 'app.js'
99 end
100
5603f65 Devin Torres Tons of improvements. Parity with current ember gem
authored
101 match 'tests/**/*.js' do
102 filter LoaderFilter,
103 :module_id_generator => proc { |input|
104 input.path.sub(/^lib\//, "#{APPNAME}/").sub(/\.js$/, '')
105 }
106 concat 'app-tests.js'
107 end
108
a7c55ae Add README section on app structure
Devin Torres authored
109 match 'css/**/*.css' do
110 if ENV['RAKEP_MODE'] == 'production'
111 yui_css
112 end
113 concat ['bootstrap.css', 'main.css'], 'app.css'
4043134 Initial commit
Devin Torres authored
114 end
115
a7c55ae Add README section on app structure
Devin Torres authored
116 match 'css/**/*.scss' do
117 sass
118 if ENV['RAKEP_MODE'] == 'production'
119 yui_css
120 end
121 concat 'app.css'
122 end
123
124 match "static/**/*" do
125 concat do |input|
126 input.sub(/static\//, '')
127 end
4043134 Initial commit
Devin Torres authored
128 end
129 end
130
5603f65 Devin Torres Tons of improvements. Parity with current ember gem
authored
131 # vim: filetype=ruby
Something went wrong with that request. Please try again.