-
Notifications
You must be signed in to change notification settings - Fork 64
/
Rakefile
51 lines (41 loc) · 1.14 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
# frozen_string_literal: true
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: %i[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: %i[rspec rubocop]