forked from datamapper/dm-more
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
156 lines (130 loc) · 3.66 KB
/
Rakefile
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
require 'pathname'
require 'spec/rake/spectask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'fileutils'
include FileUtils
JRUBY = RUBY_PLATFORM =~ /java/
WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
## ORDER IS IMPORTANT
# gems may depend on other member gems of dm-more
gem_paths = %w[
dm-adjust
dm-serializer
dm-validations
dm-types
adapters/dm-ferret-adapter
adapters/dm-rest-adapter
dm-aggregates
dm-ar-finders
dm-cli
dm-constraints
dm-is-list
dm-is-nested_set
dm-is-remixable
dm-is-searchable
dm-is-state_machine
dm-is-tree
dm-is-versioned
dm-migrations
dm-observer
dm-sweatshop
dm-tags
dm-timestamps
rails_datamapper
]
# skip installing ferret on Ruby 1.9 until the gem is fixed
if JRUBY || WINDOWS || RUBY_VERSION < '1.9'
gem_paths -= %w[ adapters/dm-ferret-adapter ]
end
gems = gem_paths.map { |gem_path| File.basename(gem_path) }
excluded_gems = ENV['EXCLUDE'] ? ENV['EXCLUDE'].split(',') : []
gem_paths = gem_paths - excluded_gems
gem_spec = Gem::Specification.new do |gem|
gem.name = 'dm-more'
gem.summary = 'DataMapper Plugins'
gem.description = gem.summary
gem.email = 'dan.kubb [a] gmail [d] com'
gem.homepage = 'http://github.com/datamapper/dm-more/'
gem.authors = [ 'Dan Kubb' ]
gem.version = File.read('VERSION').chomp
gem.rubyforge_project = 'datamapper'
gem.add_dependency 'dm-core', '~> 0.10.3'
gems.each do |gem_name|
gem.add_dependency File.basename(gem_name), '~> 0.10.3'
end
gem.add_development_dependency 'rspec', '~> 1.3'
gem.add_development_dependency 'yard', '~> 0.5'
gem.require_path = 'lib'
gem.files = %w[ LICENSE README.rdoc lib/dm-more.rb ]
end
Rake::GemPackageTask.new(gem_spec) do |package|
package.gem_spec = gem_spec
end
FileList['tasks/**/*.rake'].each { |task| import task }
def rake(cmd, bundle_exec = false)
sh "#{bundle_exec ? 'bundle exec ' : ''}#{RUBY} -S rake #{cmd}", :verbose => true
end
def bundle(cmd)
sh "bundle #{cmd}", :verbose => true
end
desc "Install #{gem_spec.name}"
task :install do
gem_paths.each do |dir|
Dir.chdir(dir) { rake 'install', true }
end
end
desc "Generate gemspecs for all gems in #{gem_spec.name}"
task :gemspec do
gem_paths.each do |dir|
Dir.chdir(dir) { rake 'gemspec', true }
end
end
namespace :bundle do
desc "Runs 'bundle install --without quality' for all gems in #{gem_spec.name} (suitable for spec runs)"
task :install do
gem_paths.each do |dir|
Dir.chdir(dir) { bundle 'install --without quality' }
end
end
namespace :install do
desc "Runs 'bundle install' for all gems in #{gem_spec.name}"
task :quality do
gem_paths.each do |dir|
Dir.chdir(dir) { bundle 'install' }
end
end
end
end
file '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|
lib = if '-adapter' == gem[-8..-1]
gem.split('-')[1..-1].join('_')
else
gem
end
file.puts "require '#{lib}'"
end
end
end
desc "Release #{gem_spec.name}"
task :release => [ :gem ] do
gem_paths.each do |dir|
Dir.chdir(dir) { rake 'release', true }
# workaround Jeweler bug. it was identifying the repo as
# in a dirty state, but it is not. running git status clears
# the dirty state.
system 'git status >/dev/null'
end
sh "#{RUBY} -S gem push pkg/dm-more-#{gem_spec.version}.gem"
end
desc 'Run specs'
task :spec do
exit 1 unless (gem_paths - %w[ rails_datamapper ]).map do |gem_name|
Dir.chdir(gem_name) { rake 'spec', true }
end.all?
end
task :default => :spec