@@ -31,21 +31,23 @@ task :stats do
31
31
puts "Users: #{ resource_count ( 'user' ) } "
32
32
end
33
33
34
- desc "Compile javascript pixel library "
34
+ desc "Compile javascript files "
35
35
task :compile do
36
- library_path = 'public/javascripts/pixel.js'
37
- output_path = "#{ library_path . gsub ( /\. js$/ , '' ) } .min.js"
38
-
39
- puts "Compiling #{ library_path } "
40
- uri = URI ( 'http://closure-compiler.appspot.com/compile' )
41
- options = {
42
- 'js_code' => File . open ( library_path ) . read ,
43
- 'compilation_level' => 'SIMPLE_OPTIMIZATIONS' ,
44
- 'output_format' => 'text' ,
45
- 'output_info' => 'compiled_code'
46
- }
47
- res = Net ::HTTP . post_form ( uri , options )
48
-
49
- puts "Writing compiled code to #{ output_path } "
50
- File . open ( output_path , 'w' ) { |f | f . write ( res . body ) }
36
+ [ 'pixel.js' , 'init.js' ] . each do |file |
37
+ library_path = "public/javascripts/#{ file } "
38
+ output_path = "#{ library_path . gsub ( /\. js$/ , '' ) } .min.js"
39
+
40
+ puts "Compiling #{ library_path } "
41
+ uri = URI ( 'http://closure-compiler.appspot.com/compile' )
42
+ options = {
43
+ 'js_code' => File . open ( library_path ) . read ,
44
+ 'compilation_level' => 'SIMPLE_OPTIMIZATIONS' ,
45
+ 'output_format' => 'text' ,
46
+ 'output_info' => 'compiled_code'
47
+ }
48
+ res = Net ::HTTP . post_form ( uri , options )
49
+
50
+ puts "Writing compiled code to #{ output_path } "
51
+ File . open ( output_path , 'w' ) { |f | f . write ( res . body ) }
52
+ end
51
53
end
0 commit comments