summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-09-01 17:34:24 +0200
committerEugen Wissner <belka@caraus.de>2024-09-01 17:34:24 +0200
commit4f74c2ec10682b4725a413894c67063817810582 (patch)
treec24ab4900ecbb76271cb11a653d34014ea50628b /lib
parent14cc805dcfce79ab699ebb83261749a3a1c227fd (diff)
downloadslackbuilder-4f74c2ec10682b4725a413894c67063817810582.tar.gz
Support text based placeholders
Diffstat (limited to 'lib')
-rw-r--r--lib/SlackBuilder/Package.hs22
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/SlackBuilder/Package.hs b/lib/SlackBuilder/Package.hs
index f9faff1..5f8472e 100644
--- a/lib/SlackBuilder/Package.hs
+++ b/lib/SlackBuilder/Package.hs
@@ -9,12 +9,10 @@ module SlackBuilder.Package
, DownloadTemplate(..)
, PackageDescription(..)
, PackageUpdateData(..)
- , Maintainer(..)
, Updater(..)
, renderDownloadWithVersion
) where
-import Data.List.NonEmpty (NonEmpty(..))
import Data.Text (Text)
import qualified Data.Text as Text
import Text.URI (URI(..))
@@ -43,12 +41,6 @@ data Download = Download
, md5sum :: Digest MD5
} deriving (Eq, Show)
--- | Package maintainer information.
-data Maintainer = Maintainer
- { name :: Text
- , email :: Text
- } deriving (Eq, Show)
-
-- | Appears in the download URI template and specifies which part of the URI
-- should be replaced with the package version.
data DownloadPlaceholder
@@ -62,20 +54,18 @@ instance Show DownloadPlaceholder
show VersionPlaceholder = "{version}"
-- | List of URI components, including version placeholders.
-newtype DownloadTemplate = DownloadTemplate (NonEmpty DownloadPlaceholder)
- deriving Eq
+newtype DownloadTemplate = DownloadTemplate
+ { unDownloadTemplate :: Text
+ } deriving Eq
instance Show DownloadTemplate
where
- show (DownloadTemplate components) = concatMap show components
+ show = Text.unpack . unDownloadTemplate
-- | Replaces placeholders in the URL template with the given version.
renderDownloadWithVersion :: MonadThrow m => DownloadTemplate -> Text -> m URI
-renderDownloadWithVersion (DownloadTemplate components) version =
- URI.mkURI $ foldr f "" components
- where
- f (StaticPlaceholder staticPlaceholder) = (staticPlaceholder <>)
- f VersionPlaceholder = (version <>)
+renderDownloadWithVersion (DownloadTemplate template) version =
+ URI.mkURI $ Text.replace "{version}" version template
-- | Function used to get the latest version of a source.
data Updater = Updater