public
Description: Fluent programming (chained method calls) for JavaScript.
Homepage: http://osteele.com/sources/javascript/fluently/
Clone URL: git://github.com/osteele/fluently.git
fluently / Rakefile
100644 73 lines (61 sloc) 2.117 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
73
require 'rake/packagetask'
 
PROJECT_NAME = "fluently"
RELEASE_VERSION = open('VERSION').read.chomp
PACKAGE_NAME = "#{PROJECT_NAME}-#{RELEASE_VERSION}.tgz"
 
IGNORE_FILES = Dir['**/#*#'] + Dir['**/.#*'] + Dir['build/**'] + Dir['working/**'] + Dir['pkg/*'] + %w{build working agenda.txt}
PACKAGE_FILES = Dir['**/*'] - Dir['*.tgz'] - IGNORE_FILES
 
task :docs => 'build/index.html'
 
Rake::PackageTask.new("fluently", RELEASE_VERSION) do |p|
  p.need_tar = true
  p.package_files.include PACKAGE_FILES
end
 
task :publish => [:package, :docs] do
  target = "osteele.com:osteele.com/sources/javascript/fluently"
  sh "rsync -av --delete . #{target} --exclude build"
  sh "scp 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/javascript/fluently/#{PACKAGE_NAME}"
  content = File.read(t.name).
    sub(/<title>.*?<\/title>/, '<title>Fluently</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
 
SHARED_FILES = %w[fluently.js]
 
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('../lztestkit/src', '.')
end
 
task :push do
  dirsync('.', '../lztestkit/src')
end