sam / do fork watch download tarball
public
Rubygem
Description: DataObjects
Homepage: http://rubyforge.org/projects/dorb
Clone URL: git://github.com/sam/do.git
dkubb (author)
Thu May 15 13:48:19 -0700 2008
commit  c540d9f98ad08607081c6a28a791908e39557a59
tree    4fae23ab42d7cc97ecde171b2d22a4b175f90d20
parent  0da60a83e284ec987bdc3bdcfd82f7fe9b0bd221
do / Rakefile
100644 106 lines (82 sloc) 3.136 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env ruby
 
# do rake file
 
require 'pathname'
require 'rubygems'
require 'rake'
require Pathname('spec/rake/spectask')
require Pathname('rake/rdoctask')
 
DIR = Pathname(__FILE__).dirname.expand_path.to_s
 
WIN32 = (PLATFORM =~ /win32|cygwin/) rescue nil
SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
 
# projects = %w[data_objects do_jdbc do_mysql do_postgres do_sqlite3]
# Took out do_jdbc since it doesn't build yet.
projects = %w[data_objects do_mysql do_postgres do_sqlite3]
 
desc 'Install the do gems'
task :install => [ 'ci:install_all' ]
 
desc 'Run specifications'
Spec::Rake::SpecTask.new(:spec) do |t|
  t.spec_opts << '--format specdoc' << '--color'
  t.spec_files = Pathname.glob(Pathname.new(__FILE__).parent + '**/spec/**/*_spec.rb')
end
 
task 'do:spec' => [ 'spec' ]
 
namespace :ci do
 
  projects.each do |gem_name|
    task gem_name do
      ENV['gem_name'] = gem_name
 
      Rake::Task["ci:run_all"].invoke
    end
  end
 
  task :install_all do
    projects.each do |gem_name|
      cd(File.join(File.dirname(__FILE__), gem_name))
      sh("rake install")
    end
  end
 
  task :run_all => [:spec, :install, :doc, :publish]
 
  task :spec => :define_tasks do
    Rake::Task["#{ENV['gem_name']}:spec"].invoke
  end
 
  task :doc => :define_tasks do
    Rake::Task["#{ENV['gem_name']}:doc"].invoke
  end
 
  task :install => :uninstall do
    sh %{cd #{ENV['gem_name']} && rake install}
  end
 
  task :uninstall do
    sh %{#{SUDO} gem uninstall #{ENV['gem_name']} --ignore-dependencies} rescue nil
  end
 
  task :publish do
    out = ENV['CC_BUILD_ARTIFACTS'] || "out"
    mkdir_p out unless File.directory? out if out
 
    mv "rdoc", "#{out}/rdoc" if out
    mv "coverage", "#{out}/coverage_report" if out && File.exists?("coverage")
    mv "rspec_report.html", "#{out}/rspec_report.html" if out
  end
 
  task :define_tasks do
    gem_name = ENV['gem_name']
 
    unless FileList["#{DIR}/#{gem_name}/ext/**/extconf.rb"].empty?
      file "#{gem_name}/Makefile" => FileList["#{DIR}/#{gem_name}/ext/**/extconf.rb", "#{DIR}/#{gem_name}/ext/**/*.c", "#{DIR}/#{gem_name}/ext/**/*.h"] do
        system("cd #{gem_name} && ruby ext/extconf.rb")
        system("cd #{gem_name} && make all") || system("cd #{gem_name} && nmake all")
      end
      task "#{gem_name}:spec" => "#{gem_name}/Makefile"
    end
 
    Spec::Rake::SpecTask.new("#{gem_name}:spec") do |t|
      t.spec_opts = ["--format", "specdoc", "--format", "html:rspec_report.html", "--diff"]
      t.spec_files = Pathname.glob(ENV['FILES'] || DIR + "/#{gem_name}/spec/**/*_spec.rb")
      unless ENV['NO_RCOV']
        t.rcov = true
        t.rcov_opts << '--exclude' << "spec,gems,#{(projects - [gem_name]).join(',')}"
        t.rcov_opts << '--text-summary'
        t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
        t.rcov_opts << '--only-uncovered'
      end
    end
 
    Rake::RDocTask.new("#{gem_name}:doc") do |t|
      t.rdoc_dir = 'rdoc'
      t.title = gem_name
      t.options = ['--line-numbers', '--inline-source', '--all']
      t.rdoc_files.include("#{gem_name}/lib/**/*.rb", "#{gem_name}/ext/**/*.c")
    end
  end
end