File: Rakefile

package info (click to toggle)
backbone 0.9.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,252 kB
  • ctags: 229
  • sloc: makefile: 49
file content (43 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download
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
require 'rubygems'

HEADER = /((^\s*\/\/.*\n)+)/

desc "rebuild the backbone-min.js files for distribution"
task :build do
  begin
    require 'closure-compiler'
  rescue LoadError
    puts "closure-compiler not found.\nInstall it by running 'gem install closure-compiler'"
    exit
  end
  source = File.read 'backbone.js'
  header = source.match(HEADER)
  File.open('backbone-min.js', 'w+') do |file|
    file.write header[1].squeeze(' ') + Closure::Compiler.new.compress(source)
  end
end

desc "build the docco documentation"
task :doc do
  check 'docco', 'docco', 'https://github.com/jashkenas/docco'
  system 'docco backbone.js && docco examples/todos/todos.js examples/backbone-localstorage.js'
end

desc "run JavaScriptLint on the source"
task :lint do
  check 'jsl', 'JavaScript Lint', 'http://www.javascriptlint.com/'
  system "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js"
end

desc "test the CoffeeScript integration"
task :test do
  check 'coffee', 'CoffeeScript', 'http://coffeescript.org/'
  system "coffee test/*.coffee"
end

# Check for the existence of an executable.
def check(exec, name, url)
  return unless `which #{exec}`.empty?
  puts "#{name} not found.\nInstall it from #{url}"
  exit
end