-
Notifications
You must be signed in to change notification settings - Fork 24
/
Rakefile
90 lines (78 loc) · 2.16 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
require File.dirname(__FILE__) + '/lib/also_migrate/gems'
AlsoMigrate::Gems.activate %w(rake rspec)
require 'rake'
require 'spec/rake/spectask'
def gemspec
@gemspec ||= begin
file = File.expand_path('../also_migrate.gemspec', __FILE__)
eval(File.read(file), binding, file)
end
end
if defined?(Spec::Rake::SpecTask)
desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = %w(-fs --color)
t.warning = true
end
task :spec
task :default => :spec
end
desc "Build gem(s)"
task :gem do
old_gemset = ENV['GEMSET']
root = File.expand_path('../', __FILE__)
pkg = "#{root}/pkg"
system "rm -Rf #{pkg}"
AlsoMigrate::Gems.gemset_names.each do |gemset|
ENV['GEMSET'] = gemset.to_s
system "cd #{root} && gem build also_migrate.gemspec"
system "mkdir -p #{pkg} && mv *.gem pkg"
end
ENV['GEMSET'] = old_gemset
end
namespace :gem do
desc "Install gem(s)"
task :install do
Rake::Task['gem'].invoke
Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
system "gem install #{pkg} --no-ri --no-rdoc"
end
end
desc "Push gem(s)"
task :push do
Rake::Task['gem'].invoke
Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
system "gem push #{pkg}"
end
end
end
namespace :gems do
desc "Install gem dependencies (DEV=0 DOCS=0 GEMSPEC=default SUDO=0)"
task :install do
dev = ENV['DEV'] == '1'
docs = ENV['DOCS'] == '1' ? '' : '--no-ri --no-rdoc'
gemset = ENV['GEMSET']
sudo = ENV['SUDO'] == '1' ? 'sudo' : ''
AlsoMigrate::Gems.gemset = gemset if gemset
if dev
gems = AlsoMigrate::Gems.gemspec.development_dependencies
else
gems = AlsoMigrate::Gems.gemspec.dependencies
end
gems.each do |name|
name = name.to_s
version = AlsoMigrate::Gems.versions[name]
if Gem.source_index.find_name(name, version).empty?
version = version ? "-v #{version}" : ''
system "#{sudo} gem install #{name} #{version} #{docs}"
else
puts "already installed: #{name} #{version}"
end
end
end
end
desc "Validate the gemspec"
task :gemspec do
gemspec.validate
end