diff options
Diffstat (limited to 'lib/SlackBuilder')
| -rw-r--r-- | lib/SlackBuilder/Package.hs | 22 |
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 |
