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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lilypond-ruby.rb +35 -25
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0753909e55ec718709787b480e31ac1125cf69355e4993b278ad9ef2c7d37b78'
4
- data.tar.gz: 47a9251087eca6fa7730ab28f04e7d383411ca2a7ddba159034ffebf351bea71
3
+ metadata.gz: 4d54f5369710cc4da48b7114204e186b85edeff67dd1cd8eda50066ff4495b2a
4
+ data.tar.gz: b3ff051ea699b01fb52c803c7d61159566d0484bb80b29d23f94ac2465f1a8f5
5
5
  SHA512:
6
- metadata.gz: fc1930db2fd8263983327931b9ef14856aec59631c92a430f75fda1d1cbca99d0f42aaf1772b7806ab6211d3b65e7643a320283a6e82fb874b10fb5c14e58e0b
7
- data.tar.gz: 9c8663c4c47e2321678fb975d2e214f3fdacf5d76bfe981c376d062ac55179d40846f285fc0d3fd0d8594cfc42e43d3965d125a4b54b0f48b8dec977fa8f5d07
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 generate_pdf_with_lilypond(file_name, lilypond_code, output_type = nil)
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 ||= LilyPond.configuration.default_output
33
- Open3.popen3(path, "--#{output}", tempfile.path) do |stdin, stdout, stderr, wait_thr|
34
- # Write the Lilypond code to stdin
35
- stdin.write(lilypond_code)
36
- stdin.close
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
- # Wait for the process to complete
39
- Process.detach(wait_thr.pid)
39
+ # Wait for the process to complete
40
+ Process.detach(wait_thr.pid)
40
41
 
41
- # Read and process the output and error streams
42
- loop do
43
- # Wait for output to become available for reading
44
- ready = IO.select([stdout, stderr])
45
- next unless ready
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
- # Read available data from the streams
48
- ready[0].each do |stream|
49
- data = stream.read_nonblock(1024)
50
- puts data # or process the data as necessary
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.2
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-10 00:00:00.000000000 Z
11
+ date: 2023-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi