Skip to content

Commit

Permalink
add support for Web Interface packages (.www files + new `WebInterfac…
Browse files Browse the repository at this point in the history
…e Name` tag alias)
  • Loading branch information
cfillion committed Dec 19, 2016
1 parent c3a47ec commit d681f64
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/reapack/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ReaPack::Index
data: %w{data},
theme: %w{theme},
langpack: %w{reaperlangpack},
webinterface: %w{www},
}.freeze

FS_ROOT = File.expand_path('/').freeze
Expand Down
5 changes: 3 additions & 2 deletions lib/reapack/index/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ class Scanner

HEADER_ALIASES = {
[:reascript_name, :jsfx_name, :theme_name,
:extension_name, :langpack_name, :desc, :name] => :description,
:extension_name, :langpack_name, :webinterface_name,
:desc, :name] => :description,
[:links, :website] => :link,
:screenshots => :screenshot,
}.freeze

META_TYPES = [:extension, :data, :theme].freeze
META_TYPES = [:extension, :data, :theme, :webinterface].freeze

def initialize(cat, pkg, mh, index)
@cat, @pkg, @mh, @index = cat, pkg, mh, index
Expand Down
27 changes: 27 additions & 0 deletions test/index/test_scan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,31 @@ def test_langpack
index.write!
assert_equal expected, File.read(index.path)
end

def test_webinterface
index = ReaPack::Index.new @dummy_path
index.url_template = 'http://host/$path'
index.files = ['Web Interfaces/Test.www']

index.scan index.files.first, <<-IN
@version 1.0
@provides test.html http://host/test.html
IN

expected = <<-XML
<?xml version="1.0" encoding="utf-8"?>
<index version="1">
<category name="Web Interfaces">
<reapack name="Test.www" type="webinterface">
<version name="1.0">
<source file="test.html">http://host/test.html</source>
</version>
</reapack>
</category>
</index>
XML

index.write!
assert_equal expected, File.read(index.path)
end
end
25 changes: 14 additions & 11 deletions test/test_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_type_of
'Cat/test.theme' => :theme,
'Cat/test.reaperlangpack' => :langpack,
'Cat/test.ReaperLangPack' => :langpack,
'Cat/test.www' => :webinterface,
}.each {|fn, type|
actual = ReaPack::Index.type_of fn
assert_equal type, actual,
Expand All @@ -37,17 +38,19 @@ def test_resolve_type
assert_nil ReaPack::Index.resolve_type('hello')

{
:script => :script,
'lua' => :script,
'eel' => :script,
'effect' => :effect,
:jsfx => :effect,
'jsfx' => :effect,
'extension' => :extension,
'ext' => :extension,
'data' => :data,
'theme' => :theme,
'langpack' => :langpack,
:script => :script,
'lua' => :script,
'eel' => :script,
'effect' => :effect,
:jsfx => :effect,
'jsfx' => :effect,
'extension' => :extension,
'ext' => :extension,
'data' => :data,
'theme' => :theme,
'langpack' => :langpack,
'www' => :webinterface,
'webinterface' => :webinterface,
}.each {|input, type|
actual = ReaPack::Index.resolve_type input
assert_equal type, actual,
Expand Down

0 comments on commit d681f64

Please sign in to comment.