-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
70 lines (58 loc) · 1.57 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
# frozen_string_literal: true
require "bundler"
require "rake/clean"
require "rubygems/package_task"
GEMDIRS = Dir.glob("*/*.gemspec").map { |f| File.dirname(f) }
rcee_spec = Bundler.load_gemspec("rcee.gemspec")
Gem::PackageTask.new(rcee_spec).define
def update_version_string(filepath, version)
updated_file = File.read(filepath).gsub(/(\s*)VERSION\s*=\s*.*/, %(\\1VERSION = "#{version}"))
File.open(filepath, "w") { |f| f.write(updated_file) }
end
def in_each_gemdir(&block)
GEMDIRS.each do |gemdir|
Dir.chdir(gemdir) do
puts "=== #{gemdir} ==="
block.call(gemdir)
end
end
end
namespace "version" do
desc "update the version constant of all the gems to match rcee.gemspec"
task "set" do
version = rcee_spec.version
in_each_gemdir do |gemdir|
version_path = Dir.glob("lib/**/version.rb").first
update_version_string(version_path, version)
puts "updated #{File.join(gemdir, version_path)} to #{version}"
end
end
end
desc "create all the gems"
task "package" do
rm_rf("gems") && mkdir("gems")
in_each_gemdir do
sh("bundle")
sh("bundle exec rake clean")
sh("bundle exec rake package")
cp(Dir.glob("pkg/*.gem"), "../gems")
end
cp(Dir.glob("pkg/*.gem"), "gems")
end
desc "test all the gems"
task "test" do
in_each_gemdir do
sh("bundle") and sh("bundle exec rake compile test")
end
end
task "clean" do
in_each_gemdir do
sh("bundle") and sh("bundle exec rake clean")
end
end
task "clobber" do
in_each_gemdir do
sh("bundle") and sh("bundle exec rake clean clobber")
end
end
CLEAN.add("pkg")