forked from plaid/plaid-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
83 lines (64 loc) · 1.75 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
require 'bundler/gem_tasks'
require 'sdoc'
require 'rdoc/task'
require 'rake/testtask'
require 'dotenv/load'
require 'fileutils'
require 'tmpdir'
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'doc/rdoc'
rdoc.generator = 'sdoc'
rdoc.main = 'README.md'
rdoc.rdoc_files.include('README.md', 'LICENSE.txt', 'lib/**/*.rb')
rdoc.markup = 'tomdoc'
end
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/test*.rb']
t.verbose = true
t.ruby_opts << '-rminitest/pride'
end
desc 'Update the gh-pages branch with doc/rdoc contents'
task :update_gh_pages do
tmpdir = Dir::Tmpname.create('plaid_docs') {}
desc = `git describe`.chomp
sh "git clone --shared . #{tmpdir}"
Dir.chdir(tmpdir) do
sh 'git checkout gh-pages'
FileUtils.rm_rf Dir.glob("#{tmpdir}/*")
end
FileUtils.cp_r Dir.glob('doc/rdoc/*'), tmpdir
Dir.chdir(tmpdir) do
sh 'git add .'
sh 'git add --update .'
sh "git commit --allow-empty -m 'Regenerate docs for #{desc}'"
sh 'git push'
end
FileUtils.rm_rf tmpdir
end
desc 'Generate rdoc and update gh-pages on GitHub'
task update_github_docs: %i[rdoc update_gh_pages] do
sh 'git push origin gh-pages'
end
desc 'Hide real credentials in VCR cassettes'
task :vcr_hide_credentials do
all_creds = %w[PLAID_RUBY_CLIENT_ID PLAID_RUBY_SECRET]
all_creds.each do |cred|
raise "#{cred} is not set" unless ENV[cred]
end
Dir['test/vcr_cassettes/*'].each do |fn|
data = File.read(fn)
data0 = data.clone
all_creds.each do |cred|
data.gsub! ENV[cred], cred
end
next unless data != data0
File.open(fn, 'w') { |f| f.write data }
puts ">> Updated #{fn}"
end
end
task :test_stubbed do
ENV['STUB_API'] ||= '1'
Rake::Task['test'].invoke
end
task default: :test_stubbed