reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit a22bd242f5c69b5fe8aee82bded60f15822ef5ac
parent 3256f87ed4e548d19ff87133d9f1aa5930021e0c
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue,  8 Mar 2016 02:51:18 -0500

add support for JSFXs

Diffstat:
Msrc/package.cpp | 9++++++++-
Msrc/package.hpp | 1+
Mtest/package.cpp | 38+++++++++++++++++++++++++++++++-------
3 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/src/package.cpp b/src/package.cpp @@ -30,6 +30,8 @@ Package::Type Package::typeFor(const char *type) return ScriptType; else if(!strcmp(type, "extension")) return ExtensionType; + else if(!strcmp(type, "effect")) + return EffectType; else return UnknownType; } @@ -96,11 +98,16 @@ Path Package::makeTargetPath(const string &file) const // only allow directory traversal up to the index name path += Path(m_category->name()) + file; break; + case EffectType: + path.append("Effects"); + path.append(m_category->index()->name()); + path += Path(m_category->name()) + file; + break; case ExtensionType: path.append("UserPlugins"); path.append(file, false); break; - default: + case UnknownType: // The package has an unsupported type, so we return an empty path. // The empty path won't be used because the category will reject // this package right away. Maybe the parser should not bother with loading diff --git a/src/package.hpp b/src/package.hpp @@ -32,6 +32,7 @@ public: UnknownType, ScriptType, ExtensionType, + EffectType, }; static Type typeFor(const char *); diff --git a/test/package.cpp b/test/package.cpp @@ -13,13 +13,17 @@ using namespace std; static const char *M = "[package]"; TEST_CASE("package type from string", M) { - SECTION("unknown") { + SECTION("unknown") REQUIRE(Package::typeFor("yoyo") == Package::UnknownType); - } - SECTION("script") { + SECTION("script") REQUIRE(Package::typeFor("script") == Package::ScriptType); - } + + SECTION("extension") + REQUIRE(Package::typeFor("extension") == Package::ExtensionType); + + SECTION("effect") + REQUIRE(Package::typeFor("effect") == Package::EffectType); } TEST_CASE("empty package name", M) { @@ -100,11 +104,14 @@ TEST_CASE("script target path", M) { expected.append("Scripts"); expected.append("Remote Name"); expected.append("Category Name"); - REQUIRE(pack.makeTargetPath() == expected); + + expected.removeLast(); + expected.append("hello_world.lua"); + REQUIRE(pack.makeTargetPath("../../../hello_world.lua") == expected); } -TEST_CASE("script target path: directory traversal", M) { +TEST_CASE("limited directory traversal from category", M) { Index ri("Remote Name"); Category cat("../..", &ri); @@ -117,7 +124,7 @@ TEST_CASE("script target path: directory traversal", M) { REQUIRE(pack.makeTargetPath() == expected); } -TEST_CASE("script target path without category", M) { +TEST_CASE("target path without category", M) { Package pack(Package::ScriptType, "file.name"); try { @@ -143,6 +150,23 @@ TEST_CASE("extension target path", M) { REQUIRE(pack.makeTargetPath("../reaper_reapack.dll") == expected); } +TEST_CASE("effect target path", M) { + Index ri("Remote Name"); + Category cat("Category Name", &ri); + + Package pack(Package::EffectType, "file.name", &cat); + + Path expected; + expected.append("Effects"); + expected.append("Remote Name"); + expected.append("Category Name"); + + REQUIRE(pack.makeTargetPath() == expected); + + expected.removeLast(); + expected.append("hello_world.jsfx"); + REQUIRE(pack.makeTargetPath("../../../hello_world.jsfx") == expected); +} TEST_CASE("full name", M) { SECTION("no category") {