lyp 0.3.6 → 0.3.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8e7eff9d0273f1f122a7cef54b14742090cbc56
4
- data.tar.gz: c2c62ae013980d248bc3b1f7f3c2640000b387d3
3
+ metadata.gz: b51e26364d2db0d4433ba21cdff532f05afa846c
4
+ data.tar.gz: 0305882ebc3ec0aee3a484f4bbea47cc39c6ccc1
5
5
  SHA512:
6
- metadata.gz: 55d99aabb7837d1d4bb7ef91d8a96daadecc84fefe292b0796ba68d45961213fbc5d6161dc6412d43a7d903cd9524dc28dd27ae864f10e8463cb72ad6c856f42
7
- data.tar.gz: ed708b1226d8611769fd14f559113c907c47834f32d51c19ce0908cffa0ec9cac4c9261603fe073b9659d0dedb2f22d3d5b11516b048cf5b4cb606ff769e6253
6
+ metadata.gz: 27f6770fa7d43f96e399c951cac4ef3afd45b952d01857113608bf95a8e62c3a05e2fa8530596255b28d3f38a7b45804808096521905439a800fede2b244019f
7
+ data.tar.gz: 318b2daf11c8507e082ee493b91a4f5d79f0b9c6bc55048b4db2a07be36a6ac6489bf347cd05de71aca4e0b6b374c66f143349a87c75a597913074d155631c89
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
- [![Build Status](https://travis-ci.org/noteflakes/lyp.svg?branch=master)](https://travis-ci.org/noteflakes/lyp)
1
+ <p align="center">
2
+ <a href="https://travis-ci.org/noteflakes/lyp"><img src="https://travis-ci.org/noteflakes/lyp.svg?branch=master"</a>
3
+ </p>
4
+ <p align="center">
5
+ <a href="https://github.com/lyp-packages/index#readme">The lyp package index</a>
6
+ </p>
2
7
 
3
8
  # lyp - a package manager for lilypond
4
9
 
@@ -130,7 +135,7 @@ The difference between merely copying and including a lilypond file in your musi
130
135
 
131
136
  In lyp, a package should contain at least a single lilypond file named `package.ly` in its root directory. A package could contain additional lilypond files referenced in the main package file (using relative includes). A package could also depend on other packages by using the `\require` command (see below).
132
137
 
133
- Lilypond packages are expected to be published as git repositories. The packages is then versioned using git tags. A package can be referenced either using its git URL, a short name (if it's registered in the [lyp package index](https://github.com/noteflakes/lyp-index)), or alternatively as a local path (which is meant for package development more than anything else).
138
+ Lilypond packages are expected to be published as git repositories. The packages is then versioned using git tags. A package can be referenced either using its git URL, a short name (if it's registered in the [lyp package index](https://github.com/lyp-packages/index)), or alternatively as a local path (which is meant for package development more than anything else).
134
139
 
135
140
  ### Installing packages
136
141
 
@@ -197,7 +202,7 @@ To install the `assert` package required in the file we run:
197
202
  ```bash
198
203
  $ lyp resolve test.ly
199
204
  #=>
200
- Cloning https://github.com/noteflakes/lyp-assert.git...
205
+ Cloning https://github.com/lyp-packages/assert.git...
201
206
 
202
207
  Installed assert@0.2.0
203
208
  ```
@@ -216,17 +221,17 @@ A package is normally referenced by its git URL. Lyp lets you provide either ful
216
221
 
217
222
  ```bash
218
223
  # Fully-qualified URLs
219
- $ lyp install https://github.com/noteflakes/lyp-package-template.git
220
- $ lyp install https://github.com/noteflakes/lyp-package-template
224
+ $ lyp install https://github.com/lyp-packages/package-template.git
225
+ $ lyp install https://github.com/lyp-packages/package-template
221
226
 
222
227
  # Partially-qualified URL
223
- $ lyp install github.com/noteflakes/lyp-package-template
228
+ $ lyp install github.com/lyp-packages/package-template
224
229
 
225
230
  # Github repository id
226
231
  $ lyp install noteflakes/lyp-package-template
227
232
  ```
228
233
 
229
- In addition, lyp also provides an [index of publically available package](https://github.com/noteflakes/lyp-index), which maps a package name to its URL (see also below). Using the index, packages are referenced by their published name instead of by their git URL:
234
+ In addition, lyp also provides an [index of publically available package](https://github.com/lyp-packages/index), which maps a package name to its URL (see also below). Using the index, packages are referenced by their published name instead of by their git URL:
230
235
 
231
236
  ```bash
232
237
  $ lyp install dummy
@@ -326,9 +331,18 @@ Lyp also defines a `lyp:load` scheme function for loading scheme files using rel
326
331
 
327
332
  Loading scheme files that way is a better technique than adding directorys to `%load-path`, because this way one avoids possible name clashes, which may lead to unexpected behavior.
328
333
 
334
+ ### Conditional includes
335
+
336
+ Files can also be included conditionally by evaluating a scheme expression using the `\pcondInclude` and `\pcondIncludeOnce` commands:
337
+
338
+ ```lilypond
339
+ % include edition-specific tweaks
340
+ \pcondInclude #(eq? edition 'urtext) "urtext_tweaks.ly"
341
+ ```
342
+
329
343
  ### Including fonts
330
344
 
331
- Lyp also supports automatic installation of fonts, based on work by [Abraham Leigh](https://github.com/tisimst). When a package is installed, lyp will copy any font files residing in the `fonts` directory into the corresponding `otf` and `svg` directories of all installed versions of lilypond.
345
+ Lyp also supports automatic installation of fonts, based on work by [Abraham Lee](https://github.com/tisimst). When a package is installed, lyp will copy any font files residing in the `fonts` directory into the corresponding `otf` and `svg` directories of all installed versions of lilypond.
332
346
 
333
347
  **Note**: fonts will be only installed in versions of lilypond starting from than 2.18.2. Lyp automatically patches any version ower than 2.19.12 in order to support custom fonts.
334
348
 
@@ -343,13 +357,13 @@ $ lyp test .
343
357
 
344
358
  A test file can either be a simple lilypond file which includes the package files and results in a lilypond score, or a lilypond file that performs unit tests on scheme code.
345
359
 
346
- For more information on testing, see the [lyp-assert](https://github.com/noteflakes/lyp-assert) package, which is meant to be used for unit testing lilypond code, and serves as an example of how to test a package.
360
+ For more information on testing, see the [lyp-assert](https://github.com/lyp-packages/assert) package, which is meant to be used for unit testing lilypond code, and serves as an example of how to test a package.
347
361
 
348
362
  ### Publishing packages
349
363
 
350
364
  In order for your package to be available to all users, you'll need to first push your code to a publically accessible git repository (for example on github). Users will then be able to install your package by using the git URL of the public repository.
351
365
 
352
- You can also add your package to the lyp [public package index](https://github.com/noteflakes/lyp-index), by cloning it, editing [index.yaml](https://github.com/noteflakes/lyp-index/blob/master/index.yaml), and creating a pull request.
366
+ You can also add your package to the lyp [public package index](https://github.com/lyp-packages/index), by cloning it, editing [index.yaml](https://github.com/lyp-packages/index/blob/master/index.yaml), and creating a pull request.
353
367
 
354
368
  ## Installing and Using Lilypond
355
369
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- LYP_VERSION="0.3.6"
3
+ LYP_VERSION="0.3.7"
4
4
  WORKDIR="/tmp/lyp-release-installer"
5
5
  URL_BASE="https://github.com/noteflakes/lyp/releases/download/v$LYP_VERSION"
6
6
 
@@ -25,6 +25,7 @@ LYP_LY_HELP = <<EOF
25
25
  Lyp-provided options:
26
26
  -E, --env use version specified in $LILYPOND_VERSION
27
27
  -n, --install install the specified version if not found
28
+ -O, --open open the target file after compilation
28
29
  -R, --raw run raw lilypond (no pre-processing)
29
30
  -r, --require=PACKAGE preload the specified package
30
31
  -u, --use=VERSION use the given version of lilypond
@@ -115,6 +115,25 @@
115
115
  (if (defined? '*parser*)
116
116
  (ly:parser-include-string str)
117
117
  (ly:parser-include-string parser str)))
118
+
119
+ (define (lyp:include parser location path once) (let* (
120
+ (current-dir (lyp:this-dir))
121
+ (abs-path (if (lyp:absolute-path? path)
122
+ path
123
+ (lyp:expand-path (lyp:join-path current-dir path))))
124
+ (included? (and once (hash-ref lyp:file-included? abs-path)))
125
+ )
126
+
127
+ (if (not included?) (begin
128
+ (ly:debug "include ~a\n" abs-path)
129
+ (if (not (file-exists? abs-path))
130
+ (throw 'lyp:failure "lyp:include"
131
+ (format "File not found ~a" abs-path) #f))
132
+
133
+ (hash-set! lyp:file-included? abs-path #t)
134
+ (lyp:include-string (lyp:fmt-include abs-path))
135
+ ))
136
+ ))
118
137
  )
119
138
 
120
139
  % command form
@@ -132,35 +151,15 @@ require = #(define-void-function (parser location ref)(string?) (let* (
132
151
  ))
133
152
  ))
134
153
 
135
- pinclude = #(define-void-function (parser location path)(string?) (let* (
136
- (current-dir (lyp:this-dir))
137
- (abs-path (if (lyp:absolute-path? path)
138
- path
139
- (lyp:expand-path (lyp:join-path current-dir path))))
140
- )
141
- (ly:debug "\\pinclude ~a\n" abs-path)
142
- (if (not (file-exists? abs-path))
143
- (throw 'lyp:failure "\\pinclude"
144
- (format "File not found ~a" abs-path) #f))
154
+ pinclude = #(define-void-function (parser location path)(string?)
155
+ (lyp:include parser location path #f))
145
156
 
146
- (hash-set! lyp:file-included? abs-path #t)
147
- (lyp:include-string (lyp:fmt-include abs-path))
148
- ))
157
+ pcondInclude = #(define-void-function (parser location expr path)(scheme? string?)
158
+ (if expr (lyp:include parser location path #f)))
149
159
 
150
- pincludeOnce = #(define-void-function (parser location path)(string?) (let* (
151
- (current-dir (lyp:this-dir))
152
- (abs-path (if (lyp:absolute-path? path)
153
- path
154
- (lyp:expand-path (lyp:join-path current-dir path))))
155
- (included? (hash-ref lyp:file-included? abs-path))
156
- )
157
- (if (not included?) (begin
158
- (ly:debug (format "\\pincludeOnce ~a\n" abs-path))
159
- (if (not (file-exists? abs-path))
160
- (throw 'lyp:failure "\\pincludeOnce"
161
- (format "File not found ~a" abs-path) #f))
160
+ pincludeOnce = #(define-void-function (parser location path)(string?)
161
+ (lyp:include parser location path #t))
162
+
163
+ pcondIncludeOnce = #(define-void-function (parser location path)(string?)
164
+ (if expr (lyp:include parser location path #t)))
162
165
 
163
- (hash-set! lyp:file-included? abs-path #t)
164
- (lyp:include-string (lyp:fmt-include abs-path))
165
- )
166
- )))
@@ -30,6 +30,8 @@ module Lyp::Lilypond
30
30
  options[:use_version] = $1
31
31
  when '-n', '--install'
32
32
  options[:install] = true
33
+ when '-O', '--open'
34
+ options[:open] = true
33
35
  else
34
36
  argv_clean << arg
35
37
  end
@@ -68,7 +70,7 @@ module Lyp::Lilypond
68
70
 
69
71
  def invoke(argv, opts = {})
70
72
  lilypond = current_lilypond
71
-
73
+
72
74
  case opts[:mode]
73
75
  when :system
74
76
  system("#{lilypond} #{argv.join(" ")}")
@@ -409,9 +411,9 @@ module Lyp::Lilypond
409
411
 
410
412
  def download_lilypond(url, fn, opts)
411
413
  require 'httpclient'
412
-
414
+
413
415
  STDERR.puts "Downloading #{url}" unless opts[:silent]
414
-
416
+
415
417
  download_count = 0
416
418
  client = HTTPClient.new
417
419
  conn = client.get_async(url)
@@ -669,8 +671,7 @@ module Lyp::Lilypond
669
671
  end
670
672
 
671
673
  def parse_error_msg(msg)
672
- (msg =~ /[^\n]+: error.+failed files: ".+"/m) ?
673
- $& : msg
674
+ (msg =~ /[^\n]+: error.+failed files: ".+"/m) ? $& : msg
674
675
  end
675
676
  end
676
677
  end
@@ -339,7 +339,7 @@ module Lyp::Package
339
339
  end
340
340
  end
341
341
 
342
- LYP_INDEX_URL = "https://raw.githubusercontent.com/noteflakes/lyp-index/master/index.yaml"
342
+ LYP_INDEX_URL = "https://raw.githubusercontent.com/lyp-packages/index/master/index.yaml"
343
343
 
344
344
  def search_lyp_index(package)
345
345
  entry = lyp_index['packages'][package]
@@ -447,14 +447,17 @@ module Lyp::Package
447
447
  # Runs all tests found in local directory
448
448
  def run_local_tests(dir, opts = {})
449
449
  package_dir = File.expand_path(dir)
450
- test_files = Dir["#{package_dir}/**/*_test.ly"]
451
450
  run_tests(opts) do |stats|
452
- test_files.each do |f|
451
+ find_test_files(package_dir).each do |f|
453
452
  perform_test(f, stats)
454
453
  end
455
454
  end
456
455
  end
457
456
 
457
+ def find_test_files(dir)
458
+ Dir["#{dir}/**/*_test.ly", "#{dir}/**/*-test.ly"]
459
+ end
460
+
458
461
  # This method runs tests by yielding the test statistics.
459
462
  # The caller should then call #perform_test to run each test file.
460
463
  def run_tests(opts = {})
@@ -493,7 +496,7 @@ module Lyp::Package
493
496
 
494
497
  run_tests(opts) do |stats|
495
498
  packages.each do |path|
496
- files = Dir["#{path}/**/*_test.ly"]
499
+ files = find_test_files(path)
497
500
  next if files.empty?
498
501
 
499
502
  FileUtils.cd(path) do
@@ -5,7 +5,11 @@ module Lyp
5
5
 
6
6
  INTERPOLATION_START = "{{".freeze
7
7
  INTERPOLATION_END = "}}".freeze
8
- INTERPOLATION_RE = /#{INTERPOLATION_START}((?:(?!#{INTERPOLATION_END}).)*)#{INTERPOLATION_END}/m
8
+ INTERPOLATION_RE = /#{INTERPOLATION_START}([^\?\/](?:(?!#{INTERPOLATION_END}).)*)#{INTERPOLATION_END}/m
9
+
10
+ IF_START = "{{?".freeze
11
+ IF_END = "{{/}}".freeze
12
+ IF_RE = /\{\{\?((?:(?!#{INTERPOLATION_END}).)*)#{INTERPOLATION_END}((?:(?!#{IF_END}).)*)#{IF_END}/m
9
13
 
10
14
  ESCAPED_QUOTE = '\\"'.freeze
11
15
  QUOTE = '"'.freeze
@@ -30,13 +34,27 @@ EOF
30
34
 
31
35
  metaclass.instance_eval method_str
32
36
  end
33
-
37
+
38
+ def convert_interpolation(s)
39
+ s.gsub(INTERPOLATION_RE) do
40
+ code = $1.gsub(ESCAPED_QUOTE, QUOTE)
41
+ "\#{#{code}}"
42
+ end
43
+ end
44
+
34
45
  def convert_literal(s)
35
46
  # look for interpolated values, wrap them with #{}
36
47
  s = s.inspect.gsub(INTERPOLATION_RE) do
37
48
  code = $1.gsub(ESCAPED_QUOTE, QUOTE)
38
49
  "\#{#{code}}"
39
50
  end
51
+
52
+ s = s.gsub(IF_RE) do
53
+ test, code = $1, $2
54
+ test = test.strip.gsub(ESCAPED_QUOTE, QUOTE)
55
+ "\#\{if #{test}; \"#{code}\"; end}"
56
+ end
57
+
40
58
  "__emit__[#{s}]"
41
59
  end
42
60
 
@@ -66,5 +66,6 @@ end
66
66
 
67
67
  `
68
68
  \include {{quote_path[user_filename]}}
69
- `
70
69
 
70
+ #(if (defined? 'assert:summary) (assert:summary))
71
+ `
@@ -1,3 +1,3 @@
1
1
  module Lyp
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
@@ -10,6 +10,7 @@ module Lyp
10
10
 
11
11
  # copy current_package_dir option
12
12
  r[:current_package_dir] = opts[:current_package_dir]
13
+ r[:opts] = opts
13
14
 
14
15
  FileUtils.mkdir_p("#{Lyp::TMP_ROOT}/wrappers")
15
16
  fn = "#{Lyp::TMP_ROOT}/wrappers/#{File.basename(fn)}"
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.6
4
+ version: 0.3.7
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-03-08 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.5.1
137
+ rubygems_version: 2.4.8
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: Lyp is a package manager for lilypond