forked from JackDanger/permanent_records
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
49 lines (40 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
require 'bundler'
require 'yaml'
require 'English'
Bundler::GemHelper.install_tasks
version = File.read('./VERSION').chomp
CONFIG = YAML.load_file(
File.expand_path('spec/support/database.yml', File.dirname(__FILE__))
)
def test_database_exists?
system "psql -l | grep -q #{CONFIG['test'][:database]}"
$CHILD_STATUS.success?
end
def create_test_database
system "createdb #{CONFIG['test'][:database]}"
end
namespace :db do
task :create do
create_test_database unless test_database_exists?
end
end
require 'rubocop/rake_task'
RuboCop::RakeTask.new do |t|
t.options = ['-d']
end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:rspec) do |t|
t.rspec_opts = '-f d -c'
end
task :pandoc do
system('pandoc -s -r markdown -w rst README.md -o README.rst')
end
task publish: [:pandoc, :rubocop, :rspec] do
# Ensure the gem builds
system('gem build permanent_records.gemspec') &&
# And we didn't leave anything (aside from the gem) uncommitted
!system('git status -s | egrep -v .') &&
system('git push') &&
system("gem push permanent_records-#{version}.gem")
end
task default: [:rspec, :rubocop]