lyp-win 1.3.4 → 1.3.5

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: 4bdde7892b2da60d4c3c57e0f4f7bc2c64138f31
4
- data.tar.gz: 632d9e270522c741b6d415d6e988fe80b621251c
3
+ metadata.gz: 3697173d85f0c79b8d561bfe268d0a0510795188
4
+ data.tar.gz: a2eb68573dda67d1156fe881ad639708b2d2dc86
5
5
  SHA512:
6
- metadata.gz: 3c87eaf0dde371904971772628fc971914cda3bbc4401809b7eed00fd8747c8e2100946767f6962f407111fe42578e0ee7f40100943eba5d23432561861fe4bf
7
- data.tar.gz: 27b720a6fc0c1db76f859e8ba7178749e66d8cde097f21f6d28d519cad49769a265afb5b53a1c63af3ad2a151a5292ae89075431df86d36321ed0e199993633d
6
+ metadata.gz: 7d763075113f6cc130927168ce8eea57646574f1373db1cb79963f27cbe46af6851b2197464069f4f35b215d8571fcf8e6558701fbfa1709da9f28bf186f28d1
7
+ data.tar.gz: d85896d55f2e5c1ee7ec7bd2bf5f9cb50ae61b6e2cd2d3901ce1655378625342825cd6e86ca62631ebeb1dbbd37bb8292e090e0f405fdaf08b416417a8c2178a
data/bin/lilypond CHANGED
@@ -27,10 +27,11 @@ Lyp-provided options:
27
27
  -c, --cropped crop output (requires setting 0 margins)
28
28
  -E, --env use version specified in $LILYPOND_VERSION
29
29
  -F, --force-version use lilypond version specified in user file
30
+ -m, --music-relative=MUSIC enter music inline (relative pitch)
31
+ -M, --music=MUSIC enter music inline (absolute pitch)
30
32
  -n, --install install the specified version if not found
31
- -O, --open open the target file after compilation
32
- -R, --raw run raw lilypond (no pre-processing)
33
33
  -r, --require=PACKAGE preload the specified package
34
+ -R, --raw run raw lilypond (no pre-processing)
34
35
  -S, --snippet produce png cropped images at 600dpi
35
36
  (--cropped --png -dresolution=600)
36
37
  -u, --use=VERSION use the given version of lilypond
@@ -59,6 +60,6 @@ else
59
60
  Lyp::Lilypond.compile($argv, $options)
60
61
  rescue => e
61
62
  puts e.message
62
- puts e.backtrace.join("\n")
63
+ puts e.backtrace.join("\n") if $options[:verbose]
63
64
  end
64
65
  end
data/lib/lyp/base.rb CHANGED
@@ -62,6 +62,11 @@ module Lyp
62
62
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
63
63
  dir
64
64
  end
65
+
66
+ def self.tmp_filename(suffix = nil)
67
+ fn = (Thread.current.hash * (Time.now.to_f * 1000).to_i % 2**32).to_s(36)
68
+ "#{TMP_ROOT}/#{fn}#{suffix}"
69
+ end
65
70
 
66
71
  def self.sudo_cp(src, dest)
67
72
  cmd = "sudo cp #{src} #{dest}"
data/lib/lyp/cli.rb CHANGED
@@ -128,6 +128,8 @@ class Lyp::CLI < Thor
128
128
  desc "compile [<option>...] <FILE>", "compile given file Lilypond source file"
129
129
  def compile(*argv)
130
130
  opts, argv = Lyp::Lilypond.preprocess_argv(argv)
131
+ opts[:verbose] ||= options[:verbose]
132
+ $cmd_options = opts
131
133
 
132
134
  lilypond_path = Lyp::Lilypond.select_lilypond_version(opts, argv.last)
133
135
 
data/lib/lyp/lilypond.rb CHANGED
@@ -1,7 +1,14 @@
1
1
  module Lyp::Lilypond
2
2
  class << self
3
- NO_ARGUMENT_OPTIONS_REGEXP = /^\-([REnFOcSA]+)(.+)/
3
+ # multiple options in shorthand form, e.g. -FnO
4
+ NO_ARGUMENT_SHORTHAND_REGEXP = /^\-([AcEFnRSV]+)(.+)/
4
5
 
6
+ # shorthand option with argument, e.g. -ifoo-bar.ly
7
+ ARGUMENT_SHORTHAND_REGEXP = /^\-([efHiIjlmMoru])(.+)/
8
+
9
+ # longhand option with equal sign and argument, e.g. --include=foo/bar
10
+ ARGUMENT_EQUAL_REGEXP = /^--([^=]+)=(.+)/
11
+
5
12
  def preprocess_argv(argv)
6
13
  options = {}
7
14
  argv = argv.dup # copy for iterating
@@ -15,20 +22,22 @@ module Lyp::Lilypond
15
22
 
16
23
  def parse_lilypond_arg(arg, argv, argv_clean, options)
17
24
  case arg
18
- when NO_ARGUMENT_OPTIONS_REGEXP
19
- # handle multiple options in shorthand form, e.g. -FnO
25
+ when ARGUMENT_EQUAL_REGEXP
26
+ argv.insert(0, "--#{$1}", $2)
27
+ when ARGUMENT_SHORTHAND_REGEXP
28
+ argv.insert(0, "-#{$1}", $2)
29
+ when NO_ARGUMENT_SHORTHAND_REGEXP
20
30
  tmp_args = []
21
31
  $1.each_char {|c| tmp_args << "-#{c}"}
22
32
  tmp_args << "-#{$2}"
23
- argv = tmp_args + argv
33
+ argv.insert(0, *tmp_args)
24
34
  when '-A', '--auto-install-deps'
25
35
  options[:resolve] = true
26
36
  when '-c', '--cropped'
27
37
  argv_clean.concat ['-dbackend=eps', '-daux-files=#f']
28
38
  when '-E', '--env'
29
39
  unless ENV['LILYPOND_VERSION']
30
- STDERR.puts "$LILYPOND_VERSION not set"
31
- exit 1
40
+ raise "$LILYPOND_VERSION not set"
32
41
  end
33
42
  options[:use_version] = ENV['LILYPOND_VERSION']
34
43
  when '-F', '--force-version'
@@ -38,10 +47,14 @@ module Lyp::Lilypond
38
47
  options[:include_paths] ||= []
39
48
  options[:include_paths] << path
40
49
  argv_clean << "--include=#{path}"
50
+ when '-M', '--music'
51
+ fn = prepare_inline_music_file(argv.shift)
52
+ argv << fn
53
+ when '-m', '--music-relative'
54
+ fn = prepare_inline_music_file(argv.shift, relative: true)
55
+ argv << fn
41
56
  when '-n', '--install'
42
57
  options[:install] = true
43
- when '-O', '--open'
44
- options[:open] = true
45
58
  when '-r', '--require'
46
59
  options[:ext_require] ||= []
47
60
  options[:ext_require] << argv.shift
@@ -55,17 +68,36 @@ module Lyp::Lilypond
55
68
  options[:snippet_paper_preamble] = true
56
69
  when '-u', '--use'
57
70
  options[:use_version] = argv.shift
58
- when /^(?:\-u|\-\-use\=)"?([^\s]+)"?/
59
- options[:use_version] = $1
71
+ when '-V', '--verbose'
72
+ options[:verbose] = true
73
+ argv_clean << arg
60
74
  when '--invoke-system'
61
75
  options[:mode] = :system
62
76
  when '--invoke-quiet'
63
77
  options[:mode] = :quiet
78
+ when '--svg'
79
+ argv_clean.concat ['-dbackend=svg']
64
80
  else
65
81
  argv_clean << arg
66
82
  end
67
83
  end
68
84
 
85
+ def prepare_inline_music_file(music, opts = {})
86
+ filename = Lyp.tmp_filename('.ly')
87
+ File.open(filename, 'w+') do |f|
88
+ f << format_inline_music(music, opts)
89
+ end
90
+ filename
91
+ end
92
+
93
+ def format_inline_music(music, opts)
94
+ if opts[:relative]
95
+ "\\relative c' { #{music} }"
96
+ else
97
+ "{ #{music} }"
98
+ end
99
+ end
100
+
69
101
  VERSION_STATEMENT_REGEX = /\\version "([^"]+)"/
70
102
 
71
103
  def select_lilypond_version(opts, file_path)
data/lib/lyp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lyp
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  end
data/lib/lyp/wrapper.rb CHANGED
@@ -3,14 +3,16 @@ module Lyp
3
3
  File.expand_path('templates/deps_wrapper.rb', File.dirname(__FILE__))
4
4
  ))
5
5
 
6
+ WRAPPERS_DIR = "#{Lyp::TMP_ROOT}/wrappers"
7
+
6
8
  def self.wrap(fn, opts = {})
7
9
  r = Lyp::DependencyResolver.new(fn, opts).resolve_package_dependencies
8
10
  # copy current_package_dir option
9
11
  r[:current_package_dir] = opts[:current_package_dir]
10
12
  r[:opts] = opts
11
13
 
12
- FileUtils.mkdir_p("#{Lyp::TMP_ROOT}/wrappers")
13
- fn = "#{Lyp::TMP_ROOT}/wrappers/#{File.basename(fn)}"
14
+ FileUtils.mkdir_p(WRAPPERS_DIR)
15
+ fn = "#{WRAPPERS_DIR}/#{File.basename(fn)}"
14
16
 
15
17
  File.open(fn, 'w+') {|f| f << WRAPPER_TEMPLATE.render(r)}
16
18
 
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: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-09 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -115,7 +115,7 @@ files:
115
115
  - lib/lyp/version.rb
116
116
  - lib/lyp/windows.rb
117
117
  - lib/lyp/wrapper.rb
118
- homepage: http://github.com/noteflakes/lyp
118
+ homepage: http://lyp.noteflakes.com
119
119
  licenses:
120
120
  - MIT
121
121
  metadata: {}