forked from fog/fog-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
127 lines (105 loc) · 2.77 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
require 'bundler/setup'
require 'rake/testtask'
require 'rubygems'
require 'rubygems/package_task'
require 'yard'
require File.dirname(__FILE__) + '/lib/fog/libvirt'
#############################################################################
#
# Helper functions
#
#############################################################################
def name
@name ||= Dir['*.gemspec'].first.split('.').first
end
def version
Fog::Libvirt::VERSION
end
def gemspec_file
"#{name}.gemspec"
end
def gem_file
"#{name}-#{version}.gem"
end
#############################################################################
#
# Standard tasks
#
#############################################################################
GEM_NAME = "#{name}"
task :default => [:test, :minitest]
Rake::TestTask.new(:minitest) do |t|
t.libs << '.'
t.libs << 'lib'
t.libs << 'minitests'
t.test_files = Dir.glob('minitests/**/*_test.rb')
t.verbose = true
end
desc 'Run tests'
task :test do
mock = ENV['FOG_MOCK'] || 'true'
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests")
end
desc 'Run mocked tests'
task :mock do
sh("export FOG_MOCK=true && bundle exec shindont tests")
end
desc 'Run live tests'
task :live do
sh("export FOG_MOCK=false && bundle exec shindont tests")
end
desc "Open an irb session preloaded with this library"
task :console do
sh "irb -rubygems -r ./lib/fog/libvirt.rb"
end
#############################################################################
#
# Packaging tasks
#
#############################################################################
task :release => ["release:prepare", "release:publish"]
namespace :release do
task :preflight do
unless `git branch` =~ /^\* master$/
puts "You must be on the master branch to release!"
exit!
end
if `git tag` =~ /^\* v#{version}$/
puts "Tag v#{version} already exists!"
exit!
end
end
task :prepare => :preflight do
Rake::Task[:build].invoke
sh "gem install pkg/#{name}-#{version}.gem"
Rake::Task[:git_mark_release].invoke
end
task :publish do
Rake::Task[:git_push_release].invoke
Rake::Task[:gem_push].invoke
end
end
task :git_mark_release do
sh "git commit --allow-empty -a -m 'Release #{version}'"
sh "git tag v#{version}"
end
task :git_push_release do
sh "git push origin master"
sh "git push origin v#{version}"
end
task :gem_push do
sh "gem push pkg/#{name}-#{version}.gem"
end
desc "Build #{name}-#{version}.gem"
task :build do
sh "mkdir -p pkg"
sh "gem build #{gemspec_file}"
sh "mv #{gem_file} pkg"
end
task :gem => :build
# Include Yard tasks for rake yard
YARDOC_LOCATION = "doc"
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb', "README"]
t.options = ["--output-dir", YARDOC_LOCATION, "--title", "#{name} #{version}"]
end