public
Description: BDD for OpenLaszlo.
Homepage:
Clone URL: git://github.com/osteele/lztestkit.git
lztestkit / Rakefile
100644 72 lines (61 sloc) 2.381 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
61
62
63
64
65
66
67
68
69
70
71
72
RELEASE_VERSION = open('VERSION').read.chomp
ARCHIVE_NAME = "lztestkit-#{RELEASE_VERSION}.tgz"
IGNORE = Dir['**/#*#'] + Dir['**/.#*'] + Dir['build/**'] + Dir['working/**'] + %w{build working agenda.txt}
 
task :archive => ARCHIVE_NAME
task :docs => 'build/index.html'
 
file ARCHIVE_NAME => Dir['**/*'] - Dir['*.tgz'] - IGNORE do |t|
  puts t.prerequisites.sort.join("\n") if ENV['verbose']
  sh "tar cfz #{t.name} #{t.prerequisites - ['Rakefile']}"
end
 
task :publish => [ARCHIVE_NAME, :docs] do
  target = "osteele.com:osteele.com/sources/openlaszlo/lztestkit"
  sh "rsync README #{ARCHIVE_NAME} #{target}"
  sh "rsync build/index.html #{target}/index.html"
end
 
task :clean do
  files = Dir['*.tgz']
  rm files if files.any?
end
 
task 'build/index.html' => 'README' do |t|
  mkdir_p 'build'
  sh "rdoc --one-file -n build/index.html README"
  url = "http://osteele.com/sources/openlaszlo/#{ARCHIVE_NAME}"
  content = File.read(t.name).
    sub(/<title>.*?<\/title>/, '<title>LzTestKit</title>').
    sub(/<h2>File:.*?<\/h2>/, '').
    sub(/<h2>Classes<\/h2>/, '').
    sub(/<table.*?<\/table>/m, '').
    sub('{download-location}', "<a href=\"#{url}\">#{url}</a>")
  File.open(t.name, 'w').write(content)
end
 
AUTORUN_FILES = %w{autorun-browser.js autorun-lz.js autorun.css list-files.jsp}
SHARED_FILES = AUTORUN_FILES + %w(fluently.js jsspec.js lzmock.js lzspec.js lzunit-async.lzx lzunit-extensions.js lztimer.lzx lztimer-browser.js)
 
# TODO: sync sequencing.js, fluently.js with jsutils
 
def dirsync(source_dir, target_dir)
  options = {}
  options[:noop] = true if ENV['dryrun']
  SHARED_FILES.each do |fname|
    source = File.expand_path(File.join(source_dir, fname))
    target = File.expand_path(File.join(target_dir, fname))
    copy = false
    case
    when !File.exists?(target)
      copy = true
    when (File.size(source) == File.size(target) and
            File.read(source) == File.read(target))
      copy = false
    when File.mtime(source) < File.mtime(target)
      puts "Skipping #{fname}: source is older than target"
      sh "ls -l {#{source_dir},#{target_dir}}/#{fname}" if ENV['verbose']
    else
      copy = true
    end
    cp source, target, options if copy
  end
end
 
task :pull do
  dirsync('~/perforce/dc/client/applib/calendar/test/includes', 'src')
end
 
task :push do
  dirsync('src', '~/perforce/dc/client/applib/calendar/test/includes')
end