forked from simp/rubygem-simp-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
100 lines (84 loc) · 2.7 KB
/
Rakefile
File metadata and controls
100 lines (84 loc) · 2.7 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
$: << File.expand_path( '../lib/', __FILE__ )
require 'fileutils'
require 'find'
require 'rake/clean'
require 'rspec/core/rake_task'
require 'rubygems'
require 'simp/rake'
Simp::Rake::Pkg.new(File.dirname(__FILE__))
@package='simp-cli'
@rakefile_dir=File.dirname(__FILE__)
CLEAN.include "#{@package}-*.gem"
CLEAN.include 'coverage'
CLEAN.include 'dist'
CLEAN.include 'pkg'
Find.find( @rakefile_dir ) do |path|
if File.directory? path
CLEAN.include path if File.basename(path) == 'tmp'
else
Find.prune
end
end
desc 'Ensure gemspec-safe permissions on all files'
task :chmod do
gemspec = File.expand_path( "#{@package}.gemspec", @rakefile_dir ).strip
spec = Gem::Specification::load( gemspec )
spec.files.each do |file|
FileUtils.chmod 'go=r', file
end
end
desc 'special notes about these rake commands'
task :help do
puts %Q{
== Environment Variables ==
SIMP_RPM_BUILD when set, alters the gem produced by pkg:gem to be RPM-safe.
'pkg:gem' sets this automatically.
== Restrictions ==
- Because the code for this gem uses a global, singleton HighLine object,
the tests for this code cannot be parallelized.
- To prevent actual changes from being made to your system, some of the
'simp config' tests fail if the tests are run as root.
}
end
desc "Run spec tests"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ['--color']
t.pattern = 'spec/**/*_spec.rb'
end
namespace :pkg do
@specfile_template = "rubygem-#{@package}.spec.template"
@specfile = "build/rubygem-#{@package}.spec"
# ----------------------------------------
# DO NOT UNCOMMENT THIS: the spec file requires a lot of tweaking
# ----------------------------------------
# desc "generate RPM spec file for #{@package}"
# task :spec => [:clean, :gem] do
# Dir.glob("pkg/#{@package}*.gem") do |pkg|
# sh %Q{gem2rpm -t "#{@specfile_template}" "#{pkg}" > "#{@specfile}"}
# end
# end
desc "build rubygem package for #{@package}"
task :gem => :chmod do
gem_dirs = [@rakefile_dir]
gem_dirs += Dir.glob('ext/gems/*')
gem_dirs.each do |gem_dir|
Dir.chdir gem_dir do
Dir['*.gemspec'].each do |spec_file|
cmd = %Q{SIMP_RPM_BUILD=1 bundle exec gem build "#{spec_file}" &> /dev/null}
sh cmd
FileUtils.mkdir_p 'dist'
FileUtils.mv Dir.glob('*.gem'), File.join(@rakefile_dir, 'dist')
end
end
end
end
desc "build and install rubygem package for #{@package}"
task :install_gem => [:clean, :gem] do
Dir.chdir @rakefile_dir
Dir.glob("dist/#{@package}*.gem") do |pkg|
sh %Q{bundle exec gem install #{pkg}}
end
end
Rake::Task[:rpm].prerequisites.unshift(:gem)
end
# vim: syntax=ruby