Skip to content

Commit

Permalink
revert renaming of noindex to index, remove @main and validate @metap…
Browse files Browse the repository at this point in the history
  • Loading branch information
cfillion committed May 20, 2016
1 parent e71e410 commit 5af06f4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/reapack/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def scan(path, contents)

mh = MetaHeader.new contents

if mh[:index] == false
if mh[:noindex]
remove path
return
end
Expand Down
6 changes: 3 additions & 3 deletions lib/reapack/index/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Scanner
:author => [MetaHeader::VALUE, MetaHeader::SINGLELINE],
:changelog => [MetaHeader::VALUE],
:provides => [MetaHeader::VALUE, PROVIDES_VALIDATOR],
:index => [MetaHeader::BOOLEAN],
:main => [MetaHeader::BOOLEAN],
:noindex => [MetaHeader::BOOLEAN],
:metapackage => [MetaHeader::BOOLEAN],
}.freeze

WITH_MAIN = [:script, :effect].freeze
Expand Down Expand Up @@ -49,7 +49,7 @@ def run

if @is_main && sources.none? {|src| src.file.nil? }
# add the package itself as a main source
src = Source.new make_url(@pkg.path), @mh[:main, true]
src = Source.new make_url(@pkg.path), true
sources.unshift src

@cselector.push @pkg.type, src.platform, @pkg.path
Expand Down
1 change: 0 additions & 1 deletion test/data/noindex.lua

This file was deleted.

15 changes: 2 additions & 13 deletions test/index/test_scan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_author
def test_noindex
index = ReaPack::Index.new @real_path

index.scan 'script.lua', '@index false'
index.scan 'script.lua', '@noindex'

assert_equal false, index.modified?
end
Expand All @@ -159,7 +159,7 @@ def test_noindex_autoremove
index = ReaPack::Index.new @real_path
index.commit = @commit

index.scan 'Category Name/Hello World.lua', '@index false'
index.scan 'Category Name/Hello World.lua', '@noindex'

assert_equal true, index.modified?
assert_equal '1 removed package', index.changelog
Expand All @@ -183,17 +183,6 @@ def test_metapackage
assert_equal 'no files provided', error.message
end

def test_nomain
index = ReaPack::Index.new @dummy_path
index.url_template = 'http://host/$path'
index.files = ['Category/script.lua', 'Category/test']

index.scan index.files.first, "@version 1.0\n@main false"
index.write!

refute_match 'main="true"', File.read(index.path)
end

def test_version_time
index = ReaPack::Index.new @dummy_path
index.url_template = 'http://host/$path'
Expand Down
10 changes: 5 additions & 5 deletions test/test_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ def test_provides
end

def test_index
@mh[:index] = 'value'
@mh[:noindex] = 'value'
error = assert_raises(ReaPack::Index::Error) { @scanner.run }
assert_equal "tag 'index' cannot have a value", error.message
assert_equal "tag 'noindex' cannot have a value", error.message
end

def test_main
@mh[:main] = 'value'
def test_metapackage
@mh[:metapackage] = 'value'
error = assert_raises(ReaPack::Index::Error) { @scanner.run }
assert_equal "tag 'main' cannot have a value", error.message
assert_equal "tag 'metapackage' cannot have a value", error.message
end
end
end

0 comments on commit 5af06f4

Please sign in to comment.