From 1217c2f5e4adf5b6cd813172f6b3f540cde0ac6c Mon Sep 17 00:00:00 2001 From: Aerex Date: Sun, 13 Sep 2020 01:26:22 -0500 Subject: [PATCH] refactor(tw): Removed unused project_prefix_suffix config --- composer.json | 6 ++++- example-config.yaml | 1 - lib/Configs/TaskwarriorConfig.php | 4 ---- lib/Storages/Taskwarrior.php | 23 ++----------------- tests/Configs/ConfigTest.php | 2 -- tests/Configs/Fixtures/TaskwarriorConfig.yaml | 1 - 6 files changed, 7 insertions(+), 30 deletions(-) diff --git a/composer.json b/composer.json index a68b2c8..d9efd4c 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,9 @@ "url": "https://git.aerex.me/Aerex/baikal-storage-plugin" } ], + "bin": [ + "bin/generateconfig" + ], "require": { "php": ">=5.5", "sabre/dav" : "~4.1.0", @@ -26,7 +29,8 @@ "symfony/config": "3.4", "symfony/process": "^3.4", "monolog/monolog": "^2.0", - "symfony/yaml": "~3.0|~4.0" + "symfony/yaml": "~3.0|~4.0", + "symfony/console": "^3.4|^4.0|^5.0" }, "require-dev": { "phpunit/phpunit": "^8.5.3" diff --git a/example-config.yaml b/example-config.yaml index 48b276c..3aeb833 100755 --- a/example-config.yaml +++ b/example-config.yaml @@ -4,4 +4,3 @@ logger: taskwarrior: taskdata: /home/aerex/.task taskrc: /home/aerex/.taskrc - project_category_prefix: project_ diff --git a/lib/Configs/TaskwarriorConfig.php b/lib/Configs/TaskwarriorConfig.php index e02fcc0..ded3c86 100644 --- a/lib/Configs/TaskwarriorConfig.php +++ b/lib/Configs/TaskwarriorConfig.php @@ -17,10 +17,6 @@ class TaskwarriorConfig { ->defaultValue('~/.taskrc') ->info('The enivronment variable overrides the default and the command line specification of the .taskrc file') ->end() - ->scalarNode('project_category_prefix') - ->defaultValue('project_') - ->info('The word after the given prefix for a iCal category will be used to identify a task\'s project') - ->end() ->end(); return $node; diff --git a/lib/Storages/Taskwarrior.php b/lib/Storages/Taskwarrior.php index 40badaf..6a7237d 100644 --- a/lib/Storages/Taskwarrior.php +++ b/lib/Storages/Taskwarrior.php @@ -33,11 +33,6 @@ class Taskwarrior implements IStorage { $html .= 'The environment variable overrides the default and the command line, and the "data.location" configuration setting of the task data directory'; $html .= ''; $html .= ''; - $html .= ''; - $html .= 'project_category_prefix'; - $html .= "The word after the given prefix for a iCal category will be used to identify a task's project"; - $html .= ''; - $html .= ''; return $html; } @@ -50,10 +45,6 @@ class Taskwarrior implements IStorage { $this->configs['taskdata'] = $postData['tw_taskdata']; } - if (isset($postData['tw_project_category_prefix'])){ - $this->configs['project_category_prefix'] = $postData['tw_project_category_prefix']; - } - return $this->configs; } @@ -164,18 +155,8 @@ class Taskwarrior implements IStorage { } if (isset($vtodo->CATEGORIES)) { - $task['tags'] = []; - foreach ($vtodo->CATEGORIES as $category) { - if (isset($this->configs['project_category_prefix'])) { - $projTagSuffixRegExp = sprintf('/^%s/', $this->configs['project_category_prefix']); - if (preg_match($projTagSuffixRegExp, $category)) { - $task['project'] = preg_replace($projTagSuffixRegExp, '', $category); - continue; - } - } - $task['tags'] = $category; - } - } + $task['tags'] = $vtodo->CATEGORIES->getJsonValue(); + } if (isset($vtodo->GEO)){ $task['geo'] = $vtodo->GEO->getRawMimeDirValue(); diff --git a/tests/Configs/ConfigTest.php b/tests/Configs/ConfigTest.php index 983b482..39c121f 100644 --- a/tests/Configs/ConfigTest.php +++ b/tests/Configs/ConfigTest.php @@ -40,8 +40,6 @@ class ConfigTest extends TestCase { $this->assertEquals($taskwarriorConfigs['taskrc'], '/home/aerex/.taskrc'); $this->assertArrayHasKey('taskdata', $taskwarriorConfigs, 'taskwarrior config is missing taskdata property'); $this->assertEquals($taskwarriorConfigs['taskdata'], '/home/aerex/.task'); - $this->assertArrayHasKey('project_category_prefix', $taskwarriorConfigs, 'taskwarrior config is missing project_category_prefix property'); - $this->assertEquals($taskwarriorConfigs['project_category_prefix'], 'project_'); } } diff --git a/tests/Configs/Fixtures/TaskwarriorConfig.yaml b/tests/Configs/Fixtures/TaskwarriorConfig.yaml index 65f8f3f..63a7751 100755 --- a/tests/Configs/Fixtures/TaskwarriorConfig.yaml +++ b/tests/Configs/Fixtures/TaskwarriorConfig.yaml @@ -6,4 +6,3 @@ storages: taskwarrior: taskdata: /home/aerex/.task taskrc: /home/aerex/.taskrc - project_category_prefix: project_