public
Rubygem
Description: Extras for DataMapper, including bridges to DataObjects::Migrations and Merb::DataMapper
Homepage: http://datamapper.org
Clone URL: git://github.com/sam/dm-more.git
Search Repo:
myabc (author)
Thu May 08 15:25:29 -0700 2008
commit  ecab0d300e9c9543c619661059d67c52e9d24869
tree    6d1c5af21a1f3d3473d846535c33999fa578daa7
parent  1569d96fa9c302ce85b327c5d9fd6fc9c20b1756
dm-more / Rakefile
100755 184 lines (153 sloc) 4.866 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
module DataMapper
  # Set this to the version of dm-core that you are building against/for
  VERSION = "0.9.0"
 
  # Set this to the version of dm-more you plan to release
  MORE_VERSION = "0.9.0"
end
 
require 'pathname'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher'
require 'spec/rake/spectask'
require 'rake/rdoctask'
require 'fileutils'
include FileUtils
 
DIR = Pathname(__FILE__).dirname.expand_path.to_s
 
gems = %w[
merb_datamapper
dm-migrations
dm-serializer
dm-types
dm-validations
dm-cli
dm-is-tree
dm-timestamps
dm-aggregates
couchdb_adapter
dm-ar-finders
]
 
PROJECT = "dm-more"
 
dm_more_spec = Gem::Specification.new do |s|
  s.platform = Gem::Platform::RUBY
  s.name = PROJECT
  s.summary = "An Object/Relational Mapper for Ruby"
  s.description = "Faster, Better, Simpler."
  s.version = DataMapper::MORE_VERSION
 
  s.authors = "Sam Smoot"
  s.email = "ssmoot@gmail.com"
  s.rubyforge_project = PROJECT
  s.homepage = "http://datamapper.org"
 
  s.files = %w[ MIT-LICENSE README Rakefile TODO ]
  s.add_dependency("dm-core", ">= #{DataMapper::VERSION}")
  gems.each do |gem|
    s.add_dependency gem, [">= #{DataMapper::VERSION}"]
  end
end
 
Rake::GemPackageTask.new(dm_more_spec) do |p|
  p.gem_spec = dm_more_spec
  p.need_tar = true
  p.need_zip = true
end
 
CLEAN.include ["**/.*.sw?", "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", "coverage", "cache", "lib/merb-more.rb"]
 
windows = (PLATFORM =~ /win32|cygwin/) rescue nil
 
SUDO = windows ? "" : "sudo"
 
desc "Install it all"
task :install => [:install_gems, :package] do
  sh %{#{SUDO} gem install --local pkg/dm-more-#{DataMapper::MORE_VERSION}.gem --no-update-sources}
# sh %{#{SUDO} gem install --local pkg/dm-#{DataMapper::MORE_VERSION}.gem --no-update-sources}
end
 
desc "Build the dm-more gems"
task :build_gems do
  gems.each do |dir|
    Dir.chdir(dir){ sh "rake gem" }
  end
end
 
desc "Install the dm-more gems"
task :install_gems => :build_gems do
  gems.each do |dir|
    Dir.chdir(dir){ sh "#{SUDO} rake install" }
  end
end
 
desc "Uninstall the dm-more gems"
task :uninstall_gems do
  gems.each do |sub_gem|
    sh %{#{SUDO} gem uninstall #{sub_gem}}
  end
end
 
task :package => ["lib/dm-more.rb"]
desc "Create dm-more.rb"
task "lib/dm-more.rb" do
  mkdir_p "lib"
  File.open("lib/dm-more.rb","w+") do |file|
    file.puts "### AUTOMATICALLY GENERATED. DO NOT EDIT."
    gems.each do |gem|
      next if gem == "dm-gen"
      file.puts "require '#{gem}'"
    end
  end
end
 
desc "Bundle up all the dm-more gems"
task :bundle => [:package, :build_gems] do
  mkdir_p "bundle"
# cp "pkg/dm-#{DataMapper::MORE_VERSION}.gem", "bundle"
  cp "pkg/dm-more-#{DataMapper::MORE_VERSION}.gem", "bundle"
  gems.each do |gem|
    File.open("#{gem}/Rakefile") do |rakefile|
      rakefile.read.detect {|l| l =~ /^VERSION\s*=\s*"(.*)"$/ }
      sh %{cp #{gem}/pkg/#{gem}-#{$1}.gem bundle/}
    end
  end
end
 
namespace :ci do
 
  gems.each do |gem_name|
    task gem_name do
      ENV['gem_name'] = gem_name
 
      Rake::Task["ci:run_all"].invoke
    end
  end
 
  task :run_all => [:spec, :install, :doc, :publish]
  
  task :spec_all => :define_tasks do
    gems.each do |gem_name|
      Rake::Task["#{gem_name}:spec"].invoke
    end
  end
 
  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 do
    sh %{cd #{ENV['gem_name']} && rake install}
  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 && File.exists?("rspec_report.html")
  end
 
  task :define_tasks do
    gem_names = [(ENV['gem_name'] || gems)].flatten
    gem_names.each do |gem_name|
      Spec::Rake::SpecTask.new("#{gem_name}:spec") do |t|
        puts "#{gem_name}:spec"
        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,#{(gems - [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
end