lyp-win 1.3.2 → 1.3.3

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: 2658b2c6b915cfcb4aea08d0c7a7297eacff23d2
4
- data.tar.gz: 6d21e73c9255593957c147c553601f808e0a9170
3
+ metadata.gz: 534ac9d88a77c484848182c3e3afaf7e7218b6a7
4
+ data.tar.gz: b1174d32d32e5cea1188e8bdb541ee6abdeb5625
5
5
  SHA512:
6
- metadata.gz: 138b589dbbe5d989782bf2dc9309ea946196101f72d8845ee6c86b1c4ed3e762fa4b780476a31f9b55aa5dc5d52599e565108a545501cdcf41f0ebdb4f9af64c
7
- data.tar.gz: 2b9f8378409264e79bd77f88caccde271697cb33b628fcf700eca698753a067046b112b24208c8d7fd2c35a216de28968dc85f1b8987fd2f51696ce6d214813b
6
+ metadata.gz: f3f7f1f4138f391723cc5b79f045101c99aa189b365a535ed7065b8e99e2950eb00fa18c498ccc78bd95f60f8aa6ddc6c783cede0e60c7756a7cbd779875e8db
7
+ data.tar.gz: a9c51b25bf4975211790f3b300f6e6e4e6166fc3e5319c632f5fdbeeb6a3bcb1771c7eb7b7b809c6fc5ddc2b818af02e684b1d1d6cbe1dcb5572ca5c1022cbe6
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 FILE`
670
+ Synopsis: `lyp flatten SOURCE [DEST]`
671
671
 
672
- Flattens a source file and all included files into a single file.
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
- flat = Lyp::Transform.flatten(input_path)
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, ctx = {})
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
- "\n%%% #{inc_path}\n#{flatten(inc_path, ctx)}\n"
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#{flatten(inc_path, ctx)}\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
@@ -1,3 +1,3 @@
1
1
  module Lyp
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lyp-win
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
@@ -84,7 +84,7 @@ dependencies:
84
84
  - - '='
85
85
  - !ruby/object:Gem::Version
86
86
  version: 1.5.1
87
- description: Lyp is a tool for managing lilypond versions and lilypond packages
87
+ description: Lyp is a tool for installing lilypond and managing lilypond packages
88
88
  email: ciconia@gmail.com
89
89
  executables:
90
90
  - lyp
@@ -138,5 +138,5 @@ rubyforge_project:
138
138
  rubygems_version: 2.4.8
139
139
  signing_key:
140
140
  specification_version: 4
141
- summary: Lyp is a package manager for lilypond
141
+ summary: Lyp - the Lilypond swiss army knife
142
142
  test_files: []