chordpro 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chordpro/html.rb +3 -1
- data/lib/chordpro/transform.rb +8 -1
- data/lib/chordpro/version.rb +1 -1
- data/spec/chordpro/html_spec.rb +3 -0
- data/spec/chordpro/song_spec.rb +6 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63af32128eade913aee185dd458d7db4921e40a9478c14f601f0afbe40c9369f
|
4
|
+
data.tar.gz: f54510fd08ba6ee3c58a2ab1e64bf23904170b75e12f53e76c3ed18dabeb8ee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6355b5df98865b8679b243bee79ec8338f33d9a7654420d9720f15f6b159bc953998462538202a2f2bb6981eb3388bb3d3ce3320479688a2b201ca9b2aca879e
|
7
|
+
data.tar.gz: 41d152280dc2abb09ce8f0607b41a983857ed06bcd352f9f955e1b0fa9f1355419a947bbb13892d4217595aed60c153042ded12a8ced4a9b68112bff5fc18f58
|
data/lib/chordpro/html.rb
CHANGED
@@ -18,7 +18,9 @@ module Chordpro
|
|
18
18
|
alias_method :t, :title
|
19
19
|
|
20
20
|
def subtitle(subtitle)
|
21
|
-
|
21
|
+
unless subtitle.match(/^\s*$/)
|
22
|
+
@html.h2(class: "subtitle") { |h2| h2.text! subtitle }
|
23
|
+
end
|
22
24
|
end
|
23
25
|
alias_method :st, :subtitle
|
24
26
|
alias_method :su, :subtitle
|
data/lib/chordpro/transform.rb
CHANGED
@@ -4,8 +4,15 @@ module Chordpro
|
|
4
4
|
directive_name = Directive.find(name) || Directive::Name.new(name.to_s)
|
5
5
|
Chordpro::Directive.new(directive_name, value.to_s)
|
6
6
|
end
|
7
|
+
|
8
|
+
rule(directive: {name: simple(:name), value: []}) do
|
9
|
+
directive_name = Directive.find(name) || Directive::Name.new(name.to_s)
|
10
|
+
Chordpro::Directive.new(directive_name, "")
|
11
|
+
end
|
12
|
+
|
7
13
|
rule(directive: {name: simple(:name)}) do
|
8
|
-
|
14
|
+
directive_name = Directive.find(name) || Directive::Name.new(name.to_s)
|
15
|
+
Chordpro::Directive.new(directive_name)
|
9
16
|
end
|
10
17
|
|
11
18
|
rule(linebreak: simple(:x)) { Chordpro::Linebreak.new }
|
data/lib/chordpro/version.rb
CHANGED
data/spec/chordpro/html_spec.rb
CHANGED
@@ -19,6 +19,9 @@ describe Chordpro::HTML do
|
|
19
19
|
it "renders h2 for #{name}" do
|
20
20
|
expect(html("{#{name}:The Beatles}").to_s).to eq('<h2 class="subtitle">The Beatles</h2>')
|
21
21
|
end
|
22
|
+
it "allows empty #{name}" do
|
23
|
+
expect(html("{#{name}: }").to_s).to eq('')
|
24
|
+
end
|
22
25
|
end
|
23
26
|
|
24
27
|
it "guards against xss in the subtitle" do
|
data/spec/chordpro/song_spec.rb
CHANGED
@@ -19,11 +19,16 @@ module Chordpro
|
|
19
19
|
expect(song.metadata[:artist]).to eq(song.metadata["artist"])
|
20
20
|
end
|
21
21
|
|
22
|
-
it "returns nil for unknown directive" do
|
22
|
+
it "returns nil for unknown directive with value" do
|
23
23
|
song = Chordpro.parse("{foo: bar}")
|
24
24
|
expect(song.metadata["foo"]).to eq(nil)
|
25
25
|
end
|
26
26
|
|
27
|
+
it "returns nil for unknown directive" do
|
28
|
+
song = Chordpro.parse("{foo}")
|
29
|
+
expect(song.metadata["foo"]).to eq(nil)
|
30
|
+
end
|
31
|
+
|
27
32
|
it "returns hash with to_h" do
|
28
33
|
expect(song.metadata.to_h).to eq({
|
29
34
|
"title" => "Africa",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chordpro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Keepers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
155
|
+
rubygems_version: 3.5.9
|
156
156
|
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: A ruby parser for the chordpro song file format.
|