Move package configuration to the configuration file
This commit is contained in:
@ -2,15 +2,16 @@
|
||||
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
obtain one at https://mozilla.org/MPL/2.0/. -}
|
||||
|
||||
-- | Contains data describing packages and how they are should be updated,
|
||||
-- | Contains data describing packages, methods to update them and to request
|
||||
-- information about them.
|
||||
module SlackBuilder.Package
|
||||
( DownloadPlaceholder(..)
|
||||
, Download(..)
|
||||
( Download(..)
|
||||
, DownloadTemplate(..)
|
||||
, PackageDescription(..)
|
||||
, PackageUpdateData(..)
|
||||
, Updater(..)
|
||||
, renderDownloadWithVersion
|
||||
, renderTextWithVersion
|
||||
) where
|
||||
|
||||
import Data.Text (Text)
|
||||
@ -41,18 +42,6 @@ data Download = Download
|
||||
, md5sum :: Digest MD5
|
||||
} 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
|
||||
= StaticPlaceholder Text
|
||||
| VersionPlaceholder
|
||||
deriving Eq
|
||||
|
||||
instance Show DownloadPlaceholder
|
||||
where
|
||||
show (StaticPlaceholder staticPlaceholder) = Text.unpack staticPlaceholder
|
||||
show VersionPlaceholder = "{version}"
|
||||
|
||||
-- | List of URI components, including version placeholders.
|
||||
newtype DownloadTemplate = DownloadTemplate
|
||||
{ unDownloadTemplate :: Text
|
||||
@ -65,7 +54,11 @@ instance Show DownloadTemplate
|
||||
-- | Replaces placeholders in the URL template with the given version.
|
||||
renderDownloadWithVersion :: MonadThrow m => DownloadTemplate -> Text -> m URI
|
||||
renderDownloadWithVersion (DownloadTemplate template) version =
|
||||
URI.mkURI $ Text.replace "{version}" version template
|
||||
URI.mkURI $ renderTextWithVersion template version
|
||||
|
||||
-- | Replaces placeholders in the text with the given version.
|
||||
renderTextWithVersion :: Text -> Text -> Text
|
||||
renderTextWithVersion template version = Text.replace "{version}" version template
|
||||
|
||||
-- | Function used to get the latest version of a source.
|
||||
data Updater = Updater
|
||||
|
Reference in New Issue
Block a user