forked from red-data-tools/red_amber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
72 lines (56 loc) · 1.59 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
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rake/clean'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/test_*.rb']
t.warning = false
end
require 'rubocop/rake_task'
RuboCop::RakeTask.new
task default: %i[test rubocop]
def install_gems_for_examples
sh 'cd bin; bundle install; cd -'
end
# Example
desc 'Start example environment'
task :example do
install_gems_for_examples
sh 'bundle exec --gemfile=bin/Gemfile bin/example'
end
# Quarto
namespace :quarto do
qmd_dir = 'doc/qmd'
notebook_dir = 'doc/notebook'
directory notebook_dir
qmd_files = FileList["#{qmd_dir}/*.qmd"]
qmd_files.exclude('~*.qmd')
notebooks = qmd_files.pathmap('%{qmd,notebook}p').ext('.ipynb')
qmd_files.zip(notebooks).each do |qmd, notebook|
file notebook => notebook_dir
file notebook => qmd do
sh "quarto convert #{qmd} -o #{notebook}"
end
end
desc 'Convert qmd to ipynb files'
task convert: notebooks
file notebooks => notebook_dir
desc 'test to execute notebooks'
task test: notebooks do
install_gems_for_examples
notebooks.each do |notebook|
quarto_options = '--execute-daemon-restart --execute'
sh "bundle exec --gemfile=bin/Gemfile quarto render #{notebook} #{quarto_options}"
end
end
end
desc 'Start jupyter lab'
task jupyter: 'quarto:convert' do
install_gems_for_examples
jupyter_options =
"--notebook-dir='doc/notebook' --NotebookApp.token=''"
sh "bundle exec --gemfile=bin/Gemfile jupyter lab #{jupyter_options}"
end
CLEAN << 'doc/notebook'