jekyll-lilypond 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +99 -0
- data/LICENSE +21 -0
- data/README.md +98 -0
- data/files/rite.png +0 -0
- data/jekyll-lilypond.gemspec +23 -0
- data/lib/jekyll-lilypond/file_processor.rb +67 -0
- data/lib/jekyll-lilypond/lilypond_tag.rb +34 -0
- data/lib/jekyll-lilypond/tag.rb +17 -0
- data/lib/jekyll-lilypond/tag_processor.rb +56 -0
- data/lib/jekyll-lilypond/templates/basic.ly +45 -0
- data/lib/jekyll-lilypond/templates/empty.ly +1 -0
- data/lib/jekyll-lilypond/templates/figure.html +25 -0
- data/lib/jekyll-lilypond/templates/img.html +4 -0
- data/lib/jekyll-lilypond/templates/raw.html +1 -0
- data/lib/jekyll-lilypond/templates/raw.ly +1 -0
- data/lib/jekyll-lilypond/templates/showsource.html +36 -0
- data/lib/jekyll-lilypond/templates.rb +60 -0
- data/lib/jekyll-lilypond/version.rb +5 -0
- data/lib/jekyll-lilypond.rb +11 -0
- data/spec/file_processor_spec.rb +167 -0
- data/spec/fixtures/.gitignore +5 -0
- data/spec/fixtures/404.html +25 -0
- data/spec/fixtures/Gemfile +31 -0
- data/spec/fixtures/_config.yml +56 -0
- data/spec/fixtures/_layouts/basic_html.html +1 -0
- data/spec/fixtures/_layouts/vacuous_html.html +1 -0
- data/spec/fixtures/_layouts/vacuous_ly.ly +1 -0
- data/spec/fixtures/_layouts/variables_html.html +1 -0
- data/spec/fixtures/_layouts/variables_ly.ly +1 -0
- data/spec/fixtures/_posts/2021-01-16-welcome-to-jekyll.markdown +29 -0
- data/spec/fixtures/about.markdown +18 -0
- data/spec/fixtures/index.markdown +6 -0
- data/spec/fixtures/page.md +8 -0
- data/spec/integration_spec.rb +115 -0
- data/spec/spec_helper.rb +88 -0
- data/spec/tag_processor_spec.rb +135 -0
- data/spec/tag_spec.rb +51 -0
- data/spec/templates_spec.rb +175 -0
- metadata +118 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
require "jekyll-lilypond"
|
2
|
+
require "spec_helper"
|
3
|
+
require "tmpdir"
|
4
|
+
include Liquid
|
5
|
+
|
6
|
+
RSpec.shared_context 'temp_dir' do
|
7
|
+
around do |example|
|
8
|
+
Dir.mktmpdir do |dir|
|
9
|
+
@temp_dir = dir
|
10
|
+
example.run
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :temp_dir
|
15
|
+
|
16
|
+
let(:source) { '\version "2.14.1" { c d e f g a b c }' }
|
17
|
+
let(:hash) { "99cef9f0865c2c21ba7b5b00d1092f61" }
|
18
|
+
let(:sourcepath) { "#{@temp_dir}/99cef9f0865c2c21ba7b5b00d1092f61.ly" }
|
19
|
+
let(:svgpath) { "#{@temp_dir}/99cef9f0865c2c21ba7b5b00d1092f61.svg" }
|
20
|
+
let(:barepath) { "#{@temp_dir}/99cef9f0865c2c21ba7b5b00d1092f61" }
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.describe(Jekyll::Lilypond::FileProcessor) do
|
24
|
+
include_context 'temp_dir'
|
25
|
+
|
26
|
+
context "initialization" do
|
27
|
+
it "works if the working dir exists" do
|
28
|
+
expect { described_class.new(@temp_dir, hash, source) }.not_to raise_error
|
29
|
+
end
|
30
|
+
it "works even if the working dir is in a deeply nested path" do
|
31
|
+
path = "#{@temp_dir}/foo/bar/baz/whatever"
|
32
|
+
FileUtils.mkdir_p(path)
|
33
|
+
expect { described_class.new(path, hash, source) }.not_to raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "writing" do
|
38
|
+
it "creates a file at the expected location" do
|
39
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
40
|
+
file_processor.write
|
41
|
+
expect(File.file?(sourcepath)).to eq(true)
|
42
|
+
end
|
43
|
+
it "populates that file with the right source" do
|
44
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
45
|
+
file_processor.write
|
46
|
+
expect(File.open(sourcepath).read).to eq(source)
|
47
|
+
end
|
48
|
+
it "doesn't overwrite an existing source file with the same name" do
|
49
|
+
File.open(sourcepath, "w") do |f|
|
50
|
+
f.write("This should not be overwritten")
|
51
|
+
end
|
52
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
53
|
+
file_processor.write
|
54
|
+
expect(File.open(sourcepath).read).to eq("This should not be overwritten")
|
55
|
+
end
|
56
|
+
it "creates the working directory if it does not exist" do
|
57
|
+
path = "#{@temp_dir}/foo/bar/baz/whatever"
|
58
|
+
expect {
|
59
|
+
fp = described_class.new(path, hash, source)
|
60
|
+
fp.write
|
61
|
+
}.not_to raise_error
|
62
|
+
expect(File.exists?(path)).to eq(true)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "compiling" do
|
67
|
+
it "results in an svg file" do
|
68
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
69
|
+
file_processor.write
|
70
|
+
file_processor.compile
|
71
|
+
expect(File.exist?(svgpath)).to eq(true)
|
72
|
+
end
|
73
|
+
it "doesn't call lilypond if the target svg exists" do
|
74
|
+
File.open(svgpath, "w") do |f|
|
75
|
+
f.write("This should not be overwritten")
|
76
|
+
end
|
77
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
78
|
+
file_processor.write
|
79
|
+
file_processor.compile
|
80
|
+
expect(File.open(svgpath).read).to eq("This should not be overwritten")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
context "trimming" do
|
84
|
+
it "results in an svg file" do
|
85
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
86
|
+
file_processor.write
|
87
|
+
file_processor.compile
|
88
|
+
file_processor.trim_svg
|
89
|
+
expect(File.exist?(svgpath)).to eq(true)
|
90
|
+
end
|
91
|
+
it "raises an error if the target svg does not exist" do
|
92
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
93
|
+
expect { file_processor.trim_svg }.to raise_error(RuntimeError)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
context "integration with lilypond" do
|
97
|
+
it "puts output in the target directory even if it's deeply nested" do
|
98
|
+
path = "#{@temp_dir}/foo/bar/baz/whatever"
|
99
|
+
FileUtils.mkdir_p(path)
|
100
|
+
file_processor = described_class.new(path, hash, source)
|
101
|
+
file_processor.write
|
102
|
+
file_processor.compile
|
103
|
+
expect(File.exist?("#{path}/#{hash}.svg")).to eq(true)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
RSpec.shared_context 'temp_dir_with_midi' do
|
109
|
+
around do |example|
|
110
|
+
Dir.mktmpdir do |dir|
|
111
|
+
@temp_dir = dir
|
112
|
+
example.run
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
attr_reader :temp_dir
|
117
|
+
|
118
|
+
let(:source) { '\version "2.14.1" \score { { c d e f g a b c } \midi { } }' }
|
119
|
+
let(:hash) { "f95206924ddb60916690c047a2345b87" }
|
120
|
+
let(:sourcepath) { "#{@temp_dir}/f95206924ddb60916690c047a2345b87.ly" }
|
121
|
+
let(:svgpath) { "#{@temp_dir}/f95206924ddb60916690c047a2345b87.svg" }
|
122
|
+
let(:mp3path) { "#{@temp_dir}/f95206924ddb60916690c047a2345b87.mp3" }
|
123
|
+
let(:barepath) { "#{@temp_dir}/f95206924ddb60916690c047a2345b87" }
|
124
|
+
end
|
125
|
+
|
126
|
+
RSpec.describe(Jekyll::Lilypond::FileProcessor) do
|
127
|
+
include_context 'temp_dir_with_midi'
|
128
|
+
|
129
|
+
context "making mp3" do
|
130
|
+
it "results in an mp3 file" do
|
131
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
132
|
+
file_processor.write
|
133
|
+
file_processor.compile
|
134
|
+
file_processor.make_mp3
|
135
|
+
expect(File.exist?(mp3path)).to eq(true)
|
136
|
+
end
|
137
|
+
it "doesn't touch a target mp3 that already exists" do
|
138
|
+
File.open(mp3path, "w") do |f|
|
139
|
+
f.write("This should not be overwritten")
|
140
|
+
end
|
141
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
142
|
+
file_processor.write
|
143
|
+
file_processor.compile
|
144
|
+
file_processor.make_mp3
|
145
|
+
expect(File.open(mp3path).read).to eq("This should not be overwritten")
|
146
|
+
end
|
147
|
+
it "errors sensibly if its midi dependency doesn't exist" do
|
148
|
+
file_processor = described_class.new(@temp_dir, hash, source)
|
149
|
+
expect { file_processor.make_mp3 }.to raise_error(RuntimeError)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context "integration with lilypond" do
|
154
|
+
it "puts output in the target directory even if it's deeply nested" do
|
155
|
+
path = "#{@temp_dir}/foo/bar/baz/whatever"
|
156
|
+
FileUtils.mkdir_p(path)
|
157
|
+
file_processor = described_class.new(path, hash, source)
|
158
|
+
file_processor.write
|
159
|
+
file_processor.compile
|
160
|
+
expect(File.exist?("#{path}/#{hash}.midi")).to eq(true)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
#To do: Error handling
|
164
|
+
#To do: Flexible lilypond invocation
|
165
|
+
#To do: Do lilypond's products end up in the right place?
|
166
|
+
end
|
167
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
permalink: /404.html
|
3
|
+
layout: default
|
4
|
+
---
|
5
|
+
|
6
|
+
<style type="text/css" media="screen">
|
7
|
+
.container {
|
8
|
+
margin: 10px auto;
|
9
|
+
max-width: 600px;
|
10
|
+
text-align: center;
|
11
|
+
}
|
12
|
+
h1 {
|
13
|
+
margin: 30px 0;
|
14
|
+
font-size: 4em;
|
15
|
+
line-height: 1;
|
16
|
+
letter-spacing: -1px;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
|
20
|
+
<div class="container">
|
21
|
+
<h1>404</h1>
|
22
|
+
|
23
|
+
<p><strong>Page not found :(</strong></p>
|
24
|
+
<p>The requested page could not be found.</p>
|
25
|
+
</div>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
# Hello! This is where you manage which Jekyll version is used to run.
|
3
|
+
# When you want to use a different version, change it below, save the
|
4
|
+
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
5
|
+
#
|
6
|
+
# bundle exec jekyll serve
|
7
|
+
#
|
8
|
+
# This will help ensure the proper Jekyll version is running.
|
9
|
+
# Happy Jekylling!
|
10
|
+
gem "jekyll", "~> 4.2.0"
|
11
|
+
# This is the default theme for new Jekyll sites. You may change this to anything you like.
|
12
|
+
gem "minima", "~> 2.5"
|
13
|
+
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
14
|
+
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
15
|
+
# gem "github-pages", group: :jekyll_plugins
|
16
|
+
# If you have any plugins, put them here!
|
17
|
+
group :jekyll_plugins do
|
18
|
+
gem "jekyll-feed", "~> 0.12"
|
19
|
+
gem "jekyll-lilypond", path: "../.."
|
20
|
+
end
|
21
|
+
|
22
|
+
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
|
23
|
+
# and associated library.
|
24
|
+
platforms :mingw, :x64_mingw, :mswin, :jruby do
|
25
|
+
gem "tzinfo", "~> 1.2"
|
26
|
+
gem "tzinfo-data"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Performance-booster for watching directories on Windows
|
30
|
+
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
|
31
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Welcome to Jekyll!
|
2
|
+
#
|
3
|
+
# This config file is meant for settings that affect your whole blog, values
|
4
|
+
# which you are expected to set up once and rarely edit after that. If you find
|
5
|
+
# yourself editing this file very often, consider using Jekyll's data files
|
6
|
+
# feature for the data you need to update frequently.
|
7
|
+
#
|
8
|
+
# For technical reasons, this file is *NOT* reloaded automatically when you use
|
9
|
+
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
|
10
|
+
#
|
11
|
+
# If you need help with YAML syntax, here are some quick references for you:
|
12
|
+
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
|
13
|
+
# https://learnxinyminutes.com/docs/yaml/
|
14
|
+
#
|
15
|
+
# Site settings
|
16
|
+
# These are used to personalize your new site. If you look in the HTML files,
|
17
|
+
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
|
18
|
+
# You can create any custom variable you would like, and they will be accessible
|
19
|
+
# in the templates via {{ site.myvariable }}.
|
20
|
+
|
21
|
+
title: Your awesome title
|
22
|
+
email: your-email@example.com
|
23
|
+
description: >- # this means to ignore newlines until "baseurl:"
|
24
|
+
Write an awesome description for your new site here. You can edit this
|
25
|
+
line in _config.yml. It will appear in your document head meta (for
|
26
|
+
Google search results) and in your feed.xml site description.
|
27
|
+
baseurl: "" # the subpath of your site, e.g. /blog
|
28
|
+
url: "" # the base hostname & protocol for your site, e.g. http://example.com
|
29
|
+
twitter_username: jekyllrb
|
30
|
+
github_username: jekyll
|
31
|
+
|
32
|
+
# Build settings
|
33
|
+
theme: minima
|
34
|
+
plugins:
|
35
|
+
- jekyll-feed
|
36
|
+
- jekyll-lilypond
|
37
|
+
|
38
|
+
# Exclude from processing.
|
39
|
+
# The following items will not be processed, by default.
|
40
|
+
# Any item listed under the `exclude:` key here will be automatically added to
|
41
|
+
# the internal "default list".
|
42
|
+
#
|
43
|
+
# Excluded items can be processed by explicitly listing the directories or
|
44
|
+
# their entries' file path in the `include:` list.
|
45
|
+
#
|
46
|
+
# exclude:
|
47
|
+
# - .sass-cache/
|
48
|
+
# - .jekyll-cache/
|
49
|
+
# - gemfiles/
|
50
|
+
# - Gemfile
|
51
|
+
# - Gemfile.lock
|
52
|
+
# - node_modules/
|
53
|
+
# - vendor/bundle/
|
54
|
+
# - vendor/cache/
|
55
|
+
# - vendor/gems/
|
56
|
+
# - vendor/ruby/
|
@@ -0,0 +1 @@
|
|
1
|
+
<img src='{{ filename }}.png'>
|
@@ -0,0 +1 @@
|
|
1
|
+
{{- content -}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{ {{ content }} }
|
@@ -0,0 +1 @@
|
|
1
|
+
{{- a }} {{ content }} {{ b -}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{{- a }} {{ content }} {{ b -}}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
layout: post
|
3
|
+
title: "Welcome to Jekyll!"
|
4
|
+
date: 2021-01-16 16:01:22 -0500
|
5
|
+
categories: jekyll update
|
6
|
+
---
|
7
|
+
You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.
|
8
|
+
|
9
|
+
Jekyll requires blog post files to be named according to the following format:
|
10
|
+
|
11
|
+
`YEAR-MONTH-DAY-title.MARKUP`
|
12
|
+
|
13
|
+
Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit numbers, and `MARKUP` is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.
|
14
|
+
|
15
|
+
Jekyll also offers powerful support for code snippets:
|
16
|
+
|
17
|
+
{% highlight ruby %}
|
18
|
+
def print_hi(name)
|
19
|
+
puts "Hi, #{name}"
|
20
|
+
end
|
21
|
+
print_hi('Tom')
|
22
|
+
#=> prints 'Hi, Tom' to STDOUT.
|
23
|
+
{% endhighlight %}
|
24
|
+
|
25
|
+
Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk].
|
26
|
+
|
27
|
+
[jekyll-docs]: https://jekyllrb.com/docs/home
|
28
|
+
[jekyll-gh]: https://github.com/jekyll/jekyll
|
29
|
+
[jekyll-talk]: https://talk.jekyllrb.com/
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: About
|
4
|
+
permalink: /about/
|
5
|
+
---
|
6
|
+
|
7
|
+
This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)
|
8
|
+
|
9
|
+
You can find the source code for Minima at GitHub:
|
10
|
+
[jekyll][jekyll-organization] /
|
11
|
+
[minima](https://github.com/jekyll/minima)
|
12
|
+
|
13
|
+
You can find the source code for Jekyll at GitHub:
|
14
|
+
[jekyll][jekyll-organization] /
|
15
|
+
[jekyll](https://github.com/jekyll/jekyll)
|
16
|
+
|
17
|
+
|
18
|
+
[jekyll-organization]: https://github.com/jekyll
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
require "jekyll-lilypond"
|
3
|
+
require "spec_helper"
|
4
|
+
require "tmpdir"
|
5
|
+
|
6
|
+
RSpec.describe(Jekyll::Lilypond) do
|
7
|
+
around(:each) do |example|
|
8
|
+
Dir.mktmpdir do |dir|
|
9
|
+
@temp_dir = dir
|
10
|
+
@test_page = "#{@temp_dir}/test_page.md"
|
11
|
+
@dest_page = "#{dest_dir}/test_page.html"
|
12
|
+
FileUtils.cp_r("spec/fixtures/.", @temp_dir)
|
13
|
+
File.open(@test_page, "w") { |f| f.write(test_page_contents) }
|
14
|
+
example.run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:overrides) { {} }
|
19
|
+
let(:config) do
|
20
|
+
Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
|
21
|
+
"full_rebuild" => true,
|
22
|
+
"source" => @temp_dir,
|
23
|
+
"destination" => dest_dir,
|
24
|
+
"show_drafts" => false,
|
25
|
+
"url" => "http://example.org",
|
26
|
+
"name" => "My awesome site",
|
27
|
+
"author" => {
|
28
|
+
"name" => "Dr. Jekyll",
|
29
|
+
},
|
30
|
+
"collections" => {
|
31
|
+
"my_collection" => { "output" => true },
|
32
|
+
"other_things" => { "output" => false },
|
33
|
+
},
|
34
|
+
}, overrides))
|
35
|
+
end
|
36
|
+
let(:site) { Jekyll::Site.new(config) }
|
37
|
+
let(:context) { make_context(:site => site) }
|
38
|
+
|
39
|
+
|
40
|
+
context "somethingorother" do
|
41
|
+
let(:test_page_contents) {
|
42
|
+
<<-MD
|
43
|
+
---
|
44
|
+
layout: home
|
45
|
+
---
|
46
|
+
foobledooble
|
47
|
+
MD
|
48
|
+
}
|
49
|
+
it "works" do
|
50
|
+
expect(File).to exist(@test_page)
|
51
|
+
site.process
|
52
|
+
expect(File.read(@dest_page)).to include("foobledooble")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "used with the vacuous template" do
|
57
|
+
let(:test_page_contents) {
|
58
|
+
<<-MD
|
59
|
+
---
|
60
|
+
layout: vacuous_html
|
61
|
+
---
|
62
|
+
Test test test
|
63
|
+
{% lilypond source_template_code: "{ {{ content }} }",
|
64
|
+
include_template_code: '<img src="{{ filename }}.svg" />' %}
|
65
|
+
c d e f g a b c
|
66
|
+
{% endlilypond %}
|
67
|
+
Test test test
|
68
|
+
MD
|
69
|
+
}
|
70
|
+
before(:each) do site.process end
|
71
|
+
it "doesn't just emit the tag contents" do
|
72
|
+
expect(File.read(@dest_page)).not_to include("c d e f g a b c")
|
73
|
+
end
|
74
|
+
it "produces a SVG in the source tree" do
|
75
|
+
expect(File).to exist("#{@temp_dir}/lilypond_files/a5b1d61f70473f0247629a66cfc50e52.svg")
|
76
|
+
end
|
77
|
+
it "produces a SVG in the destination tree" do
|
78
|
+
expect(File).to exist("#{dest_dir}/lilypond_files/a5b1d61f70473f0247629a66cfc50e52.svg")
|
79
|
+
end
|
80
|
+
it "produces an image element in the rendered page" do
|
81
|
+
expect(File.read(@dest_page)).to include('<img src="a5b1d61f70473f0247629a66cfc50e52.svg" />')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "used with the vacuous template" do
|
86
|
+
let(:test_page_contents) {
|
87
|
+
<<-MD
|
88
|
+
---
|
89
|
+
layout: vacuous_html
|
90
|
+
---
|
91
|
+
Test test test
|
92
|
+
{% lilypond source_template: "vacuous_ly",
|
93
|
+
include_template_code: '<img src="{{ filename }}.svg" />' %}
|
94
|
+
c d e f g a b c
|
95
|
+
{% endlilypond %}
|
96
|
+
Test test test
|
97
|
+
MD
|
98
|
+
}
|
99
|
+
before(:each) do site.process end
|
100
|
+
it "doesn't just emit the tag contents" do
|
101
|
+
expect(File.read(@dest_page)).not_to include("c d e f g a b c")
|
102
|
+
end
|
103
|
+
it "produces a SVG in the source tree" do
|
104
|
+
expect(File).to exist("#{@temp_dir}/lilypond_files/a5b1d61f70473f0247629a66cfc50e52.svg")
|
105
|
+
end
|
106
|
+
it "produces a SVG in the destination tree" do
|
107
|
+
expect(File).to exist("#{dest_dir}/lilypond_files/a5b1d61f70473f0247629a66cfc50e52.svg")
|
108
|
+
end
|
109
|
+
it "produces an image element in the rendered page" do
|
110
|
+
expect(File.read(@dest_page)).to include('<img src="a5b1d61f70473f0247629a66cfc50e52.svg" />')
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require "jekyll"
|
5
|
+
require "jekyll-lilypond"
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
|
9
|
+
config.expect_with :rspec do |expectations|
|
10
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
11
|
+
end
|
12
|
+
|
13
|
+
config.mock_with :rspec do |mocks|
|
14
|
+
mocks.verify_partial_doubles = true
|
15
|
+
end
|
16
|
+
|
17
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
18
|
+
|
19
|
+
#https://ayastreb.me/writing-a-jekyll-plugin/ from here on down
|
20
|
+
SOURCE_DIR = File.expand_path("../fixtures", __FILE__)
|
21
|
+
DEST_DIR = File.expand_path("../dest", __FILE__)
|
22
|
+
|
23
|
+
def source_dir(*files)
|
24
|
+
File.join(SOURCE_DIR, *files)
|
25
|
+
end
|
26
|
+
|
27
|
+
def dest_dir(*files)
|
28
|
+
File.join(DEST_DIR, *files)
|
29
|
+
end
|
30
|
+
|
31
|
+
def make_context(registers = {})
|
32
|
+
Liquid::Context.new({}, {}, { :site => site }.merge(registers))
|
33
|
+
end
|
34
|
+
|
35
|
+
# The settings below are suggested to provide a good initial experience
|
36
|
+
# with RSpec, but feel free to customize to your heart's content.
|
37
|
+
=begin
|
38
|
+
# This allows you to limit a spec run to individual examples or groups
|
39
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
40
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
41
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
42
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
43
|
+
config.filter_run_when_matching :focus
|
44
|
+
|
45
|
+
# Allows RSpec to persist some state between runs in order to support
|
46
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
47
|
+
# you configure your source control system to ignore this file.
|
48
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
49
|
+
|
50
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
51
|
+
# recommended. For more details, see:
|
52
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
53
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
54
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
55
|
+
config.disable_monkey_patching!
|
56
|
+
|
57
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
58
|
+
# be too noisy due to issues in dependencies.
|
59
|
+
config.warnings = true
|
60
|
+
|
61
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
62
|
+
# file, and it's useful to allow more verbose output when running an
|
63
|
+
# individual spec file.
|
64
|
+
if config.files_to_run.one?
|
65
|
+
# Use the documentation formatter for detailed output,
|
66
|
+
# unless a formatter has already been configured
|
67
|
+
# (e.g. via a command-line flag).
|
68
|
+
config.default_formatter = "doc"
|
69
|
+
end
|
70
|
+
|
71
|
+
# Print the 10 slowest examples and example groups at the
|
72
|
+
# end of the spec run, to help surface which specs are running
|
73
|
+
# particularly slow.
|
74
|
+
config.profile_examples = 10
|
75
|
+
|
76
|
+
# Run specs in random order to surface order dependencies. If you find an
|
77
|
+
# order dependency and want to debug it, you can fix the order by providing
|
78
|
+
# the seed, which is printed after each run.
|
79
|
+
# --seed 1234
|
80
|
+
config.order = :random
|
81
|
+
|
82
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
83
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
84
|
+
# test failures related to randomization by passing the same `--seed` value
|
85
|
+
# as the one that triggered the failure.
|
86
|
+
Kernel.srand config.seed
|
87
|
+
=end
|
88
|
+
end
|