reapack-index 1.1rc2 → 1.1rc3

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: 45a5d393aea0b960659f4bb459bf40adfb0abc0c
4
- data.tar.gz: 5f3955b073c091771b71383f1ce9fcb679593950
3
+ metadata.gz: 6d74129191d5d7a07762ebdab7f566c7cd885872
4
+ data.tar.gz: 54ed24d5a0674024502fafb3f0a498d0d3fac519
5
5
  SHA512:
6
- metadata.gz: 34198f4f8e78724ae0036a4c7c1b421530c88f10446a0d60f6cc057fca43e12c80713874b95e57010e24b1a850c3f0bd7da0a2ccc504ca7d8ebf7aea90c97e12
7
- data.tar.gz: a68176f901401b24fab087eae9e0507fc9fd9dccf8eebb479d2c482503a7621c15c7443c58ed5cc8ab5b3b6daad9fab2f3342d283308ce54b7c57a200ffda181
6
+ metadata.gz: e8becc15eba83d516c6ef4a4a69f44987b162316af47352705c54ca496b45f824444d6a2731464b8afe97ec754fe89e296b3d766e6c8aa4f023eff48f5628050
7
+ data.tar.gz: db0ff137c68b50b83e69902946141149d133cdabd0b769ab0e4baa69b8c0af97a0cc3ba499d2d8a3676dd6959401c303a138e6f80da33d76a4a85ef3df2a7a3a
@@ -1,5 +1,5 @@
1
1
  module ReaPack
2
2
  class Index
3
- VERSION = '1.1rc2'
3
+ VERSION = '1.1rc3'
4
4
  end
5
5
  end
@@ -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(',').each {|user_opt|
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(no)?main\Z/
42
- instance.main = !$1
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), true
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), line.main?
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.main = !metapackage? if line.main.nil?
160
+ src.detect_sections @pkg if line.main.nil? && !metapackage?
153
161
  else
154
162
  if line.url_template
155
163
  src.file = file
@@ -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, main = false)
25
+ def initialize(url)
22
26
  @url = url
23
- @main = main
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] = true if @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
@@ -4,7 +4,7 @@ Unicode true
4
4
  !include Sections.nsh
5
5
  !include StrRep.nsh
6
6
 
7
- !define VERSION "1.1rc2"
7
+ !define VERSION "1.1rc3"
8
8
  !define NAME "reapack-index ${VERSION}"
9
9
  !define LONG_VERSION "0.1.0.0"
10
10
 
@@ -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="true">http://host/Category/script.lua?Category/script.lua</source>
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="true" platform="darwin">http://host/Category/script.lua</source>
79
- <source main="true" platform="win64">http://host/Category/script.lua</source>
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="true">http://host/Category/script.lua</source>
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="true" file="a.dat">http://host/Category/a.dat</source>
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="true"', File.read(index.path)
347
+ assert_match 'main="main"', File.read(index.path)
345
348
  end
346
349
  end
@@ -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="true">http://host/Category/Path/Instrument%20Track.lua</source>
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 main="true">http://host/Dynamics/super_compressor.jsfx</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
@@ -40,7 +40,7 @@ class TestProvides < MiniTest::Test
40
40
  '[win64] file',
41
41
  '[Darwin]file',
42
42
  ' [ darwin32 ] file',
43
- '[win32, darwin64] file',
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,Data] file',
51
+ '[windows Data] file',
52
52
  '[windows] file',
53
- '[,windows,,] file',
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, nomain] file',
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
- '[, Test] file',
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="true">http://host/</source>
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
- assert_equal false, src.main?
146
- src.main = true
147
- assert_equal true, src.main?
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.1rc2
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-09-14 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler