lyp 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/install_release.sh +1 -1
- data/lib/lyp/base.rb +20 -2
- data/lib/lyp/cli.rb +1 -1
- data/lib/lyp/etc/detect_system_lilypond.ly +14 -0
- data/lib/lyp/lilypond.rb +33 -10
- data/lib/lyp/package.rb +36 -16
- data/lib/lyp/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e45125d6f5c577945a68e0f18d81d3202495a52c
|
4
|
+
data.tar.gz: 24379cc9ee854d468587469286a6c5e306e39f7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6201fa84a3a6f5458d5caf4f8cc85135def441229c8cebd8f32269496b8f8a49353edd50477961bac05376497710e3b196ae9eb4b47f8f6b97935d555c595f28
|
7
|
+
data.tar.gz: 74f2e49025ce8b1049e348c28666fc7d0181fc0a603066fcc994d49b47298b3b357c65576f8c43a8ebea3542d5c1bf34b48a890179451dfbfb44eaab41bda642
|
data/bin/install_release.sh
CHANGED
data/lib/lyp/base.rb
CHANGED
@@ -25,12 +25,17 @@ module Lyp
|
|
25
25
|
FONT_COPY_REQ = Gem::Requirement.new('>=2.18.2')
|
26
26
|
FONT_PATCH_REQ = Gem::Requirement.new('>=2.18.2', '<2.19.12')
|
27
27
|
|
28
|
+
ETC_DIRECTORY = File.join(File.dirname(__FILE__), 'etc')
|
29
|
+
|
28
30
|
# Font patch filename (required for 2.18.2 <= lilypond < 2.19.12)
|
29
|
-
FONT_PATCH_FILENAME = File.
|
31
|
+
FONT_PATCH_FILENAME = File.join(ETC_DIRECTORY, 'font.scm')
|
32
|
+
|
33
|
+
# File for detecting version and data dir of system-installed lilypond
|
34
|
+
DETECT_SYSTEM_LILYPOND_FILENAME = File.join(ETC_DIRECTORY, 'detect_system_lilypond.ly')
|
30
35
|
|
31
36
|
# etc/lyp.ly contains lyp:* procedure definitions for loading packages and
|
32
37
|
# other support code.
|
33
|
-
LYP_LY_LIB_PATH = File.
|
38
|
+
LYP_LY_LIB_PATH = File.join(ETC_DIRECTORY, 'lyp.ly')
|
34
39
|
|
35
40
|
LILYPOND_NOT_FOUND_MSG = "No version of lilypond found.\nTo install lilypond run 'lyp install lilypond'"
|
36
41
|
|
@@ -57,5 +62,18 @@ module Lyp
|
|
57
62
|
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
58
63
|
dir
|
59
64
|
end
|
65
|
+
|
66
|
+
def self.sudo_cp(src, dest)
|
67
|
+
cmd = "sudo cp #{src} #{dest}"
|
68
|
+
msg = `#{cmd}`
|
69
|
+
raise msg unless $?.success?
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.confirm_action(prompt)
|
73
|
+
require 'readline'
|
74
|
+
|
75
|
+
response = Readline.readline(prompt)
|
76
|
+
["y", "yes"].include?(response)
|
77
|
+
end
|
60
78
|
end
|
61
79
|
|
data/lib/lyp/cli.rb
CHANGED
@@ -219,7 +219,7 @@ class Lyp::CLI < Thor
|
|
219
219
|
end
|
220
220
|
|
221
221
|
lilypond = Lyp::Lilypond.use(version, options)
|
222
|
-
puts "Using version #{lilypond[:version]}"
|
222
|
+
puts "Using lilypond version #{lilypond[:version]}"
|
223
223
|
end
|
224
224
|
|
225
225
|
desc "list [PATTERN|lilypond]", "List installed packages matching PATTERN or versions of lilypond"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
% original code:
|
2
|
+
% https://github.com/openlilylib/oll-core/blob/master/internal/predicates.scm
|
3
|
+
|
4
|
+
#(begin
|
5
|
+
(define (lilypond-version-string)
|
6
|
+
(string-join
|
7
|
+
(map (lambda (elt) (if (integer? elt) (number->string elt) elt))
|
8
|
+
(ly:version))
|
9
|
+
"."))
|
10
|
+
|
11
|
+
(display (format "~a\n~a\n" (lilypond-version-string) (ly:get-option 'datadir)))
|
12
|
+
)
|
13
|
+
|
14
|
+
|
data/lib/lyp/lilypond.rb
CHANGED
@@ -184,10 +184,10 @@ module Lyp::Lilypond
|
|
184
184
|
|
185
185
|
list.inject([]) do |m, path|
|
186
186
|
begin
|
187
|
-
resp = `#{path}
|
188
|
-
|
189
|
-
|
190
|
-
|
187
|
+
resp = `#{path} #{Lyp::DETECT_SYSTEM_LILYPOND_FILENAME} 2>/dev/null`
|
188
|
+
|
189
|
+
if resp =~ /(.+)\n(.+)/
|
190
|
+
version, data_path = $1, $2
|
191
191
|
m << {
|
192
192
|
root_path: File.expand_path(File.join(File.dirname(path), '..')),
|
193
193
|
data_path: data_path,
|
@@ -197,7 +197,7 @@ module Lyp::Lilypond
|
|
197
197
|
}
|
198
198
|
end
|
199
199
|
rescue
|
200
|
-
# ignore error
|
200
|
+
# ignore error, don't include this version in the list of lilyponds
|
201
201
|
end
|
202
202
|
m
|
203
203
|
end
|
@@ -475,15 +475,38 @@ module Lyp::Lilypond
|
|
475
475
|
target_fn = File.join(lyp_lilypond_share_dir(version), 'lilypond/current/scm/font.scm')
|
476
476
|
FileUtils.cp(Lyp::FONT_PATCH_FILENAME, target_fn)
|
477
477
|
end
|
478
|
+
|
479
|
+
SYSTEM_LILYPOND_PATCH_WARNING = <<-EOF.gsub(/^\s{6}/, '').chomp
|
480
|
+
The system-installed lilypond version %s needs to be patched in
|
481
|
+
order to support custom music fonts. This operation will replace the file
|
482
|
+
|
483
|
+
%s
|
484
|
+
|
485
|
+
Would you like to overwrite this file? (y/n):
|
486
|
+
EOF
|
478
487
|
|
479
|
-
def patch_system_lilypond_font_scm(lilypond)
|
480
|
-
return unless Lyp::FONT_PATCH_REQ =~ Gem::Version.new(lilypond[:version])
|
488
|
+
def patch_system_lilypond_font_scm(lilypond, opts)
|
489
|
+
return false unless Lyp::FONT_PATCH_REQ =~ Gem::Version.new(lilypond[:version])
|
481
490
|
|
482
491
|
target_fn = File.join(lilypond[:data_path], '/scm/font.scm')
|
483
|
-
|
484
|
-
|
485
|
-
|
492
|
+
# do nothing if alredy patched
|
493
|
+
if IO.read(target_fn) == IO.read(Lyp::FONT_PATCH_FILENAME)
|
494
|
+
return true
|
495
|
+
end
|
486
496
|
|
497
|
+
prompt = SYSTEM_LILYPOND_PATCH_WARNING % [lilypond[:version], target_fn]
|
498
|
+
return unless Lyp.confirm_action(prompt)
|
499
|
+
|
500
|
+
puts "Patching #{target_fn}:" unless opts[:silent]
|
501
|
+
if File.writeable?(target_fn)
|
502
|
+
FileUtils.cp(target_fn, "#{target_fn}.old")
|
503
|
+
FileUtils.cp(Lyp::FONT_PATCH_FILENAME, target_fn)
|
504
|
+
else
|
505
|
+
Lyp.sudo_cp(target_fn, "#{target_fn}.old")
|
506
|
+
Lyp.sudo_cp(Lyp::FONT_PATCH_FILENAME, target_fn)
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
487
510
|
def copy_fonts_from_all_packages(version, opts)
|
488
511
|
return unless Lyp::FONT_COPY_REQ =~ Gem::Version.new(version)
|
489
512
|
|
data/lib/lyp/package.rb
CHANGED
@@ -68,7 +68,6 @@ module Lyp::Package
|
|
68
68
|
install_package_dependencies(info[:path], opts)
|
69
69
|
|
70
70
|
if File.directory?(File.join(info[:path], 'fonts'))
|
71
|
-
puts "Installing package fonts..." unless opts[:silent]
|
72
71
|
install_package_fonts(info[:path], opts)
|
73
72
|
end
|
74
73
|
|
@@ -269,35 +268,56 @@ module Lyp::Package
|
|
269
268
|
end
|
270
269
|
sub_deps.each {|d| install(d, opts)}
|
271
270
|
end
|
271
|
+
|
272
|
+
SYSTEM_LILYPOND_PROMPT = <<-EOF.gsub(/^\s{6}/, '').chomp
|
273
|
+
Do you wish to install the package fonts on the system-installed lilypond
|
274
|
+
version %s (this might require sudo password)? (y/n):
|
275
|
+
EOF
|
272
276
|
|
273
277
|
def install_package_fonts(package_path, opts = {})
|
278
|
+
puts "Installing package fonts..." unless opts[:silent]
|
279
|
+
available_on_versions = []
|
280
|
+
|
274
281
|
req = Lyp::FONT_COPY_REQ
|
275
282
|
|
276
283
|
Lyp::Lilypond.list.each do |lilypond|
|
277
284
|
next unless req =~ Gem::Version.new(lilypond[:version])
|
278
|
-
|
285
|
+
|
286
|
+
if lilypond[:system]
|
287
|
+
next unless Lyp.confirm_action(SYSTEM_LILYPOND_PROMPT % lilypond[:version])
|
288
|
+
end
|
289
|
+
|
279
290
|
ly_fonts_dir = File.join(lilypond[:data_path], 'fonts')
|
280
291
|
package_fonts_dir = File.join(package_path, 'fonts')
|
281
292
|
|
282
293
|
if lilypond[:system]
|
283
|
-
Lyp::Lilypond.patch_system_lilypond_font_scm(lilypond)
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
FileUtils.cp(fn, target_fn)
|
289
|
-
end
|
290
|
-
|
291
|
-
Dir["#{package_fonts_dir}/*.svg"].each do |fn|
|
292
|
-
target_fn = File.join(ly_fonts_dir, 'svg', File.basename(fn))
|
293
|
-
FileUtils.cp(fn, target_fn)
|
294
|
+
if Lyp::Lilypond.patch_system_lilypond_font_scm(lilypond, opts)
|
295
|
+
available_on_versions << lilypond[:version]
|
296
|
+
end
|
297
|
+
else
|
298
|
+
available_on_versions << lilypond[:version]
|
294
299
|
end
|
295
300
|
|
296
|
-
Dir["#{package_fonts_dir}
|
297
|
-
target_fn =
|
298
|
-
|
301
|
+
Dir["#{package_fonts_dir}/*"].each do |fn|
|
302
|
+
target_fn = case File.extname(fn)
|
303
|
+
when '.otf'
|
304
|
+
File.join(ly_fonts_dir, 'otf', File.basename(fn))
|
305
|
+
when '.svg', '.woff'
|
306
|
+
File.join(ly_fonts_dir, 'svg', File.basename(fn))
|
307
|
+
end
|
308
|
+
|
309
|
+
if File.writable?(File.dirname(target_fn))
|
310
|
+
FileUtils.cp(fn, target_fn)
|
311
|
+
else
|
312
|
+
Lyp.sudo_cp(fn, target_fn)
|
313
|
+
end
|
299
314
|
end
|
300
315
|
end
|
316
|
+
|
317
|
+
unless opts[:silent]
|
318
|
+
puts "\nFonts available on lilypond #{available_on_versions.join(', ')}"
|
319
|
+
end
|
320
|
+
|
301
321
|
end
|
302
322
|
|
303
323
|
def package_git_url(package, search_index = true)
|
data/lib/lyp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lyp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/lyp.rb
|
101
101
|
- lib/lyp/base.rb
|
102
102
|
- lib/lyp/cli.rb
|
103
|
+
- lib/lyp/etc/detect_system_lilypond.ly
|
103
104
|
- lib/lyp/etc/font.scm
|
104
105
|
- lib/lyp/etc/lyp.ly
|
105
106
|
- lib/lyp/git_based_rugged.rb
|