forked from tinkerwell/angular-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
48 lines (36 loc) · 1.21 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
task :default => [:compile]
task :compile do
require File.expand_path("gem/lib/angular-table/version")
require "coffee-script"
require "uglifier"
script = CoffeeScript.compile collect_coffees("coffee")
prepend_author_notice(script)
File.open("angular-table.js", "w") { |file| file.write(script) }
File.open("gem/app/assets/javascripts/angular-table.js", "w") { |file| file.write(script) }
File.open("angular-table.min.js", "w") { |file| file.write(prepend_author_notice(Uglifier.new.compile(script))) }
end
def collect_coffees src
files = ["atTable", "atImplicit", "atPagination", "metaCollector", "setupFactory"]
script = ""
files.each do |file|
script << File.read("#{src}/#{file}.coffee") << "\n"
end
script
end
def prepend_author_notice script
comments = ""
comments << "// author: Samuel Mueller \n"
comments << "// version: #{AngularTable::VERSION} \n"
comments << "// license: MIT \n"
comments << "// homepage: http://github.com/ssmm/angular-table \n"
script.prepend comments
script
end
task :dev do
require "listen"
puts "listening!"
Listen.to!("coffee", :force_polling => true) do |modified, added, removed|
puts "recompiling source!"
`rake compile`
end
end