reapack-index 1.1rc2 → 1.1rc3
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 +4 -4
- data/lib/reapack/index/gem_version.rb +1 -1
- data/lib/reapack/index/package.rb +6 -0
- data/lib/reapack/index/provides.rb +9 -3
- data/lib/reapack/index/scanner.rb +11 -3
- data/lib/reapack/index/source.rb +29 -7
- data/setup/reapack-index.nsi +1 -1
- data/test/index/test_provides.rb +9 -6
- data/test/index/test_scan.rb +2 -2
- data/test/test_package.rb +2 -0
- data/test/test_provides.rb +7 -6
- data/test/test_source.rb +44 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d74129191d5d7a07762ebdab7f566c7cd885872
|
4
|
+
data.tar.gz: 54ed24d5a0674024502fafb3f0a498d0d3fac519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8becc15eba83d516c6ef4a4a69f44987b162316af47352705c54ca496b45f824444d6a2731464b8afe97ec754fe89e296b3d766e6c8aa4f023eff48f5628050
|
7
|
+
data.tar.gz: db0ff137c68b50b83e69902946141149d133cdabd0b769ab0e4baa69b8c0af97a0cc3ba499d2d8a3676dd6959401c303a138e6f80da33d76a4a85ef3df2a7a3a
|
@@ -8,6 +8,8 @@ class ReaPack::Index
|
|
8
8
|
|
9
9
|
TYPE_ATTR = 'type'.freeze
|
10
10
|
DESC_ATTR = 'desc'.freeze
|
11
|
+
DIR_SEPARATOR = Regexp.union(
|
12
|
+
*[File::SEPARATOR, File::ALT_SEPARATOR].compact).freeze
|
11
13
|
|
12
14
|
def initialize(node)
|
13
15
|
super
|
@@ -24,6 +26,10 @@ class ReaPack::Index
|
|
24
26
|
@node.parent[NAME_ATTR]
|
25
27
|
end
|
26
28
|
|
29
|
+
def topdir
|
30
|
+
category&.split(DIR_SEPARATOR)&.first
|
31
|
+
end
|
32
|
+
|
27
33
|
def path
|
28
34
|
@path ||= File.join category, name if category && name
|
29
35
|
end
|
@@ -28,7 +28,7 @@ class ReaPack::Index
|
|
28
28
|
|
29
29
|
instance = self.new pattern, url_tpl
|
30
30
|
|
31
|
-
options and options.split(
|
31
|
+
options and options.split("\x20").each {|user_opt|
|
32
32
|
user_opt.strip!
|
33
33
|
next if user_opt.empty?
|
34
34
|
|
@@ -38,8 +38,14 @@ class ReaPack::Index
|
|
38
38
|
instance.platform = opt.to_sym
|
39
39
|
elsif type = ReaPack::Index.resolve_type(opt)
|
40
40
|
instance.type = type
|
41
|
-
elsif opt =~ /\A(
|
42
|
-
|
41
|
+
elsif opt =~ /\A(nomain)|main(?:=(.+))?\Z/
|
42
|
+
if $1 # nomain
|
43
|
+
instance.main = false
|
44
|
+
elsif $2 # explicit sections
|
45
|
+
instance.main = $2.split(',').reject(&:empty?).map {|s| s.to_sym }
|
46
|
+
else # implicit sections
|
47
|
+
instance.main = true
|
48
|
+
end
|
43
49
|
else
|
44
50
|
raise Error, "unknown option '#{user_opt}'"
|
45
51
|
end
|
@@ -78,7 +78,8 @@ class ReaPack::Index
|
|
78
78
|
|
79
79
|
if !metapackage? && sources.none? {|src| src.file.nil? }
|
80
80
|
# add the package itself as a main source
|
81
|
-
src = Source.new make_url(@pkg.path)
|
81
|
+
src = Source.new make_url(@pkg.path)
|
82
|
+
src.detect_sections @pkg
|
82
83
|
sources.unshift src
|
83
84
|
|
84
85
|
@cselector.push @pkg.type, src.platform, @pkg.path
|
@@ -141,15 +142,22 @@ class ReaPack::Index
|
|
141
142
|
end
|
142
143
|
|
143
144
|
files.map {|file|
|
144
|
-
src = Source.new make_url(file, line.url_template)
|
145
|
+
src = Source.new make_url(file, line.url_template)
|
145
146
|
src.platform = line.platform
|
146
147
|
src.type = line.type
|
147
148
|
|
149
|
+
case line.main?
|
150
|
+
when true
|
151
|
+
src.detect_sections @pkg
|
152
|
+
when Array
|
153
|
+
src.sections = line.main?
|
154
|
+
end
|
155
|
+
|
148
156
|
@cselector.push src.type || @pkg.type, src.platform,
|
149
157
|
line.url_template ? expanded : file
|
150
158
|
|
151
159
|
if file == @pkg.path
|
152
|
-
src.
|
160
|
+
src.detect_sections @pkg if line.main.nil? && !metapackage?
|
153
161
|
else
|
154
162
|
if line.url_template
|
155
163
|
src.file = file
|
data/lib/reapack/index/source.rb
CHANGED
@@ -12,23 +12,24 @@ class ReaPack::Index
|
|
12
12
|
darwin: :all, darwin32: :darwin, darwin64: :darwin,
|
13
13
|
}.freeze
|
14
14
|
|
15
|
+
SECTIONS = [
|
16
|
+
:main, :midi_editor
|
17
|
+
].freeze
|
18
|
+
|
15
19
|
class << self
|
16
20
|
def is_platform?(input)
|
17
21
|
PLATFORMS.has_key? input&.to_sym
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
|
-
def initialize(url
|
25
|
+
def initialize(url)
|
22
26
|
@url = url
|
23
|
-
@
|
27
|
+
@sections = []
|
24
28
|
@platform = :all
|
25
29
|
end
|
26
30
|
|
27
|
-
attr_reader :platform, :type
|
31
|
+
attr_reader :platform, :type, :sections
|
28
32
|
attr_accessor :file, :url
|
29
|
-
attr_writer :main
|
30
|
-
|
31
|
-
def main?; @main; end
|
32
33
|
|
33
34
|
def platform=(new_platform)
|
34
35
|
new_platform ||= :all
|
@@ -50,9 +51,30 @@ class ReaPack::Index
|
|
50
51
|
@type = new_type.to_sym
|
51
52
|
end
|
52
53
|
|
54
|
+
def detect_sections(pkg)
|
55
|
+
@sections = []
|
56
|
+
|
57
|
+
if (@type || pkg.type) == :script
|
58
|
+
topdir = pkg.topdir.downcase
|
59
|
+
@sections << (topdir == 'midi editor' ? :midi_editor : :main)
|
60
|
+
end
|
61
|
+
|
62
|
+
@sections.freeze # force going through sections=() for validation
|
63
|
+
end
|
64
|
+
|
65
|
+
def sections=(new_sections)
|
66
|
+
new_sections.each {|s|
|
67
|
+
unless SECTIONS.include? s
|
68
|
+
raise Error, "invalid Action List section '#{s}'"
|
69
|
+
end
|
70
|
+
}
|
71
|
+
|
72
|
+
@sections = new_sections.sort {|s| SECTIONS.index s }.freeze
|
73
|
+
end
|
74
|
+
|
53
75
|
def make_node(parent)
|
54
76
|
@node = Nokogiri::XML::Node.new TAG, parent.document
|
55
|
-
@node[MAIN] =
|
77
|
+
@node[MAIN] = @sections.join "\x20" unless @sections.empty?
|
56
78
|
@node[PLATFORM] = @platform if @platform != :all
|
57
79
|
@node[TYPE] = @type if @type
|
58
80
|
@node[FILE] = @file if @file
|
data/setup/reapack-index.nsi
CHANGED
data/test/index/test_provides.rb
CHANGED
@@ -28,7 +28,7 @@ class TestIndex::Provides < MiniTest::Test
|
|
28
28
|
<category name="Category">
|
29
29
|
<reapack name="script.lua" type="script">
|
30
30
|
<version name="1.0">
|
31
|
-
<source main="
|
31
|
+
<source main="main">http://host/Category/script.lua?Category/script.lua</source>
|
32
32
|
<source platform="windows" file="../Resources/unicode.dat">http://host/Resources/unicode.dat?Category/script.lua</source>
|
33
33
|
<source file="test.png">http://host/Category/test.png?Category/script.lua</source>
|
34
34
|
</version>
|
@@ -75,8 +75,8 @@ class TestIndex::Provides < MiniTest::Test
|
|
75
75
|
<category name="Category">
|
76
76
|
<reapack name="script.lua" type="script">
|
77
77
|
<version name="1.0">
|
78
|
-
<source main="
|
79
|
-
<source main="
|
78
|
+
<source main="main" platform="darwin">http://host/Category/script.lua</source>
|
79
|
+
<source main="main" platform="win64">http://host/Category/script.lua</source>
|
80
80
|
</version>
|
81
81
|
</reapack>
|
82
82
|
</category>
|
@@ -142,7 +142,7 @@ class TestIndex::Provides < MiniTest::Test
|
|
142
142
|
<category name="Category">
|
143
143
|
<reapack name="script.lua" type="script">
|
144
144
|
<version name="1.0">
|
145
|
-
<source main="
|
145
|
+
<source main="main">http://host/Category/script.lua</source>
|
146
146
|
<source platform="windows" file="Data/a.dat">http://host/Category/Data/a.dat</source>
|
147
147
|
<source platform="windows" file="Data/b.dat">http://host/Category/Data/b.dat</source>
|
148
148
|
<source file="test.txt">http://host/Category/test.txt</source>
|
@@ -297,6 +297,7 @@ class TestIndex::Provides < MiniTest::Test
|
|
297
297
|
'Category/script.lua',
|
298
298
|
'Category/a.dat',
|
299
299
|
'Category/b.dat',
|
300
|
+
'Category/c.dat',
|
300
301
|
]
|
301
302
|
|
302
303
|
index.scan index.files.first, <<-IN
|
@@ -305,6 +306,7 @@ class TestIndex::Provides < MiniTest::Test
|
|
305
306
|
[main] a.dat
|
306
307
|
[nomain] .
|
307
308
|
[nomain] b.dat
|
309
|
+
[main=midi_editor] c.dat
|
308
310
|
IN
|
309
311
|
|
310
312
|
expected = <<-XML
|
@@ -313,9 +315,10 @@ class TestIndex::Provides < MiniTest::Test
|
|
313
315
|
<category name="Category">
|
314
316
|
<reapack name="script.lua" type="script">
|
315
317
|
<version name="1.0">
|
316
|
-
<source main="
|
318
|
+
<source main="main" file="a.dat">http://host/Category/a.dat</source>
|
317
319
|
<source>http://host/Category/script.lua</source>
|
318
320
|
<source file="b.dat">http://host/Category/b.dat</source>
|
321
|
+
<source main="midi_editor" file="c.dat">http://host/Category/c.dat</source>
|
319
322
|
</version>
|
320
323
|
</reapack>
|
321
324
|
</category>
|
@@ -341,6 +344,6 @@ class TestIndex::Provides < MiniTest::Test
|
|
341
344
|
IN
|
342
345
|
|
343
346
|
index.write!
|
344
|
-
assert_match 'main="
|
347
|
+
assert_match 'main="main"', File.read(index.path)
|
345
348
|
end
|
346
349
|
end
|
data/test/index/test_scan.rb
CHANGED
@@ -44,7 +44,7 @@ class TestIndex::Scan < MiniTest::Test
|
|
44
44
|
<reapack name="Instrument Track.lua" type="script">
|
45
45
|
<version name="1.0">
|
46
46
|
<changelog><![CDATA[Hello World]]></changelog>
|
47
|
-
<source main="
|
47
|
+
<source main="main">http://host/Category/Path/Instrument%20Track.lua</source>
|
48
48
|
</version>
|
49
49
|
</reapack>
|
50
50
|
</category>
|
@@ -165,7 +165,7 @@ class TestIndex::Scan < MiniTest::Test
|
|
165
165
|
<category name="Dynamics">
|
166
166
|
<reapack name="super_compressor.jsfx" type="effect">
|
167
167
|
<version name="1.0">
|
168
|
-
<source
|
168
|
+
<source>http://host/Dynamics/super_compressor.jsfx</source>
|
169
169
|
</version>
|
170
170
|
</reapack>
|
171
171
|
</category>
|
data/test/test_package.rb
CHANGED
@@ -141,11 +141,13 @@ class TestPackage < MiniTest::Test
|
|
141
141
|
pkg1 = ReaPack::Index::Package.new make_node('<reapack/>')
|
142
142
|
assert_nil pkg1.category
|
143
143
|
assert_nil pkg1.path
|
144
|
+
assert_nil pkg1.topdir
|
144
145
|
|
145
146
|
pkg2 = ReaPack::Index::Package.create 'test',
|
146
147
|
make_node('<category name="Hello/World"/>')
|
147
148
|
|
148
149
|
assert_equal 'Hello/World', pkg2.category
|
149
150
|
assert_equal 'Hello/World/test', pkg2.path
|
151
|
+
assert_equal 'Hello', pkg2.topdir
|
150
152
|
end
|
151
153
|
end
|
data/test/test_provides.rb
CHANGED
@@ -40,7 +40,7 @@ class TestProvides < MiniTest::Test
|
|
40
40
|
'[win64] file',
|
41
41
|
'[Darwin]file',
|
42
42
|
' [ darwin32 ] file',
|
43
|
-
'[win32
|
43
|
+
'[win32 darwin64] file',
|
44
44
|
].map {|l| ReaPack::Index::Provides.parse(l).platform }
|
45
45
|
end
|
46
46
|
|
@@ -48,20 +48,21 @@ class TestProvides < MiniTest::Test
|
|
48
48
|
assert_equal [:script, :data, nil, nil],
|
49
49
|
vals = [
|
50
50
|
'[script] file',
|
51
|
-
'[windows
|
51
|
+
'[windows Data] file',
|
52
52
|
'[windows] file',
|
53
|
-
'[
|
53
|
+
'[ windows ] file',
|
54
54
|
].map {|l| ReaPack::Index::Provides.parse(l).type }
|
55
55
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_main
|
59
|
-
assert_equal [true, false, nil, false],
|
59
|
+
assert_equal [true, false, nil, false, [:main, :midi_editor, :abc]],
|
60
60
|
[
|
61
61
|
'[main] file',
|
62
62
|
'[nomain] file',
|
63
63
|
'file',
|
64
|
-
'[main
|
64
|
+
'[main nomain] file',
|
65
|
+
'[main=main,midi_editor,,abc] file',
|
65
66
|
].map {|l| ReaPack::Index::Provides.parse(l).main? }
|
66
67
|
end
|
67
68
|
|
@@ -69,7 +70,7 @@ class TestProvides < MiniTest::Test
|
|
69
70
|
assert_equal ["unknown option 'HeLlO'", "unknown option 'Test'"],
|
70
71
|
[
|
71
72
|
'[HeLlO] file',
|
72
|
-
'[
|
73
|
+
'[ Test] file',
|
73
74
|
].map {|l|
|
74
75
|
assert_raises ReaPack::Index::Error do
|
75
76
|
ReaPack::Index::Provides.parse l
|
data/test/test_source.rb
CHANGED
@@ -135,22 +135,60 @@ class TestSource < MiniTest::Test
|
|
135
135
|
before = make_node '<version name="1.0"/>'
|
136
136
|
after = <<-XML
|
137
137
|
<version name="1.0">
|
138
|
-
<source main="
|
138
|
+
<source main="main midi_editor">http://host/</source>
|
139
139
|
</version>
|
140
140
|
XML
|
141
141
|
|
142
|
-
assert_equal true, ReaPack::Index::Source.new('http://host/', true).main?
|
143
|
-
|
144
142
|
src = ReaPack::Index::Source.new 'http://host/'
|
145
|
-
|
146
|
-
src.
|
147
|
-
assert_equal
|
143
|
+
assert_empty src.sections
|
144
|
+
src.sections = [:midi_editor, :main]
|
145
|
+
assert_equal [:main, :midi_editor], src.sections
|
146
|
+
|
147
|
+
assert_raises ReaPack::Index::Error do
|
148
|
+
src.sections = [:abc]
|
149
|
+
end
|
148
150
|
|
149
151
|
src.make_node before
|
150
152
|
|
151
153
|
assert_equal after.chomp, before.to_s
|
152
154
|
end
|
153
155
|
|
156
|
+
def test_auto_main_pkg_type
|
157
|
+
pkg = MiniTest::Mock.new
|
158
|
+
pkg.expect :type, :script
|
159
|
+
pkg.expect :topdir, 'Category'
|
160
|
+
|
161
|
+
src = ReaPack::Index::Source.new 'http://host/'
|
162
|
+
src.detect_sections pkg
|
163
|
+
assert_equal [:main], src.sections
|
164
|
+
|
165
|
+
pkg.verify
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_auto_main_type_override
|
169
|
+
pkg = MiniTest::Mock.new
|
170
|
+
pkg.expect :topdir, 'Category'
|
171
|
+
|
172
|
+
src = ReaPack::Index::Source.new 'http://host/'
|
173
|
+
src.type = :script
|
174
|
+
src.detect_sections pkg
|
175
|
+
assert_equal [:main], src.sections
|
176
|
+
|
177
|
+
pkg.verify
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_auto_main_midi_editor
|
181
|
+
pkg = MiniTest::Mock.new
|
182
|
+
pkg.expect :type, :script
|
183
|
+
pkg.expect :topdir, 'MIDI Editor'
|
184
|
+
|
185
|
+
src = ReaPack::Index::Source.new 'http://host/'
|
186
|
+
src.detect_sections pkg
|
187
|
+
assert_equal [:midi_editor], src.sections
|
188
|
+
|
189
|
+
pkg.verify
|
190
|
+
end
|
191
|
+
|
154
192
|
def test_is_platform
|
155
193
|
assert_equal [false, true, true, false],
|
156
194
|
[nil, :windows, 'windows', :atari].map {|p|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reapack-index
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cfillion
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|