lyp 0.0.1
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 +7 -0
- data/LICENSE +22 -0
- data/README.md +9 -0
- data/bin/lilypond +27 -0
- data/bin/lyp +4 -0
- data/lib/lyp.rb +16 -0
- data/lib/lyp/cli.rb +32 -0
- data/lib/lyp/cli/commands.rb +146 -0
- data/lib/lyp/directories.rb +26 -0
- data/lib/lyp/env.rb +32 -0
- data/lib/lyp/lilypond.rb +377 -0
- data/lib/lyp/output.rb +18 -0
- data/lib/lyp/package.rb +28 -0
- data/lib/lyp/resolver.rb +411 -0
- data/lib/lyp/settings.rb +37 -0
- data/lib/lyp/template.rb +59 -0
- data/lib/lyp/templates/deps_wrapper.rb +58 -0
- data/lib/lyp/version.rb +3 -0
- data/lib/lyp/wrapper.rb +15 -0
- metadata +163 -0
data/lib/lyp/settings.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Lyp::Settings
|
4
|
+
class << self
|
5
|
+
def get
|
6
|
+
YAML.load(IO.read(Lyp.settings_file)) rescue {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def set(o)
|
10
|
+
File.open(Lyp.settings_file, 'w+') {|f| f << YAML.dump(o)}
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](path)
|
14
|
+
h = get
|
15
|
+
while path =~ /^([^\/]+)\/(.+)$/
|
16
|
+
h = h[$1.to_sym] ||= {}
|
17
|
+
path = $2
|
18
|
+
end
|
19
|
+
|
20
|
+
h[path.to_sym]
|
21
|
+
end
|
22
|
+
|
23
|
+
def []=(path, value)
|
24
|
+
h = settings = get
|
25
|
+
while path =~ /^([^\/]+)\/(.+)$/
|
26
|
+
h = h[$1.to_sym] ||= {}
|
27
|
+
path = $2
|
28
|
+
end
|
29
|
+
|
30
|
+
h[path.to_sym] = value
|
31
|
+
|
32
|
+
set(settings)
|
33
|
+
|
34
|
+
value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/lyp/template.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Lyp
|
2
|
+
class Template
|
3
|
+
EMIT_DELIMITER = '`'.freeze
|
4
|
+
EMIT_RE = /#{EMIT_DELIMITER}(((?!#{EMIT_DELIMITER}).)*)#{EMIT_DELIMITER}/m
|
5
|
+
|
6
|
+
INTERPOLATION_START = "{{".freeze
|
7
|
+
INTERPOLATION_END = "}}".freeze
|
8
|
+
INTERPOLATION_RE = /#{INTERPOLATION_START}((?:(?!#{INTERPOLATION_END}).)*)#{INTERPOLATION_END}/m
|
9
|
+
|
10
|
+
ESCAPED_QUOTE = '\\"'.freeze
|
11
|
+
QUOTE = '"'.freeze
|
12
|
+
|
13
|
+
# From the metaid gem
|
14
|
+
def metaclass; class << self; self; end; end
|
15
|
+
|
16
|
+
def initialize(templ)
|
17
|
+
templ = templ.gsub(EMIT_RE) {|m| convert_literal($1)}
|
18
|
+
method_str = <<EOF
|
19
|
+
define_method(:render) do |_ = {}, env = {}|
|
20
|
+
__buffer__ = env[:buffer] ||= ''
|
21
|
+
__emit__ = env[:emit] ||= lambda {|s| __buffer__ << s}
|
22
|
+
__render_l__ = env[:render] ||= lambda {|n, o| Template.render(n, o, env)}
|
23
|
+
metaclass.instance_eval "define_method(:__render__) {|n, o| __render_l__[n, o]}"
|
24
|
+
begin
|
25
|
+
#{templ}
|
26
|
+
end
|
27
|
+
__buffer__
|
28
|
+
end
|
29
|
+
EOF
|
30
|
+
|
31
|
+
metaclass.instance_eval method_str
|
32
|
+
end
|
33
|
+
|
34
|
+
def convert_literal(s)
|
35
|
+
# look for interpolated values, wrap them with #{}
|
36
|
+
s = s.inspect.gsub(INTERPOLATION_RE) do
|
37
|
+
code = $1.gsub(ESCAPED_QUOTE, QUOTE)
|
38
|
+
"\#{#{code}}"
|
39
|
+
end
|
40
|
+
"__emit__[#{s}]"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Global template registry
|
44
|
+
@@templates = {}
|
45
|
+
|
46
|
+
def self.load_templates(path)
|
47
|
+
Dir["#{path}/*.rb"].each {|fn| set(File.basename(fn), IO.read(fn))}
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.set(name, templ)
|
51
|
+
@@templates[name.to_sym] = new(templ)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.render(name, arg = {}, env = {})
|
55
|
+
raise unless @@templates[name.to_sym]
|
56
|
+
@@templates[name.to_sym].render(arg, env)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Expect _ to be a hash of the form:
|
2
|
+
# {
|
3
|
+
# user_file: <path>
|
4
|
+
# package_paths: {
|
5
|
+
# <specifier> => <package path>
|
6
|
+
# ...
|
7
|
+
# }
|
8
|
+
# }
|
9
|
+
|
10
|
+
# define mapping of requested packages to actual file names
|
11
|
+
# package-refs is a hash table with an entry for each package reference made
|
12
|
+
# using \require, either in user files or in package files (for transitive dependencies).
|
13
|
+
|
14
|
+
`\version "2.19.31"
|
15
|
+
|
16
|
+
#(begin
|
17
|
+
(define package-refs (make-hash-table))`
|
18
|
+
|
19
|
+
_[:package_paths].each do |spec, path|
|
20
|
+
`
|
21
|
+
(hash-set! package-refs "{{spec}}" "{{path}}")`
|
22
|
+
end
|
23
|
+
|
24
|
+
# package-loaded is hash table used for tracking loaded packages, so each
|
25
|
+
# package is loaded only once.
|
26
|
+
`
|
27
|
+
(define package-loaded (make-hash-table))
|
28
|
+
)
|
29
|
+
`
|
30
|
+
|
31
|
+
# define the \require command
|
32
|
+
`
|
33
|
+
require = #(define-void-function (parser location package)(string?)
|
34
|
+
(let*
|
35
|
+
(
|
36
|
+
(path (hash-ref package-refs package))
|
37
|
+
(loaded? (hash-ref package-loaded path))
|
38
|
+
(package-dir (dirname path))
|
39
|
+
)
|
40
|
+
(if (and path (not loaded?)) (begin
|
41
|
+
(if (not (file-exists? path)) (
|
42
|
+
(ly:error "Failed to load package ~a (file not found ~a)" package path)
|
43
|
+
))
|
44
|
+
(ly:debug "Loaded package ~a at ~a" package package-dir)
|
45
|
+
(hash-set! package-loaded path #t)
|
46
|
+
#{ \include #path #}
|
47
|
+
))
|
48
|
+
)
|
49
|
+
)
|
50
|
+
`
|
51
|
+
|
52
|
+
# load the user's file
|
53
|
+
|
54
|
+
`
|
55
|
+
#(ly:debug "package loader is ready")
|
56
|
+
#(ly:set-option 'relative-includes #t)
|
57
|
+
\include "{{_[:user_file]}}"
|
58
|
+
`
|
data/lib/lyp/version.rb
ADDED
data/lib/lyp/wrapper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module Lyp
|
4
|
+
def self.wrap(fn)
|
5
|
+
r = Lyp::Resolver.new(fn).resolve_package_dependencies
|
6
|
+
|
7
|
+
unless r[:package_paths].empty?
|
8
|
+
fn = Tempfile.new('lyp-deps-wrapper.ly').path
|
9
|
+
|
10
|
+
t = Lyp::Template.new(IO.read(File.expand_path('templates/deps_wrapper.rb', File.dirname(__FILE__))))
|
11
|
+
File.open(fn, 'w+') {|f| f << t.render(r)}
|
12
|
+
end
|
13
|
+
fn
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lyp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sharon Rosner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: highline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.7.8
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.7'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.7.8
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ruby-progressbar
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.7'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.7.5
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.7'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.7.5
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: commander
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '4.3'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 4.3.5
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '4.3'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 4.3.5
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: nokogiri
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '1.6'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.6.7
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 1.6.7
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: httpclient
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '2.7'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.7.1
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.7'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.7.1
|
113
|
+
description: Lyp is a tool for managing lilypond versions and lilypond packages
|
114
|
+
email: ciconia@gmail.com
|
115
|
+
executables:
|
116
|
+
- lyp
|
117
|
+
- lilypond
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files: []
|
120
|
+
files:
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- bin/lilypond
|
124
|
+
- bin/lyp
|
125
|
+
- lib/lyp.rb
|
126
|
+
- lib/lyp/cli.rb
|
127
|
+
- lib/lyp/cli/commands.rb
|
128
|
+
- lib/lyp/directories.rb
|
129
|
+
- lib/lyp/env.rb
|
130
|
+
- lib/lyp/lilypond.rb
|
131
|
+
- lib/lyp/output.rb
|
132
|
+
- lib/lyp/package.rb
|
133
|
+
- lib/lyp/resolver.rb
|
134
|
+
- lib/lyp/settings.rb
|
135
|
+
- lib/lyp/template.rb
|
136
|
+
- lib/lyp/templates/deps_wrapper.rb
|
137
|
+
- lib/lyp/version.rb
|
138
|
+
- lib/lyp/wrapper.rb
|
139
|
+
homepage: http://github.com/ciconia/lyp
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.4.8
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: Lyp is a package manager for lilypond
|
163
|
+
test_files: []
|