-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
52 lines (47 loc) · 1.12 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
require 'rubygems'
require 'rake'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
require 'gemspec'
desc "Generate gemspec"
task :gemspec do
File.open("#{Dir.pwd}/#{GEM_NAME}.gemspec", 'w') do |f|
f.write(GEM_SPEC.to_ruby)
end
end
desc "Install gem"
task :install do
Rake::Task['gem'].invoke
`sudo gem uninstall #{GEM_NAME} -x`
`sudo gem install pkg/#{GEM_NAME}*.gem`
`rm -Rf pkg`
end
desc "Package gem"
Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
pkg.gem_spec = GEM_SPEC
end
desc "Rename project"
task :rename do
name = ENV['NAME'] || File.basename(Dir.pwd)
begin
dir = Dir['**/gem_template*']
from = dir.pop
if from
rb = from.include?('.rb')
to = File.dirname(from) + "/#{name}#{'.rb' if rb}"
FileUtils.mv(from, to)
end
end while dir.length > 0
Dir["**/*"].each do |path|
next if path.include?('Rakefile')
if File.file?(path)
`sed -i "" 's/gem_template/#{name}/g' #{path}`
end
end
end
desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.rcov = true
t.spec_opts = ["--format", "specdoc", "--colour"]
t.spec_files = FileList["spec/**/*_spec.rb"]
end