lyp 0.3.9 → 1.0.0
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.rb +1 -0
- data/lib/lyp/cli.rb +13 -0
- data/lib/lyp/etc/lyp.ly +11 -12
- data/lib/lyp/transform.rb +30 -0
- 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: 54f90b19cc9702e07d9ea91f39cbb731b4160eca
|
4
|
+
data.tar.gz: ad54101546c7cfe1dbb9e5557d37a0cf39406b1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 579e5add9981c4fd1ad281e030e3b5fdffd2a3f51f4d0f81886ea1ab95a49bd92550619fa31a73f6d4987c4c3cf2d5e1ea7b2952363b6ca20440b5db977819c2
|
7
|
+
data.tar.gz: b3dd8a3af50d2120d5803fe33faacb90f9f7703fa38864d3cbc2ab0a296c0c141a3cd95bb7e3f8ccd288cd39a1284575f1a3472a40a5bce640bf6658078f419f
|
data/bin/install_release.sh
CHANGED
data/lib/lyp.rb
CHANGED
data/lib/lyp/cli.rb
CHANGED
@@ -306,6 +306,19 @@ class Lyp::CLI < Thor
|
|
306
306
|
end
|
307
307
|
end
|
308
308
|
|
309
|
+
desc "flatten FILE", "Flatten a file and included files into a single output file"
|
310
|
+
def flatten(input_path, output_path = nil)
|
311
|
+
input_path = File.expand_path(input_path)
|
312
|
+
output_path = File.expand_path(output_path) if output_path
|
313
|
+
flat = Lyp::Transform.flatten(input_path)
|
314
|
+
if output_path
|
315
|
+
File.open(output_path, 'w+') {|f| f << flat}
|
316
|
+
else
|
317
|
+
puts flat
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
|
309
322
|
def self.run
|
310
323
|
start(ARGV)
|
311
324
|
rescue => e
|
data/lib/lyp/etc/lyp.ly
CHANGED
@@ -77,8 +77,8 @@
|
|
77
77
|
(format "Invalid package name ~a" ref) #f))
|
78
78
|
))
|
79
79
|
|
80
|
-
; Because the *location* in lilypond is kinda broken (it becomes unusable
|
81
|
-
; when using nested includes, even in > 2.19.22, we provide an alternative
|
80
|
+
; Because the *location* in lilypond is kinda broken (it becomes unusable
|
81
|
+
; when using nested includes, even in > 2.19.22, we provide an alternative
|
82
82
|
; for keeping track of the current file, and thus be able to include files
|
83
83
|
; using relative path names (relative to the current file).
|
84
84
|
(define lyp:last-this-file #f)
|
@@ -105,17 +105,17 @@
|
|
105
105
|
(define (lyp:fmt-include path)
|
106
106
|
(format "#(set! lyp:last-this-file \"~A\")\n\\include \"~A\"\n#(set! lyp:last-this-file \"~A\")\n"
|
107
107
|
path path (lyp:this-file)))
|
108
|
-
|
108
|
+
|
109
109
|
(define (lyp:fmt-require entry-point-path package-dir)
|
110
110
|
(format "#(set! lyp:current-package-dir \"~A\")\n~A#(set! lyp:current-package-dir \"~A\")\n"
|
111
111
|
package-dir (lyp:fmt-include entry-point-path) lyp:current-package-dir))
|
112
|
-
|
112
|
+
|
113
113
|
; helper function to cover API changes from 2.18 to 2.19
|
114
114
|
(define (lyp:include-string str)
|
115
115
|
(if (defined? '*parser*)
|
116
116
|
(ly:parser-include-string str)
|
117
117
|
(ly:parser-include-string parser str)))
|
118
|
-
|
118
|
+
|
119
119
|
(define (lyp:include parser location path once) (let* (
|
120
120
|
(current-dir (lyp:this-dir))
|
121
121
|
(abs-path (if (lyp:absolute-path? path)
|
@@ -123,7 +123,7 @@
|
|
123
123
|
(lyp:expand-path (lyp:join-path current-dir path))))
|
124
124
|
(included? (and once (hash-ref lyp:file-included? abs-path)))
|
125
125
|
)
|
126
|
-
|
126
|
+
|
127
127
|
(if (not included?) (begin
|
128
128
|
(ly:debug "include ~a\n" abs-path)
|
129
129
|
(if (not (file-exists? abs-path))
|
@@ -146,20 +146,19 @@ require = #(define-void-function (parser location ref)(string?) (let* (
|
|
146
146
|
(if (not loaded?) (begin
|
147
147
|
(ly:debug "Loading package ~a at ~a" name package-dir)
|
148
148
|
(hash-set! lyp:package-loaded? name #t)
|
149
|
-
|
149
|
+
|
150
150
|
(lyp:include-string (lyp:fmt-require entry-point-path package-dir))
|
151
151
|
))
|
152
152
|
))
|
153
|
-
|
154
|
-
pinclude = #(define-void-function (parser location path)(string?)
|
153
|
+
|
154
|
+
pinclude = #(define-void-function (parser location path)(string?)
|
155
155
|
(lyp:include parser location path #f))
|
156
156
|
|
157
157
|
pcondInclude = #(define-void-function (parser location expr path)(scheme? string?)
|
158
158
|
(if expr (lyp:include parser location path #f)))
|
159
159
|
|
160
|
-
pincludeOnce = #(define-void-function (parser location path)(string?)
|
160
|
+
pincludeOnce = #(define-void-function (parser location path)(string?)
|
161
161
|
(lyp:include parser location path #t))
|
162
162
|
|
163
|
-
pcondIncludeOnce = #(define-void-function (parser location path)(string?)
|
163
|
+
pcondIncludeOnce = #(define-void-function (parser location expr path)(scheme? string?)
|
164
164
|
(if expr (lyp:include parser location path #t)))
|
165
|
-
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Lyp::Transform
|
4
|
+
class << self
|
5
|
+
R = Lyp::DependencyResolver
|
6
|
+
|
7
|
+
def flatten(path, ctx = {})
|
8
|
+
ctx[path] = true
|
9
|
+
|
10
|
+
dir = File.dirname(path)
|
11
|
+
src = IO.read(path)
|
12
|
+
|
13
|
+
src.gsub(R::DEP_RE) do
|
14
|
+
inc_path = File.expand_path($2, dir)
|
15
|
+
case $1
|
16
|
+
when R::INCLUDE, R::PINCLUDE
|
17
|
+
"\n%%% #{inc_path}\n#{flatten(inc_path, ctx)}\n"
|
18
|
+
when R::PINCLUDE_ONCE
|
19
|
+
if ctx[inc_path]
|
20
|
+
""
|
21
|
+
else
|
22
|
+
"\n%%% #{inc_path}\n#{flatten(inc_path, ctx)}\n"
|
23
|
+
end
|
24
|
+
else
|
25
|
+
$~
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
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.
|
4
|
+
version: 1.0.0
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/lyp/system.rb
|
112
112
|
- lib/lyp/template.rb
|
113
113
|
- lib/lyp/templates/deps_wrapper.rb
|
114
|
+
- lib/lyp/transform.rb
|
114
115
|
- lib/lyp/version.rb
|
115
116
|
- lib/lyp/windows.rb
|
116
117
|
- lib/lyp/wrapper.rb
|