Skip to content

Commit 26eb8b1

Browse files
committedDec 2, 2013
Added Rakefiles for main and subprojects
1 parent 8e0454e commit 26eb8b1

File tree

3 files changed

+194
-0
lines changed

3 files changed

+194
-0
lines changed
 

‎Rakefile

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
require 'pathname'
2+
3+
subprojects = %w| elasticsearch-model elasticsearch-rails |
4+
__current__ = Pathname( File.expand_path('..', __FILE__) )
5+
6+
task :default do
7+
system "rake --tasks"
8+
end
9+
10+
desc "List all subprojects"
11+
task :subprojects do
12+
puts '-'*80
13+
subprojects.each do |project|
14+
commit = `git log --pretty=format:'%h %ar: %s' -1 #{project}`
15+
version = Gem::Specification::load(__current__.join(project, "#{project}.gemspec").to_s).version.to_s
16+
puts "[#{version}] \e[1m#{project.ljust(subprojects.map {|s| s.length}.max)}\e[0m | #{commit[ 0..80]}..."
17+
end
18+
end
19+
20+
namespace :test do
21+
desc "Run `bundle install` in all subprojects"
22+
task :bundle do
23+
subprojects.each do |project|
24+
sh "bundle install --gemfile #{__current__.join(project)}/Gemfile"
25+
puts '-'*80
26+
end
27+
end
28+
29+
desc "Run unit tests in all subprojects"
30+
task :unit do
31+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
32+
subprojects.each do |project|
33+
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:unit"
34+
puts '-'*80
35+
end
36+
Rake::Task['test:coveralls'].invoke if ENV['CI'] && defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
37+
end
38+
39+
desc "Run integration tests in all subprojects"
40+
task :integration do
41+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
42+
subprojects.each do |project|
43+
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:integration"
44+
puts '-'*80
45+
end
46+
Rake::Task['test:coveralls'].invoke if ENV['CI'] && defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
47+
end
48+
49+
desc "Run all tests in all subprojects"
50+
task :all do
51+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
52+
subprojects.each do |project|
53+
sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:all"
54+
puts '-'*80
55+
end
56+
end
57+
58+
task :coveralls do
59+
require 'coveralls/rake/task'
60+
Coveralls::RakeTask.new
61+
Rake::Task['coveralls:push'].invoke
62+
end
63+
64+
task :ci_reporter do
65+
ENV['CI_REPORTS'] ||= 'tmp/reports'
66+
if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
67+
require 'ci/reporter/rake/test_unit'
68+
Rake::Task['ci:setup:testunit'].invoke
69+
else
70+
require 'ci/reporter/rake/minitest'
71+
Rake::Task['ci:setup:minitest'].invoke
72+
end
73+
end
74+
end
75+
76+
desc "Generate documentation for all subprojects"
77+
task :doc do
78+
subprojects.each do |project|
79+
sh "cd #{__current__.join(project)} && rake doc"
80+
puts '-'*80
81+
end
82+
end
83+
84+
desc "Release all subprojects to Rubygems"
85+
task :release do
86+
subprojects.each do |project|
87+
sh "cd #{__current__.join(project)} && rake release"
88+
puts '-'*80
89+
end
90+
end

‎elasticsearch-model/Rakefile

+52
Original file line numberDiff line numberDiff line change
@@ -1 +1,53 @@
11
require "bundler/gem_tasks"
2+
3+
desc "Run unit tests"
4+
task :default => 'test:unit'
5+
task :test => 'test:unit'
6+
7+
# ----- Test tasks ------------------------------------------------------------
8+
9+
require 'rake/testtask'
10+
namespace :test do
11+
task :ci_reporter do
12+
ENV['CI_REPORTS'] ||= 'tmp/reports'
13+
require 'ci/reporter/rake/minitest'
14+
Rake::Task['ci:setup:minitest'].invoke
15+
end
16+
17+
Rake::TestTask.new(:unit) do |test|
18+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
19+
test.libs << 'lib' << 'test'
20+
test.test_files = FileList["test/unit/**/*_test.rb"]
21+
# test.verbose = true
22+
# test.warning = true
23+
end
24+
25+
Rake::TestTask.new(:integration) do |test|
26+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
27+
test.libs << 'lib' << 'test'
28+
test.test_files = FileList["test/integration/**/*_test.rb"]
29+
end
30+
31+
Rake::TestTask.new(:all) do |test|
32+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
33+
test.libs << 'lib' << 'test'
34+
test.test_files = FileList["test/unit/**/*_test.rb", "test/integration/**/*_test.rb"]
35+
end
36+
end
37+
38+
# ----- Documentation tasks ---------------------------------------------------
39+
40+
require 'yard'
41+
YARD::Rake::YardocTask.new(:doc) do |t|
42+
t.options = %w| --embed-mixins --markup=markdown |
43+
end
44+
45+
# ----- Code analysis tasks ---------------------------------------------------
46+
47+
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
48+
require 'cane/rake_task'
49+
Cane::RakeTask.new(:quality) do |cane|
50+
cane.abc_max = 15
51+
cane.no_style = true
52+
end
53+
end

‎elasticsearch-rails/Rakefile

+52
Original file line numberDiff line numberDiff line change
@@ -1 +1,53 @@
11
require "bundler/gem_tasks"
2+
3+
desc "Run unit tests"
4+
task :default => 'test:unit'
5+
task :test => 'test:unit'
6+
7+
# ----- Test tasks ------------------------------------------------------------
8+
9+
require 'rake/testtask'
10+
namespace :test do
11+
task :ci_reporter do
12+
ENV['CI_REPORTS'] ||= 'tmp/reports'
13+
require 'ci/reporter/rake/minitest'
14+
Rake::Task['ci:setup:minitest'].invoke
15+
end
16+
17+
Rake::TestTask.new(:unit) do |test|
18+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
19+
test.libs << 'lib' << 'test'
20+
test.test_files = FileList["test/unit/**/*_test.rb"]
21+
# test.verbose = true
22+
# test.warning = true
23+
end
24+
25+
Rake::TestTask.new(:integration) do |test|
26+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
27+
test.libs << 'lib' << 'test'
28+
test.test_files = FileList["test/integration/**/*_test.rb"]
29+
end
30+
31+
Rake::TestTask.new(:all) do |test|
32+
Rake::Task['test:ci_reporter'].invoke if ENV['CI']
33+
test.libs << 'lib' << 'test'
34+
test.test_files = FileList["test/unit/**/*_test.rb", "test/integration/**/*_test.rb"]
35+
end
36+
end
37+
38+
# ----- Documentation tasks ---------------------------------------------------
39+
40+
require 'yard'
41+
YARD::Rake::YardocTask.new(:doc) do |t|
42+
t.options = %w| --embed-mixins --markup=markdown |
43+
end
44+
45+
# ----- Code analysis tasks ---------------------------------------------------
46+
47+
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
48+
require 'cane/rake_task'
49+
Cane::RakeTask.new(:quality) do |cane|
50+
cane.abc_max = 15
51+
cane.no_style = true
52+
end
53+
end

0 commit comments

Comments
 (0)
Please sign in to comment.