lyp 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/lyp/cli.rb +12 -1
- data/lib/lyp/transform.rb +22 -4
- data/lib/lyp/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 654943599c1e011b73e51d186010d132ac97a03e
|
4
|
+
data.tar.gz: 8d0f985da871d897a7b656ee7378cbd2d150a46b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12821c5fa6ba1663b5a81e13a03e84945a8dcfebe468fbbda42b65c360836959d29e7fe71387be79f8aa40796357ec74dfde2f9d7040dd1a4a0a7d29618d8233
|
7
|
+
data.tar.gz: 18aa2c71a8f340ed07fa61595bf4c315a5b9183d46d6be0776961888662536c553145ff037bde260e6ff1874af9b0604bcc003a3b31cbb498fd8f169ad5ea1f5
|
data/README.md
CHANGED
@@ -667,9 +667,9 @@ Runs a Lilypond script (using the currently selected version of Lilypond).
|
|
667
667
|
|
668
668
|
### lyp flatten
|
669
669
|
|
670
|
-
Synopsis: `lyp flatten
|
670
|
+
Synopsis: `lyp flatten SOURCE [DEST]`
|
671
671
|
|
672
|
-
Flattens
|
672
|
+
Flattens the given input file at `SOURCE` and all included files into a single file to be written to `DEST`. If `DEST` is not specified, the file is written to `STDOUT`.
|
673
673
|
|
674
674
|
### lyp install
|
675
675
|
|
data/lib/lyp/cli.rb
CHANGED
@@ -160,10 +160,21 @@ class Lyp::CLI < Thor
|
|
160
160
|
end
|
161
161
|
|
162
162
|
desc "flatten FILE", "Flatten a file and included files into a single output file"
|
163
|
+
method_option :include, aliases: '-I', type: :string, desc: 'Add to include search path'
|
163
164
|
def flatten(input_path, output_path = nil)
|
164
165
|
input_path = File.expand_path(input_path)
|
165
166
|
output_path = File.expand_path(output_path) if output_path
|
166
|
-
|
167
|
+
|
168
|
+
|
169
|
+
opts = {include_paths: []}
|
170
|
+
if options[:include]
|
171
|
+
opts[:include_paths] << options[:include]
|
172
|
+
end
|
173
|
+
if Lyp::Lilypond.current_lilypond
|
174
|
+
opts[:include_paths] << Lyp::Lilypond.current_lilypond_include_path
|
175
|
+
end
|
176
|
+
|
177
|
+
flat = Lyp::Transform.flatten(input_path, opts)
|
167
178
|
if output_path
|
168
179
|
File.open(output_path, 'w+') {|f| f << flat}
|
169
180
|
else
|
data/lib/lyp/transform.rb
CHANGED
@@ -2,27 +2,45 @@ module Lyp::Transform
|
|
2
2
|
class << self
|
3
3
|
R = Lyp::DependencyResolver
|
4
4
|
|
5
|
-
def flatten(path,
|
5
|
+
def flatten(path, opts = {})
|
6
|
+
resolver = Lyp::DependencyResolver.new(path, opts)
|
7
|
+
flatten_file(path, opts)
|
8
|
+
end
|
9
|
+
|
10
|
+
def flatten_file(path, opts, ctx = {})
|
6
11
|
ctx[path] = true
|
7
12
|
|
8
13
|
dir = File.dirname(path)
|
9
14
|
src = IO.read(path)
|
10
15
|
|
11
16
|
src.gsub(R::DEP_RE) do
|
12
|
-
inc_path = File.expand_path($2, dir)
|
13
17
|
case $1
|
14
18
|
when R::INCLUDE, R::PINCLUDE
|
15
|
-
|
19
|
+
inc_path = find_include_file($2, dir, opts, path)
|
20
|
+
"\n%%% #{inc_path}\n#{flatten_file(inc_path, opts, ctx)}\n"
|
16
21
|
when R::PINCLUDE_ONCE
|
22
|
+
inc_path = find_include_file($2, dir, opts, path)
|
17
23
|
if ctx[inc_path]
|
18
24
|
""
|
19
25
|
else
|
20
|
-
"\n%%% #{inc_path}\n#{
|
26
|
+
"\n%%% #{inc_path}\n#{flatten_file(inc_path, opts, ctx)}\n"
|
21
27
|
end
|
22
28
|
else
|
23
29
|
$~
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
33
|
+
|
34
|
+
def find_include_file(ref, dir, opts, source_path)
|
35
|
+
search_paths = [dir]
|
36
|
+
search_paths += opts[:include_paths] if opts[:include_paths]
|
37
|
+
|
38
|
+
search_paths.each do |path|
|
39
|
+
full_path = File.expand_path(ref, path)
|
40
|
+
return full_path if File.file?(full_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
raise "Missing include file #{ref} specified in #{source_path}"
|
44
|
+
end
|
27
45
|
end
|
28
46
|
end
|
data/lib/lyp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lyp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
- - '='
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 1.5.1
|
101
|
-
description: Lyp is a tool for
|
101
|
+
description: Lyp is a tool for installing lilypond and managing lilypond packages
|
102
102
|
email: ciconia@gmail.com
|
103
103
|
executables:
|
104
104
|
- lyp
|
@@ -152,5 +152,5 @@ rubyforge_project:
|
|
152
152
|
rubygems_version: 2.4.8
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
|
-
summary: Lyp
|
155
|
+
summary: Lyp - the Lilypond swiss army knife
|
156
156
|
test_files: []
|