lyp-win 1.0.3 → 1.1.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: 979d491adba337cb2ee7c67181ebdfb23a64ace4
4
- data.tar.gz: 97da159cbed5589c1c5049581dabf8c829f8301c
3
+ metadata.gz: 4e38dff76bd4d1a439152bfa2feae4ba5af4ad16
4
+ data.tar.gz: 9b411863056ece14eeead97aa5966e17e24d432e
5
5
  SHA512:
6
- metadata.gz: 86ea03b988790093556d2ea5303aabf0e56f1b097f3e0afd99163a0a4ded8e8e7cc48e610dfe0fce1708d1edb6f695e015b1b6bd7cf30051f9f043b23500d0c5
7
- data.tar.gz: 62c0296ad688312460f8a097c3feff5abb827aafa00fef673501b7cb71b4c73ebae01aa55213e7f3a43129800716521b6c2ee27fdfc865386ae00c0022fc72f8
6
+ metadata.gz: 226b0270fe3e1ad54851bd872d8af0c16ca2ee1270fe1f24df065b0f4b6eee2028bcd521c08dc03463223ae8ad1dbf88e85fb5e2d012182468eb253f6a5180cf
7
+ data.tar.gz: eb02d6b9696ea5ba3bf6d1309dd20bb43e1543e14f32337886bc1e57af2e7b7c8b033d1b2d7476c26d3176f755b6484f880eb2ff64893d4b6f528d0bc6f97cfa
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- LYP_VERSION="1.0.3"
3
+ LYP_VERSION="1.1.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/cli.rb CHANGED
@@ -111,7 +111,7 @@ class Lyp::CLI < Thor
111
111
  end
112
112
 
113
113
  desc "test [<option>...] [.|PATTERN]", "Runs package tests on installed packages or local directory"
114
- method_option :install, aliases: '-n', type: :boolean, desc: 'Install the requested version of lilypond if not present'
114
+ method_option :install, aliases: '-n', type: :boolean, desc: 'Install the requested version of Lilypond if not present'
115
115
  method_option :env, aliases: '-E', type: :boolean, desc: 'Use version set by LILYPOND_VERSION environment variable'
116
116
  method_option :use, aliases: '-u', type: :string, desc: 'Use specified version'
117
117
  def test(*args)
@@ -144,10 +144,11 @@ class Lyp::CLI < Thor
144
144
  end
145
145
  end
146
146
 
147
- desc "install <PACKAGE|lilypond|self>...", "Install a package or a version of lilypond. When 'install self' is invoked, lyp installs itself in ~/.lyp."
148
- method_option :default, aliases: '-d', type: :boolean, desc: 'Set default lilypond version'
147
+ desc "install <PACKAGE|lilypond|self>...", "Install a package or a version of Lilypond. When 'install self' is invoked, lyp installs itself in ~/.lyp."
148
+ method_option :default, aliases: '-d', type: :boolean, desc: 'Set default Lilypond version'
149
149
  method_option :test, aliases: '-t', type: :boolean, desc: 'Run package tests after installation'
150
150
  method_option :dev, type: :boolean, desc: 'Install local development package'
151
+ method_option :update, aliases: '-u', type: :boolean, desc: 'Remove any old versions of the package'
151
152
  def install(*args)
152
153
  $cmd_options = options
153
154
 
@@ -175,7 +176,14 @@ class Lyp::CLI < Thor
175
176
  end
176
177
  end
177
178
 
178
- desc "uninstall <PACKAGE|lilypond|self>...", "Uninstall a package or a version of lilypond. When 'uninstall self' is invoked, lyp uninstalls itself from ~/.lyp."
179
+ desc "update <PACKAGE>...", "Install a package after removing all previous versions"
180
+ method_option :default, aliases: '-d', type: :boolean, desc: 'Set default Lilypond version'
181
+ method_option :test, aliases: '-t', type: :boolean, desc: 'Run package tests after installation'
182
+ def update(*args)
183
+ invoke 'install', args, options.merge(update: true)
184
+ end
185
+
186
+ desc "uninstall <PACKAGE|lilypond|self>...", "Uninstall a package or a version of Lilypond. When 'uninstall self' is invoked, lyp uninstalls itself from ~/.lyp."
179
187
  method_option :all, aliases: '-a', type: :boolean, desc: 'Uninstall all versions'
180
188
  def uninstall(*args)
181
189
  $cmd_options = options
@@ -197,8 +205,8 @@ class Lyp::CLI < Thor
197
205
  end
198
206
  end
199
207
 
200
- desc "use [lilypond@]<VERSION>", "Switch version of lilypond"
201
- method_option :default, aliases: '-d', type: :boolean, desc: 'Set default lilypond version'
208
+ desc "use [lilypond@]<VERSION>", "Switch version of Lilypond"
209
+ method_option :default, aliases: '-d', type: :boolean, desc: 'Set default Lilypond version'
202
210
  def use(version)
203
211
  $cmd_options = options
204
212
 
@@ -209,10 +217,10 @@ class Lyp::CLI < Thor
209
217
  end
210
218
 
211
219
  lilypond = Lyp::Lilypond.use(version, options)
212
- puts "Using lilypond version #{lilypond[:version]}"
220
+ puts "Using Lilypond version #{lilypond[:version]}"
213
221
  end
214
222
 
215
- desc "list [PATTERN|lilypond]", "List installed packages matching PATTERN or versions of lilypond"
223
+ desc "list [PATTERN|lilypond]", "List installed packages matching PATTERN or versions of Lilypond"
216
224
  def list(pattern = nil)
217
225
  $cmd_options = options
218
226
 
@@ -249,7 +257,7 @@ class Lyp::CLI < Thor
249
257
  end
250
258
  end
251
259
 
252
- desc "which [PATTERN|lilypond]", "List locations of installed packages matching PATTERN or versions of lilypond"
260
+ desc "which [PATTERN|lilypond]", "List locations of installed packages matching PATTERN or versions of Lilypond"
253
261
  def which(pattern = nil)
254
262
  $cmd_options = options
255
263
 
data/lib/lyp/lilypond.rb CHANGED
@@ -1,7 +1,3 @@
1
- require 'uri'
2
- require 'open3'
3
- require 'ruby-progressbar'
4
-
5
1
  module Lyp::Lilypond
6
2
  class << self
7
3
  NO_ARGUMENT_OPTIONS_REGEXP = /^\-([REnFOcSA]+)(.+)/
@@ -208,10 +204,14 @@ module Lyp::Lilypond
208
204
  end
209
205
 
210
206
  def get_session_settings
211
- YAML.load(IO.read(session_settings_filename)) rescue {}
207
+ req_ext('yaml')
208
+ settings = YAML.load(IO.read(session_settings_filename)) rescue {}
209
+ settings = {} unless settings.is_a?(Hash)
210
+ settings
212
211
  end
213
212
 
214
213
  def set_session_settings(settings)
214
+ req_ext('yaml')
215
215
  File.open(session_settings_filename, 'w+') do |f|
216
216
  f << YAML.dump(settings)
217
217
  end
@@ -314,7 +314,7 @@ module Lyp::Lilypond
314
314
 
315
315
  # Returns a list of versions of lilyponds available for download
316
316
  def search(version_specifier = nil)
317
- require 'open-uri'
317
+ req_ext 'open-uri'
318
318
 
319
319
  platform = detect_lilypond_platform
320
320
  url = "#{BASE_URL}/#{platform}/"
@@ -452,12 +452,14 @@ module Lyp::Lilypond
452
452
  end
453
453
 
454
454
  def temp_install_filename(url)
455
+ req_ext('uri')
455
456
  u = URI(url)
456
457
  "#{Lyp::TMP_ROOT}/#{File.basename(u.path)}"
457
458
  end
458
459
 
459
460
  def download_lilypond(url, fn, opts)
460
- require 'httpclient'
461
+ req_ext 'ruby-progressbar'
462
+ req_ext 'httpclient'
461
463
 
462
464
  STDERR.puts "Downloading #{url}" unless opts[:silent]
463
465
 
@@ -700,6 +702,7 @@ module Lyp::Lilypond
700
702
  end
701
703
 
702
704
  def exec(cmd, raise_on_failure = true)
705
+ req_ext('open3')
703
706
  $_out = ""
704
707
  $_err = ""
705
708
  success = nil
data/lib/lyp/package.rb CHANGED
@@ -1,7 +1,3 @@
1
- require 'fileutils'
2
- require 'open-uri'
3
- require 'yaml'
4
-
5
1
  module Lyp::Package
6
2
  class << self
7
3
 
@@ -10,29 +6,7 @@ module Lyp::Package
10
6
  File.dirname(path).gsub("#{Lyp.packages_dir}/", '')
11
7
  end
12
8
 
13
- if pattern
14
- if (pattern =~ /[@\>\<\=\~]/) && (pattern =~ Lyp::PACKAGE_RE)
15
- package, version = $1, $2
16
- req = Lyp.version_req(version) rescue nil
17
- packages.select! do |p|
18
- p =~ Lyp::PACKAGE_RE
19
- p_pack, p_ver = $1, $2
20
-
21
- next false unless p_pack == package
22
-
23
- if req && (p_gemver = Lyp.version(p_ver) rescue nil)
24
- req =~ p_gemver
25
- else
26
- p_ver == version
27
- end
28
- end
29
- else
30
- packages.select! do |p|
31
- p =~ Lyp::PACKAGE_RE
32
- $1 =~ /#{pattern}/
33
- end
34
- end
35
- end
9
+ packages = filter_packages(packages, pattern) if pattern
36
10
 
37
11
  packages.sort do |x, y|
38
12
  x =~ Lyp::PACKAGE_RE; x_package, x_version = $1, $2
@@ -49,6 +23,33 @@ module Lyp::Package
49
23
  end
50
24
  end
51
25
 
26
+ def filter_packages(packages, pattern)
27
+ if (pattern =~ /[@\>\<\=\~]/) && (pattern =~ Lyp::PACKAGE_RE)
28
+ package, version = $1, $2
29
+ req = Lyp.version_req(version) rescue nil
30
+ packages.select do |p|
31
+ p =~ Lyp::PACKAGE_RE
32
+ p_name, p_ver = $1, $2
33
+
34
+ next false unless p_name == package
35
+
36
+ if req && (p_gemver = Lyp.version(p_ver) rescue nil)
37
+ req =~ p_gemver
38
+ else
39
+ p_ver == version
40
+ end
41
+ end
42
+ else
43
+ if pattern =~ /^"(.+)"$/
44
+ pattern = $1
45
+ end
46
+ packages.select do |p|
47
+ p =~ Lyp::PACKAGE_RE
48
+ $1 =~ /#{pattern}/
49
+ end
50
+ end
51
+ end
52
+
52
53
  def which(pattern = nil)
53
54
  list(pattern).map {|p| "#{Lyp.packages_dir}/#{p}" }
54
55
  end
@@ -59,6 +60,10 @@ module Lyp::Package
59
60
  end
60
61
  package, version = $1, $2
61
62
 
63
+ # The update flag means all installed versions are removed prior to
64
+ # proceeding with installation
65
+ uninstall(package, {all: true}) if opts[:update]
66
+
62
67
  if version =~ /\:/
63
68
  info = install_from_local_files(package, version, opts)
64
69
  else
@@ -71,14 +76,6 @@ module Lyp::Package
71
76
  install_package_fonts(info[:path], opts)
72
77
  end
73
78
 
74
- unless opts[:silent]
75
- if info[:local_path]
76
- puts "\nInstalled #{package}@#{info[:version]} => #{info[:local_path]}\n\n"
77
- else
78
- puts "\nInstalled #{package}@#{info[:version]}\n\n"
79
- end
80
- end
81
-
82
79
  if opts[:test]
83
80
  FileUtils.cd(info[:path]) do
84
81
  run_tests(info[:path])
@@ -96,6 +93,8 @@ module Lyp::Package
96
93
  version =~ /^([^\:]+)\:(.+)$/
97
94
  version, local_path = $1, $2
98
95
 
96
+ puts "Installing #{package}@#{version} => #{local_path}" unless opts[:silent]
97
+
99
98
  entry_point_path = nil
100
99
  local_path = File.expand_path(local_path)
101
100
  if File.directory?(local_path)
@@ -143,6 +142,8 @@ module Lyp::Package
143
142
  repo = package_repository(url, tmp_path, opts)
144
143
  version = checkout_package_version(repo, version, opts)
145
144
 
145
+ puts "Installing #{package}@#{version}" unless opts[:silent]
146
+
146
147
  # Copy files
147
148
  package_path = git_url_to_package_path(
148
149
  package !~ /\// ? package : url, version
@@ -366,6 +367,8 @@ module Lyp::Package
366
367
  end
367
368
 
368
369
  def lyp_index
370
+ req_ext 'yaml'
371
+ req_ext 'open-uri'
369
372
  @lyp_index ||= YAML.load(open(LYP_INDEX_URL))
370
373
  end
371
374
 
data/lib/lyp/settings.rb CHANGED
@@ -1,12 +1,12 @@
1
- require 'yaml'
2
-
3
1
  module Lyp::Settings
4
2
  class << self
5
3
  def load
4
+ req_ext 'yaml'
6
5
  @settings = YAML.load(IO.read(Lyp.settings_file)) rescue {}
7
6
  end
8
7
 
9
8
  def save
9
+ req_ext 'yaml'
10
10
  File.open(Lyp.settings_file, 'w+') {|f| f << YAML.dump(@settings)}
11
11
  end
12
12
 
@@ -33,11 +33,13 @@ module Lyp::Settings
33
33
  end
34
34
 
35
35
  def get_value(path, default = nil)
36
+ req_ext 'yaml'
36
37
  v = self[path]
37
38
  v ? YAML.load(v) : default
38
39
  end
39
40
 
40
41
  def set_value(path, value)
42
+ req_ext 'yaml'
41
43
  self[path] = YAML.dump(value)
42
44
  end
43
45
  end
data/lib/lyp/system.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'fileutils'
2
-
3
1
  module Lyp::System
4
2
  class << self
5
3
  RUGGED_REQ = Lyp.version_req('>=0.23.0')
@@ -26,7 +24,7 @@ module Lyp::System
26
24
 
27
25
  def require_rugged_gem
28
26
  gem 'rugged', RUGGED_REQ.to_s
29
- require 'rugged'
27
+ req_ext 'rugged'
30
28
  end
31
29
 
32
30
  def use_git_based_rugged_gem
@@ -13,8 +13,6 @@ if _[:opts][:lilypond_version]
13
13
  `
14
14
  end
15
15
 
16
- require 'fileutils'
17
-
18
16
  user_filename = File.expand_path(_[:user_file])
19
17
  user_dirname = File.dirname(user_filename)
20
18
 
data/lib/lyp/transform.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'fileutils'
2
-
3
1
  module Lyp::Transform
4
2
  class << self
5
3
  R = Lyp::DependencyResolver
data/lib/lyp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lyp
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/lyp/wrapper.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'tempfile'
2
-
3
1
  module Lyp
4
2
  WRAPPER_TEMPLATE = Lyp::Template.new(IO.read(
5
3
  File.expand_path('templates/deps_wrapper.rb', File.dirname(__FILE__))
data/lib/lyp.rb CHANGED
@@ -1,14 +1,23 @@
1
- def req(f); require File.expand_path("lyp/#{f}", File.dirname(__FILE__)) end
1
+ def req_int(f)
2
+ require File.expand_path("lyp/#{f}", File.dirname(__FILE__))
3
+ end
2
4
 
3
- req 'base'
4
- req 'system'
5
- req 'settings'
5
+ module Kernel
6
+ @@ext_requires = {}
7
+ def req_ext(l)
8
+ @@ext_requires[l] ||= require(l)
9
+ end
10
+ end
6
11
 
7
- req 'template'
8
- req 'resolver'
9
- req 'wrapper'
10
- req 'package'
11
- req 'lilypond'
12
- req 'transform'
12
+ req_int 'base'
13
+ req_int 'system'
14
+ req_int 'settings'
13
15
 
14
- req 'windows' if Lyp::WINDOWS
16
+ req_int 'template'
17
+ req_int 'resolver'
18
+ req_int 'wrapper'
19
+ req_int 'package'
20
+ req_int 'lilypond'
21
+ req_int 'transform'
22
+
23
+ req_int 'windows' if Lyp::WINDOWS
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.0.3
4
+ version: 1.1.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-12-02 00:00:00.000000000 Z
11
+ date: 2016-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient