LilyPond-Ruby 0.1.5.2 → 0.1.5.3
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/lilypond-ruby.rb +35 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d54f5369710cc4da48b7114204e186b85edeff67dd1cd8eda50066ff4495b2a
|
4
|
+
data.tar.gz: b3ff051ea699b01fb52c803c7d61159566d0484bb80b29d23f94ac2465f1a8f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ffb4a7ab0157de96b1a22b5d44cc20288d3a4c874fee6c20784e5187a7437b2a9533e5f6c23ba423ba0ae0abff61054a8193d4fc70c02e635ed09e8c1174dd5
|
7
|
+
data.tar.gz: 1068a3ec0dea29a3a3e874d8f7e7b89c5d963d44224bddea5d4fc51d4cfce63984c3459f4d18db284a738bdf4f6cf271ba5ab495d70a4a45b022e944f00a3cdc
|
data/lib/lilypond-ruby.rb
CHANGED
@@ -25,45 +25,55 @@ module LilyPond
|
|
25
25
|
|
26
26
|
# Approved output types: `[:pdf, :svg, :png]` If none is provided, it defaults to
|
27
27
|
# LilyPond.configuration.default_output, which initializes as `:pdf`
|
28
|
-
def
|
28
|
+
def generate_with_lilypond(file_name, lilypond_code, output_type = nil)
|
29
29
|
tempfile = Tempfile.new(file_name)
|
30
30
|
tempfile.write(lilypond_code)
|
31
31
|
tempfile.close
|
32
|
-
output_type ||=
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
output_type ||= default_output
|
33
|
+
Dir.chdir(destination) do
|
34
|
+
Open3.popen3(path, "--#{output_type}", tempfile.path) do |stdin, stdout, stderr, wait_thr|
|
35
|
+
# Write the Lilypond code to stdin
|
36
|
+
stdin.write(lilypond_code)
|
37
|
+
stdin.close
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
# Wait for the process to complete
|
40
|
+
Process.detach(wait_thr.pid)
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
# Read and process the output and error streams
|
43
|
+
loop do
|
44
|
+
# Wait for output to become available for reading
|
45
|
+
ready = IO.select([stdout, stderr])
|
46
|
+
next unless ready
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
# Read available data from the streams
|
49
|
+
ready[0].each do |stream|
|
50
|
+
data = stream.read_nonblock(1024)
|
51
|
+
puts data # or process the data as necessary
|
52
|
+
end
|
53
|
+
rescue IO::WaitReadable, IO::WaitWritable
|
54
|
+
# Continue waiting if the streams are not yet ready
|
55
|
+
IO.select([stdout, stderr])
|
56
|
+
retry
|
57
|
+
rescue EOFError
|
58
|
+
# Stop waiting if the streams have been closed
|
59
|
+
break
|
51
60
|
end
|
52
|
-
rescue IO::WaitReadable, IO::WaitWritable
|
53
|
-
# Continue waiting if the streams are not yet ready
|
54
|
-
IO.select([stdout, stderr])
|
55
|
-
retry
|
56
|
-
rescue EOFError
|
57
|
-
# Stop waiting if the streams have been closed
|
58
|
-
break
|
59
61
|
end
|
60
62
|
end
|
61
63
|
File.delete(tempfile.path)
|
62
64
|
end
|
63
65
|
|
64
66
|
private
|
67
|
+
def default_output
|
68
|
+
LilyPond.configuration.default_output
|
69
|
+
end
|
70
|
+
|
71
|
+
def destination
|
72
|
+
LilyPond.configuration.destination_directory
|
73
|
+
end
|
74
|
+
|
65
75
|
def path
|
66
|
-
LilyPond.configuration.lilypond_path
|
76
|
+
LilyPond.configuration.lilypond_path.to_s
|
67
77
|
end
|
68
78
|
|
69
79
|
end # end self
|
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.3
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|