LilyPond-Ruby 0.1.5 → 0.1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lilypond/builder.rb +2 -2
- data/lib/lilypond/config.rb +23 -0
- data/lib/lilypond-ruby.rb +14 -7
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0753909e55ec718709787b480e31ac1125cf69355e4993b278ad9ef2c7d37b78'
|
4
|
+
data.tar.gz: 47a9251087eca6fa7730ab28f04e7d383411ca2a7ddba159034ffebf351bea71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc1930db2fd8263983327931b9ef14856aec59631c92a430f75fda1d1cbca99d0f42aaf1772b7806ab6211d3b65e7643a320283a6e82fb874b10fb5c14e58e0b
|
7
|
+
data.tar.gz: 9c8663c4c47e2321678fb975d2e214f3fdacf5d76bfe981c376d062ac55179d40846f285fc0d3fd0d8594cfc42e43d3965d125a4b54b0f48b8dec977fa8f5d07
|
data/lib/lilypond/builder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative "../lilypond-ruby.rb"
|
2
2
|
|
3
|
-
# The LilyPond
|
4
|
-
|
3
|
+
# The LilyPond module provides an interface for generating LilyPond notation.
|
4
|
+
module LilyPond
|
5
5
|
# The Builder class is responsible for building LilyPond notation.
|
6
6
|
class Builder
|
7
7
|
# Creates a new LilyPond Builder object.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "../lilypond-ruby.rb"
|
2
|
+
|
3
|
+
module LilyPond
|
4
|
+
class << self
|
5
|
+
attr_accessor :configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.configuration
|
9
|
+
@configuration ||= Configuration.new
|
10
|
+
yield(@configuration) if block_given?
|
11
|
+
@configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
class Configuration
|
15
|
+
attr_accessor :default_output, :destination_directory, :lilypond_path
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@default_output = :pdf
|
19
|
+
@destination_directory = "."
|
20
|
+
@lilypond_path = File.expand_path("../../../lilypond-2.24.1/bin/lilypond", __FILE__)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/lilypond-ruby.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
require "open3"
|
2
2
|
require "lilypond/builder"
|
3
|
+
require "lilypond/config"
|
3
4
|
require "guile"
|
4
5
|
|
5
|
-
|
6
|
-
LILYPOND_PATH = File.expand_path("../../lilypond-2.24.1/bin/lilypond", __FILE__)
|
6
|
+
module LilyPond
|
7
7
|
class << self
|
8
|
-
|
9
8
|
def version
|
10
|
-
output, error, status = Open3.capture3(
|
9
|
+
output, error, status = Open3.capture3(path, "--version")
|
11
10
|
if status.success?
|
12
11
|
puts output
|
13
12
|
else
|
@@ -16,7 +15,7 @@ class LilyPond
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def version_number
|
19
|
-
output, error, status = Open3.capture3(
|
18
|
+
output, error, status = Open3.capture3(path, "--version")
|
20
19
|
if status.success?
|
21
20
|
return output.match(/GNU LilyPond (\d+\.\d+\.\d+)/)[1]
|
22
21
|
else
|
@@ -24,11 +23,14 @@ class LilyPond
|
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
|
-
|
26
|
+
# Approved output types: `[:pdf, :svg, :png]` If none is provided, it defaults to
|
27
|
+
# LilyPond.configuration.default_output, which initializes as `:pdf`
|
28
|
+
def generate_pdf_with_lilypond(file_name, lilypond_code, output_type = nil)
|
28
29
|
tempfile = Tempfile.new(file_name)
|
29
30
|
tempfile.write(lilypond_code)
|
30
31
|
tempfile.close
|
31
|
-
|
32
|
+
output_type ||= LilyPond.configuration.default_output
|
33
|
+
Open3.popen3(path, "--#{output}", tempfile.path) do |stdin, stdout, stderr, wait_thr|
|
32
34
|
# Write the Lilypond code to stdin
|
33
35
|
stdin.write(lilypond_code)
|
34
36
|
stdin.close
|
@@ -59,5 +61,10 @@ class LilyPond
|
|
59
61
|
File.delete(tempfile.path)
|
60
62
|
end
|
61
63
|
|
64
|
+
private
|
65
|
+
def path
|
66
|
+
LilyPond.configuration.lilypond_path
|
67
|
+
end
|
68
|
+
|
62
69
|
end # end self
|
63
70
|
end # end LilyPond
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: LilyPond-Ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.5
|
4
|
+
version: 0.1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Whittaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -30,9 +30,10 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.15.5
|
33
|
-
description:
|
34
|
-
|
35
|
-
also provides a builder tool for generating LilyPond files dynamically
|
33
|
+
description: |
|
34
|
+
This gem provides a library to access and control Lilypond within Ruby.
|
35
|
+
It also provides a builder tool for generating LilyPond files dynamically
|
36
|
+
with Ruby.
|
36
37
|
email: whittakerlee81@gmail.com
|
37
38
|
executables: []
|
38
39
|
extensions: []
|
@@ -41,6 +42,7 @@ files:
|
|
41
42
|
- lib/guile.rb
|
42
43
|
- lib/lilypond-ruby.rb
|
43
44
|
- lib/lilypond/builder.rb
|
45
|
+
- lib/lilypond/config.rb
|
44
46
|
- lilypond-2.24.1/bin/abc2ly
|
45
47
|
- lilypond-2.24.1/bin/convert-ly
|
46
48
|
- lilypond-2.24.1/bin/etf2ly
|