-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathRakefile
More file actions
58 lines (48 loc) · 1.83 KB
/
Copy pathRakefile
File metadata and controls
58 lines (48 loc) · 1.83 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
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'bundler/gem_tasks'
require 'rdoc/task'
DOCS_PATH = File.expand_path('docs', __dir__)
desc 'Compile the documentation site into docs/_site'
task :docs do
version = File.read(File.expand_path('lib/torque/postgresql/version.rb', __dir__))[/VERSION = '([^']+)'/, 1]
published = File.read(File.join(DOCS_PATH, '_config.yml'))[/^gem_version:\s*(\S+)/, 1]
unless published == version
abort <<~MESSAGE
docs/_config.yml says gem_version: #{published}, but the gem is #{version}.
The site prints that number in its header, so update _config.yml before building.
MESSAGE
end
env = { 'BUNDLE_GEMFILE' => File.join(DOCS_PATH, 'Gemfile') }
Dir.chdir(DOCS_PATH) { sh(env, 'bundle', 'exec', 'jekyll', 'build') }
end
# A gem cut from master carries freshly compiled docs; every other branch skips
# the cost. Publishing docs/_site stays a manual step.
branch = `git rev-parse --abbrev-ref HEAD 2>/dev/null`.strip
Rake::Task[:build].enhance([:docs]) if branch == 'master'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Torque::Postgresql'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
desc 'Initialize the local environment'
task :environment do |t|
lib = File.expand_path('../lib', __FILE__)
spec = File.expand_path('../spec', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
$LOAD_PATH.unshift(spec) unless $LOAD_PATH.include?(spec)
end
desc 'Prints a schema dump of the test database'
task dump: :environment do |t|
require 'byebug'
require 'spec_helper'
ActiveRecord::SchemaDumper.dump
end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec