lyp-win 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c46b9613b42c79a59f83c26808a0027d7e384503
4
- data.tar.gz: 4e47b76bf8c56b7493b19f26e1ccad8d0ffce5ac
3
+ metadata.gz: 6287c0b51e3557916d828be45beb7202755eece1
4
+ data.tar.gz: c18f29783c78a749c03c60f508439a0fe789de5a
5
5
  SHA512:
6
- metadata.gz: caab1ccb0de4c9c399ddc856df9b70c661b567f610f81278245750c27854a0878d98726b3bde0f83b5a391ef406efe074484d0038fde5168e0ae3e3dbfcd728a
7
- data.tar.gz: d74d7f3e4a9d15a11ed6abc21872c2f2b598fe3e271738023d818b01607f2033dec19aeb284738e5a9cf3150ada00a6f0bdca34c7cad8558d4979d59132eb01d
6
+ metadata.gz: 6a82be4ccfe9549f26495c8501cade265c16e67746d31c842b02d6e3b27a337c7789e3798cdbf65aec36ce10ed178f0f6e81dd33f244c1f2327671f2c3073b07
7
+ data.tar.gz: 527692ac8d475dbede87df0faa88628a7b6bf5eb2628c0881870cd769ce0ca5c3746690266f45dc6586be6d6014023cbd6cea87a01a7f0e99a83e00398a986be
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- LYP_VERSION="0.3.9"
3
+ LYP_VERSION="1.0.0"
4
4
  WORKDIR="/tmp/lyp-release-installer"
5
5
  URL_BASE="https://github.com/noteflakes/lyp/releases/download/v$LYP_VERSION"
6
6
 
data/lib/lyp.rb CHANGED
@@ -9,5 +9,6 @@ req 'resolver'
9
9
  req 'wrapper'
10
10
  req 'package'
11
11
  req 'lilypond'
12
+ req 'transform'
12
13
 
13
14
  req 'windows' if Lyp::WINDOWS
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Lyp
2
- VERSION = "0.3.9"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lyp-win
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
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-27 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -97,6 +97,7 @@ files:
97
97
  - lib/lyp/system.rb
98
98
  - lib/lyp/template.rb
99
99
  - lib/lyp/templates/deps_wrapper.rb
100
+ - lib/lyp/transform.rb
100
101
  - lib/lyp/version.rb
101
102
  - lib/lyp/windows.rb
102
103
  - lib/lyp/wrapper.rb