lyp 0.3.8 → 0.3.9
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 +2 -2
- data/bin/lilypond +15 -0
- data/lib/lyp/cli.rb +9 -0
- data/lib/lyp/lilypond.rb +49 -12
- data/lib/lyp/package.rb +1 -1
- data/lib/lyp/resolver.rb +58 -19
- data/lib/lyp/settings.rb +22 -15
- data/lib/lyp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b18fe5f2da98662c879adc93a9c83cf84a76660
|
4
|
+
data.tar.gz: 45e1e3f90e79c8d8a21cb7ced32048f56fa2150e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ea695bc459d7dfcebb201ec22b2de16710077092c18561f4682938ef9d5bfb9234c92a0a93ab87320635261117e1848edf25470c54ea75cbbc5c63d856baaf4
|
7
|
+
data.tar.gz: e1db9b949090fa70a3e927e45d3d59a6808d1f5fd07f093b1ed9e022aa324f759a7e788cbc4b51d708ac62aded70176397b62e0586ed5c297922fe3a1422ae49
|
data/bin/install_release.sh
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
-
LYP_VERSION="0.3.
|
3
|
+
LYP_VERSION="0.3.9"
|
4
4
|
WORKDIR="/tmp/lyp-release-installer"
|
5
5
|
URL_BASE="https://github.com/noteflakes/lyp/releases/download/v$LYP_VERSION"
|
6
6
|
|
@@ -20,7 +20,7 @@ download() {
|
|
20
20
|
fail "Could not find curl or wget"
|
21
21
|
fi
|
22
22
|
}
|
23
|
-
|
23
|
+
|
24
24
|
PLATFORM=`uname -sp`
|
25
25
|
case $PLATFORM in
|
26
26
|
"Linux x86_64")
|
data/bin/lilypond
CHANGED
@@ -24,12 +24,15 @@ LILYPOND_HELP_SWITCHES = %w{
|
|
24
24
|
|
25
25
|
LYP_LY_HELP = <<EOF
|
26
26
|
Lyp-provided options:
|
27
|
+
-A, --auto-install-deps install any missing dependencies
|
27
28
|
-c, --cropped crop output (requires setting 0 margins)
|
28
29
|
-E, --env use version specified in $LILYPOND_VERSION
|
29
30
|
-n, --install install the specified version if not found
|
30
31
|
-O, --open open the target file after compilation
|
31
32
|
-R, --raw run raw lilypond (no pre-processing)
|
32
33
|
-r, --require=PACKAGE preload the specified package
|
34
|
+
-S, --snippet produce png cropped images at 600dpi
|
35
|
+
(--cropped --png -dresolution=600)
|
33
36
|
-u, --use=VERSION use the given version of lilypond
|
34
37
|
EOF
|
35
38
|
|
@@ -43,7 +46,19 @@ when *LILYPOND_HELP_SWITCHES
|
|
43
46
|
puts `#{$lilypond_path} #{$argv.join(' ')}`
|
44
47
|
puts LYP_LY_HELP unless $argv.first == '-dhelp'
|
45
48
|
else
|
49
|
+
Lyp::Lilypond.check_update
|
46
50
|
begin
|
51
|
+
if $options[:resolve] && $argv.last != '-'
|
52
|
+
resolver = Lyp::DependencyResolver.new($argv.last)
|
53
|
+
tree = resolver.compile_dependency_tree(ignore_missing: true)
|
54
|
+
tree.dependencies.each do |package, spec|
|
55
|
+
Lyp::Package.install(spec.clause) if spec.versions.empty?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
47
59
|
Lyp::Lilypond.compile($argv, $options)
|
60
|
+
rescue => e
|
61
|
+
puts e.message
|
62
|
+
puts e.backtrace.join("\n")
|
48
63
|
end
|
49
64
|
end
|
data/lib/lyp/cli.rb
CHANGED
@@ -147,9 +147,18 @@ class Lyp::CLI < Thor
|
|
147
147
|
desc "install <PACKAGE|lilypond|self>...", "Install a package or a version of lilypond. When 'install self' is invoked, lyp installs itself in ~/.lyp."
|
148
148
|
method_option :default, aliases: '-d', type: :boolean, desc: 'Set default lilypond version'
|
149
149
|
method_option :test, aliases: '-t', type: :boolean, desc: 'Run package tests after installation'
|
150
|
+
method_option :dev, type: :boolean, desc: 'Install local development package'
|
150
151
|
def install(*args)
|
151
152
|
$cmd_options = options
|
152
153
|
|
154
|
+
if options[:dev]
|
155
|
+
if args.empty?
|
156
|
+
args = ["#{File.basename(FileUtils.pwd)}@dev:."]
|
157
|
+
else
|
158
|
+
args = args.map {|a| "#{File.basename(File.expand_path(a))}@dev:#{a}"}
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
153
162
|
raise "No package specified" if args.empty?
|
154
163
|
|
155
164
|
args.each do |package|
|
data/lib/lyp/lilypond.rb
CHANGED
@@ -34,6 +34,10 @@ module Lyp::Lilypond
|
|
34
34
|
options[:open] = true
|
35
35
|
when '-c', '--cropped'
|
36
36
|
argv_clean += ['-dbackend=eps', '-daux-files=#f']
|
37
|
+
when '-S', '--snippet'
|
38
|
+
argv_clean += ['-dbackend=eps', '-daux-files=#f', '--png', '-dresolution=600']
|
39
|
+
when '-A', '--auto-install-deps'
|
40
|
+
options[:resolve] = true
|
37
41
|
else
|
38
42
|
argv_clean << arg
|
39
43
|
end
|
@@ -316,6 +320,11 @@ module Lyp::Lilypond
|
|
316
320
|
search.reverse.find {|l| Gem::Version.new(l[:version]).segments[1].odd?}[:version]
|
317
321
|
end
|
318
322
|
|
323
|
+
def latest_installed_unstable_version
|
324
|
+
latest = list.reverse.find {|l| Gem::Version.new(l[:version]).segments[1].odd?}
|
325
|
+
latest ? latest[:version] : nil
|
326
|
+
end
|
327
|
+
|
319
328
|
def latest_version
|
320
329
|
search.last[:version]
|
321
330
|
end
|
@@ -570,19 +579,17 @@ module Lyp::Lilypond
|
|
570
579
|
ly_fonts_dir = File.join(lyp_lilypond_share_dir(version), 'lilypond/current/fonts')
|
571
580
|
|
572
581
|
Dir["#{Lyp.packages_dir}/**/fonts"].each do |package_fonts_dir|
|
582
|
+
Dir["#{package_fonts_dir}/**/*"].each do |fn|
|
583
|
+
next unless File.file?(fn)
|
584
|
+
target_fn = case File.extname(fn)
|
585
|
+
when '.otf'
|
586
|
+
File.join(ly_fonts_dir, 'otf', File.basename(fn))
|
587
|
+
when '.svg', '.woff'
|
588
|
+
File.join(ly_fonts_dir, 'svg', File.basename(fn))
|
589
|
+
else
|
590
|
+
next
|
591
|
+
end
|
573
592
|
|
574
|
-
Dir["#{package_fonts_dir}/*.otf"].each do |fn|
|
575
|
-
target_fn = File.join(ly_fonts_dir, 'otf', File.basename(fn))
|
576
|
-
FileUtils.cp(fn, target_fn)
|
577
|
-
end
|
578
|
-
|
579
|
-
Dir["#{package_fonts_dir}/*.svg"].each do |fn|
|
580
|
-
target_fn = File.join(ly_fonts_dir, 'svg', File.basename(fn))
|
581
|
-
FileUtils.cp(fn, target_fn)
|
582
|
-
end
|
583
|
-
|
584
|
-
Dir["#{package_fonts_dir}/*.woff"].each do |fn|
|
585
|
-
target_fn = File.join(ly_fonts_dir, 'svg', File.basename(fn))
|
586
593
|
FileUtils.cp(fn, target_fn)
|
587
594
|
end
|
588
595
|
end
|
@@ -675,5 +682,35 @@ module Lyp::Lilypond
|
|
675
682
|
def parse_error_msg(msg)
|
676
683
|
(msg =~ /[^\n]+: error.+failed files: ".+"/m) ? $& : msg
|
677
684
|
end
|
685
|
+
|
686
|
+
CHECK_UPDATE_INTERVAL = 7 * 86400
|
687
|
+
CHECK_UPDATE_STAMP_KEY = 'lilypond/last_update_stamp'
|
688
|
+
|
689
|
+
UNSTABLE_UPDATE_MESSAGE = <<EOF
|
690
|
+
Lilypond version %s is now available. Install it by typing:
|
691
|
+
|
692
|
+
lyp install lilypond@unstable
|
693
|
+
|
694
|
+
EOF
|
695
|
+
|
696
|
+
def check_update
|
697
|
+
last_check = Lyp::Settings.get_value(
|
698
|
+
CHECK_UPDATE_STAMP_KEY, Time.now - CHECK_UPDATE_INTERVAL)
|
699
|
+
|
700
|
+
return unless last_check < Time.now - CHECK_UPDATE_INTERVAL
|
701
|
+
|
702
|
+
Lyp::Settings.set_value(CHECK_UPDATE_STAMP_KEY, Time.now)
|
703
|
+
|
704
|
+
# check unstable
|
705
|
+
installed = latest_installed_unstable_version
|
706
|
+
return unless installed
|
707
|
+
|
708
|
+
available = {version: latest_unstable_version}
|
709
|
+
installed = {version: installed}
|
710
|
+
|
711
|
+
if CMP_VERSION[available, installed] > 0
|
712
|
+
puts UNSTABLE_UPDATE_MESSAGE % available[:version]
|
713
|
+
end
|
714
|
+
end
|
678
715
|
end
|
679
716
|
end
|
data/lib/lyp/package.rb
CHANGED
@@ -298,7 +298,7 @@ module Lyp::Package
|
|
298
298
|
available_on_versions << lilypond[:version]
|
299
299
|
end
|
300
300
|
|
301
|
-
Dir["#{package_fonts_dir}
|
301
|
+
Dir["#{package_fonts_dir}/**/*"].each do |fn|
|
302
302
|
next unless File.file?(fn)
|
303
303
|
target_fn = case File.extname(fn)
|
304
304
|
when '.otf'
|
data/lib/lyp/resolver.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Lyp
|
2
2
|
class DependencySpec
|
3
|
-
attr_reader :clause, :versions
|
3
|
+
attr_reader :clause, :versions, :location
|
4
4
|
|
5
|
-
def initialize(clause, versions =
|
5
|
+
def initialize(clause, versions, location = nil)
|
6
6
|
@clause = clause
|
7
7
|
@versions = versions.inject({}) {|m, kv| m[kv[0].to_s] = kv[1]; m}
|
8
|
+
@location = location
|
8
9
|
end
|
9
10
|
|
10
11
|
def add_version(version, leaf)
|
@@ -16,7 +17,7 @@ module Lyp
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def hash
|
19
|
-
{
|
20
|
+
{clause: clause, versions: versions}.hash
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -28,6 +29,9 @@ module Lyp
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def add_dependency(name, spec)
|
32
|
+
if @dependencies[name.to_s] && !spec.eql?(@dependencies[name.to_s])
|
33
|
+
DependencyResolver.error("Clause mismatch found in %s", spec.location)
|
34
|
+
end
|
31
35
|
@dependencies[name.to_s] = spec
|
32
36
|
end
|
33
37
|
|
@@ -110,7 +114,7 @@ module Lyp
|
|
110
114
|
result = select_highest_versioned_permutation(permutations, user_deps).flatten
|
111
115
|
|
112
116
|
if result.empty? && !tree.dependencies.empty?
|
113
|
-
|
117
|
+
error("Failed to satisfy dependency requirements")
|
114
118
|
else
|
115
119
|
result
|
116
120
|
end
|
@@ -174,29 +178,33 @@ module Lyp
|
|
174
178
|
dir = File.dirname(path)
|
175
179
|
|
176
180
|
# Parse lilypond file for \include and \require
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
181
|
+
location = {path: path, line: 0}
|
182
|
+
ly_content.each_line do |line|
|
183
|
+
location[:line] += 1
|
184
|
+
line.scan(DEP_RE) do |type, ref|
|
185
|
+
case type
|
186
|
+
when INCLUDE, PINCLUDE, PINCLUDE_ONCE
|
187
|
+
process_include_command(ref, dir, leaf, opts, location)
|
188
|
+
when REQUIRE
|
189
|
+
process_require_command(ref, dir, leaf, opts, location)
|
190
|
+
end
|
183
191
|
end
|
184
192
|
end
|
185
193
|
|
186
194
|
# process any external requires (supplied using the -r command line option)
|
187
195
|
if @ext_require
|
188
196
|
@ext_require.each do |p|
|
189
|
-
process_require_command(p, dir, leaf, opts)
|
197
|
+
process_require_command(p, dir, leaf, opts, {ext_require: true})
|
190
198
|
end
|
191
199
|
@ext_require = nil
|
192
200
|
end
|
193
201
|
|
194
202
|
@processed_files[path] = true
|
195
203
|
rescue Errno::ENOENT
|
196
|
-
|
204
|
+
error("Could not find file #{path}")
|
197
205
|
end
|
198
206
|
|
199
|
-
def process_include_command(ref, dir, leaf, opts)
|
207
|
+
def process_include_command(ref, dir, leaf, opts, location)
|
200
208
|
# a package would normally use a plain \pinclude or \pincludeOnce
|
201
209
|
# command to include package files, e.g. \pinclude "inc/init.ly".
|
202
210
|
#
|
@@ -209,10 +217,15 @@ module Lyp
|
|
209
217
|
ref = $2
|
210
218
|
end
|
211
219
|
qualified_path = File.expand_path(ref, dir)
|
220
|
+
|
221
|
+
unless File.file?(qualified_path)
|
222
|
+
error("Invalid include file specified in %s", location)
|
223
|
+
end
|
224
|
+
|
212
225
|
queue_file_for_processing(qualified_path, leaf)
|
213
226
|
end
|
214
227
|
|
215
|
-
def process_require_command(ref, dir, leaf, opts)
|
228
|
+
def process_require_command(ref, dir, leaf, opts, location)
|
216
229
|
forced_path = nil
|
217
230
|
if ref =~ /^([^\:]+)\:(.+)$/
|
218
231
|
ref = $1
|
@@ -228,7 +241,7 @@ module Lyp
|
|
228
241
|
set_forced_package_path(package, forced_path)
|
229
242
|
end
|
230
243
|
|
231
|
-
find_package_versions(ref, leaf)
|
244
|
+
find_package_versions(ref, leaf, location)
|
232
245
|
end
|
233
246
|
|
234
247
|
def queue_file_for_processing(path, leaf)
|
@@ -430,7 +443,7 @@ module Lyp
|
|
430
443
|
|
431
444
|
# Find available packaging matching the package specifier, and queue them for
|
432
445
|
# processing any include files or transitive dependencies.
|
433
|
-
def find_package_versions(ref, leaf)
|
446
|
+
def find_package_versions(ref, leaf, location)
|
434
447
|
return {} unless ref =~ Lyp::PACKAGE_RE
|
435
448
|
ref_package = $1
|
436
449
|
version_clause = $2
|
@@ -439,7 +452,8 @@ module Lyp
|
|
439
452
|
|
440
453
|
# Raise if no match found and we're at top of the tree
|
441
454
|
if matches.empty? && (leaf == tree) && !opts[:ignore_missing]
|
442
|
-
|
455
|
+
msg = "Missing package dependency #{ref} in %sYou can install any missing packages by running:\n\n lyp resolve #{@user_file}"
|
456
|
+
error(msg, location)
|
443
457
|
end
|
444
458
|
|
445
459
|
matches.each do |p, package_leaf|
|
@@ -449,7 +463,7 @@ module Lyp
|
|
449
463
|
end
|
450
464
|
|
451
465
|
# Setup up dependency leaf
|
452
|
-
leaf.add_dependency(ref_package, DependencySpec.new(ref, matches))
|
466
|
+
leaf.add_dependency(ref_package, DependencySpec.new(ref, matches, location))
|
453
467
|
end
|
454
468
|
|
455
469
|
# Remove redundant older versions of dependencies by collating package
|
@@ -525,7 +539,7 @@ module Lyp
|
|
525
539
|
end
|
526
540
|
end
|
527
541
|
if dependency.versions.empty? && raise_on_missing
|
528
|
-
|
542
|
+
error("No valid version found for package #{package}")
|
529
543
|
end
|
530
544
|
end
|
531
545
|
end
|
@@ -537,5 +551,30 @@ module Lyp
|
|
537
551
|
available_packages["#{package}@forced"] = DependencyPackage.new(
|
538
552
|
File.join(path, MAIN_PACKAGE_FILE))
|
539
553
|
end
|
554
|
+
|
555
|
+
def error(msg, location = nil)
|
556
|
+
DependencyResolver.error(msg, location)
|
557
|
+
end
|
558
|
+
|
559
|
+
def self.error(msg, location = nil)
|
560
|
+
location = location ? format_location(location) : nil
|
561
|
+
raise ResolveError, msg % location
|
562
|
+
end
|
563
|
+
|
564
|
+
def self.format_location(location)
|
565
|
+
return "" unless location
|
566
|
+
return "require flag" if location[:ext_require]
|
567
|
+
source_line = get_source_line(location[:path], location[:line])
|
568
|
+
"#{location[:path]}:#{location[:line]}: \n\n #{source_line}\n"
|
569
|
+
end
|
570
|
+
|
571
|
+
def self.get_source_line(path, line)
|
572
|
+
IO.read(path).lines[line - 1]
|
573
|
+
rescue => e
|
574
|
+
"???"
|
575
|
+
end
|
540
576
|
end
|
541
577
|
end
|
578
|
+
|
579
|
+
class ResolveError < RuntimeError
|
580
|
+
end
|
data/lib/lyp/settings.rb
CHANGED
@@ -2,36 +2,43 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module Lyp::Settings
|
4
4
|
class << self
|
5
|
-
def
|
6
|
-
YAML.load(IO.read(Lyp.settings_file)) rescue {}
|
5
|
+
def load
|
6
|
+
@settings = YAML.load(IO.read(Lyp.settings_file)) rescue {}
|
7
7
|
end
|
8
|
-
|
9
|
-
def
|
10
|
-
File.open(Lyp.settings_file, 'w+') {|f| f << YAML.dump(
|
8
|
+
|
9
|
+
def save
|
10
|
+
File.open(Lyp.settings_file, 'w+') {|f| f << YAML.dump(@settings)}
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def [](path)
|
14
|
-
h =
|
14
|
+
h = load
|
15
15
|
while path =~ /^([^\/]+)\/(.+)$/
|
16
16
|
h = h[$1.to_sym] ||= {}
|
17
17
|
path = $2
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
h[path.to_sym]
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def []=(path, value)
|
24
|
-
h =
|
24
|
+
h = load
|
25
25
|
while path =~ /^([^\/]+)\/(.+)$/
|
26
26
|
h = h[$1.to_sym] ||= {}
|
27
27
|
path = $2
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
h[path.to_sym] = value
|
31
|
-
|
32
|
-
set(settings)
|
33
|
-
|
31
|
+
save
|
34
32
|
value
|
35
33
|
end
|
34
|
+
|
35
|
+
def get_value(path, default = nil)
|
36
|
+
v = self[path]
|
37
|
+
v ? YAML.load(v) : default
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_value(path, value)
|
41
|
+
self[path] = YAML.dump(value)
|
42
|
+
end
|
36
43
|
end
|
37
|
-
end
|
44
|
+
end
|
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.9
|
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-06-
|
11
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|