reapack

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

commit 3802b5b268a9ca18599ea2bd8cc50e3439e7bd02
parent 103ac3b767df90299de44f0446dff9bec7eb469d
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue,  2 Feb 2016 00:14:51 -0500

move author metadata to individual versions

Diffstat:
Msrc/about.cpp | 15++++++++-------
Msrc/index_v1.cpp | 6+++---
Msrc/package.hpp | 4----
Msrc/version.hpp | 5+++++
Mtest/index_v1.cpp | 14++++++++------
Atest/indexes/v1/ReaPack/author.xml | 9+++++++++
Dtest/indexes/v1/ReaPack/developer_name.xml | 9---------
Mtest/package.cpp | 8--------
Mtest/version.cpp | 8++++++++
9 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -43,6 +43,7 @@ void About::onInit() m_cats->onSelect(bind(&About::updatePackages, this)); #ifdef _WIN32 + // dirty hacks... const int NAME_SIZE = 330; #else const int NAME_SIZE = 382; @@ -51,7 +52,7 @@ void About::onInit() m_packages = createControl<ListView>(IDC_PACKAGES, ListView::Columns{ {AUTO_STR("Name"), NAME_SIZE}, {AUTO_STR("Version"), 80}, - {AUTO_STR("Developer"), 90}, + {AUTO_STR("Author"), 90}, }); m_tabs = createControl<TabBar>(IDC_TABS, TabBar::Tabs{ @@ -80,11 +81,9 @@ void About::onCommand(const int id) void About::populate() { - const auto_string &name = make_autostring(m_index->name()); - auto_char title[255] = {}; + const auto_string &name = make_autostring(m_index->name()); auto_snprintf(title, sizeof(title), AUTO_STR("About %s"), name.c_str()); - SetWindowText(handle(), title); const char *tmpRtf = \ @@ -98,6 +97,7 @@ void About::populate() ; if(!m_about->setRichText(tmpRtf)) { + // if description is invalid or empty, don't display it m_tabs->removeTab(0); m_tabs->setCurrentIndex(0); } @@ -133,11 +133,12 @@ void About::updatePackages() m_packages->clear(); for(Package *pkg : *pkgList) { + Version *lastVer = pkg->lastVersion(); const auto_string &name = make_autostring(pkg->name()); - const auto_string &author = make_autostring(pkg->author()); - const auto_string &lastVer = make_autostring(pkg->lastVersion()->name()); + const auto_string &version = make_autostring(lastVer->name()); + const auto_string &author = make_autostring(lastVer->author()); - m_packages->addRow({name, lastVer, + m_packages->addRow({name, version, author.empty() ? AUTO_STR("Unknown") : author}); } diff --git a/src/index_v1.cpp b/src/index_v1.cpp @@ -81,9 +81,6 @@ void LoadPackageV1(TiXmlElement *packNode, Category *cat) Package *pack = new Package(Package::ConvertType(type), name, cat); unique_ptr<Package> ptr(pack); - const char *author = packNode->Attribute("author"); - if(author) pack->setAuthor(author); - TiXmlElement *verNode = packNode->FirstChildElement("version"); while(verNode) { @@ -105,6 +102,9 @@ void LoadVersionV1(TiXmlElement *verNode, Package *pkg) Version *ver = new Version(name, pkg); unique_ptr<Version> ptr(ver); + const char *author = verNode->Attribute("author"); + if(author) ver->setAuthor(author); + TiXmlElement *node = verNode->FirstChildElement("source"); while(node) { diff --git a/src/package.hpp b/src/package.hpp @@ -43,9 +43,6 @@ public: const std::string &name() const { return m_name; } std::string fullName() const; - void setAuthor(const std::string &author) { m_author = author; } - const std::string &author() const { return m_author; } - void addVersion(Version *ver); const VersionSet &versions() const { return m_versions; } Version *version(const size_t i) const; @@ -58,7 +55,6 @@ private: Type m_type; std::string m_name; - std::string m_author; VersionSet m_versions; }; diff --git a/src/version.hpp b/src/version.hpp @@ -37,6 +37,10 @@ public: uint64_t code() const { return m_code; } Package *package() const { return m_package; } + + void setAuthor(const std::string &author) { m_author = author; } + const std::string &author() const { return m_author; } + void setChangelog(const std::string &); const std::string &changelog() const { return m_changelog; } @@ -58,6 +62,7 @@ private: Package *m_package; Source *m_mainSource; + std::string m_author; std::string m_changelog; std::multimap<Path, Source *> m_sources; std::set<Path> m_files; diff --git a/test/index_v1.cpp b/test/index_v1.cpp @@ -69,14 +69,15 @@ TEST_CASE("null package type", M) { } } -TEST_CASE("read package developer", M) { +TEST_CASE("read version author", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("developer_name"); + RemoteIndex *ri = RemoteIndex::load("author"); RIPTR(ri); CHECK(ri->packages().size() == 1); - REQUIRE(ri->category(0)->package(0)->author() == "Watanabe Saki"); + REQUIRE(ri->category(0)->package(0)->lastVersion()->author() + == "Watanabe Saki"); } TEST_CASE("invalid version tag", M) { @@ -120,6 +121,8 @@ TEST_CASE("null source file", M) { RemoteIndex *ri = RemoteIndex::load("missing_source_file"); RIPTR(ri); + CHECK(ri->packages().size() == 1); + Package *pkg = ri->category(0)->package(0); REQUIRE(pkg->version(0)->source(0)->file() == pkg->name()); } @@ -130,6 +133,7 @@ TEST_CASE("default platform", M) { RemoteIndex *ri = RemoteIndex::load("missing_platform"); RIPTR(ri); + CHECK(ri->packages().size() == 1); REQUIRE(ri->category(0)->package(0)->version(0)->source(0)->platform() == Source::GenericPlatform); } @@ -140,9 +144,7 @@ TEST_CASE("version changelog", M) { RemoteIndex *ri = RemoteIndex::load("changelog"); RIPTR(ri); - CHECK_FALSE(ri->categories().empty()); - CHECK_FALSE(ri->category(0)->packages().empty()); - CHECK_FALSE(ri->category(0)->package(0)->versions().empty()); + CHECK(ri->packages().size() == 1); REQUIRE(ri->category(0)->package(0)->version(0)->changelog() == "Hello\nWorld"); diff --git a/test/indexes/v1/ReaPack/author.xml b/test/indexes/v1/ReaPack/author.xml @@ -0,0 +1,9 @@ +<index version="1"> + <category name="catname"> + <reapack name="packname" type="script"> + <version name="1.0" author="Watanabe Saki"> + <source platform="all" file="filename">https://google.com/</source> + </version> + </reapack> + </category> +</index> diff --git a/test/indexes/v1/ReaPack/developer_name.xml b/test/indexes/v1/ReaPack/developer_name.xml @@ -1,9 +0,0 @@ -<index version="1"> - <category name="catname"> - <reapack name="packname" author="Watanabe Saki" type="script"> - <version name="1.0"> - <source platform="all" file="filename">https://google.com/</source> - </version> - </reapack> - </category> -</index> diff --git a/test/package.cpp b/test/package.cpp @@ -142,11 +142,3 @@ TEST_CASE("full name", M) { REQUIRE(pack.fullName() == "Remote Name/Category Name/file.name"); } } - -TEST_CASE("package developer", M) { - Package pack(Package::ScriptType, "packname"); - CHECK(pack.author().empty()); - - pack.setAuthor("cfillion"); - REQUIRE(pack.author() == "cfillion"); -} diff --git a/test/version.cpp b/test/version.cpp @@ -185,6 +185,14 @@ TEST_CASE("drop sources for unknown platforms", M) { REQUIRE(ver.sources().size() == 0); } +TEST_CASE("version author", M) { + Version ver("1.0"); + CHECK(ver.author().empty()); + + ver.setAuthor("cfillion"); + REQUIRE(ver.author() == "cfillion"); +} + #ifdef __APPLE__ TEST_CASE("drop windows sources on os x", M) { MAKE_VERSION