jnewland / gsa-prototype

Prototype/Javascript wrapper for the Google Search Appliance Search Protocol. Fancy cross-domain JSON support included.

This URL has Read+Write access

gsa-prototype / Rakefile
100644 60 lines (51 sloc) 1.474 kb
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
49
50
51
52
53
54
55
56
57
58
59
60
require 'rake'
require 'rake/packagetask'
 
desc 'Specs!'
task :test => :spec
 
GSA_ROOT = File.expand_path(File.dirname(__FILE__))
GSA_SRC_DIR = File.join(GSA_ROOT, 'src')
GSA_DIST_DIR = File.join(GSA_ROOT, 'dist')
GSA_PKG_DIR = File.join(GSA_ROOT, 'pkg')
GSA_VERSION = '0.2.0'
 
desc 'Build a combined JS file for distibution'
task :dist do
  $:.unshift File.join(GSA_ROOT, 'lib')
  require 'protodoc'
  
  Dir.chdir(GSA_SRC_DIR) do
    File.open(File.join(GSA_DIST_DIR, 'gsa-prototype.js'), 'w+') do |dist|
      dist << Protodoc::Preprocessor.new('gsa-prototype.js.erb')
    end
  end
end
 
Rake::PackageTask.new('gsa-prototype', GSA_VERSION) do |package|
  package.need_tar_gz = true
  package.package_dir = GSA_PKG_DIR
  package.package_files.include(
    '[A-Z]*',
    'dist/gsa-prototype.js',
    'lib/**',
    'src/**',
    'spec/**',
    'xsl/**'
  )
end
 
task :clean_package_source do
  rm_rf File.join(GSA_PKG_DIR, "gsa-prototype-#{VERSION}")
end
 
task :spec do
  files = ENV['STAKEOUT'] rescue 'spec/*.html'
  files = FileList[files]
  
  files.each do |file|
    if file =~ /\/([^\/]+)\.js$/
      file = "spec/#{$1}.html"
    end
    unless File.exists?(file)
      puts "Notice: Test file does not exist: #{file}"
      next
    end
    `open #{file} -a Safari -g`
  end
end
 
#TODO create a task to build with builder.js prepended
#TODO create a task to build with prototype.js and builder.js prepended
#TODO create a task to compress the JS file we build