Skip to content

Commit

Permalink
Add a FileLabel for .service files.
Browse files Browse the repository at this point in the history
  • Loading branch information
clumens committed Jul 28, 2017
1 parent 9512d88 commit 8ef6ae6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
6 changes: 4 additions & 2 deletions importer/BDCS/Label/FileLabels.hs
Expand Up @@ -23,14 +23,16 @@ import Database.Esqueleto(Key, SqlPersistT)
import BDCS.DB(Files(..), FileKeyValues(..))
import qualified BDCS.Label.Docs as Docs
import qualified BDCS.Label.Library as Library
import BDCS.Label.Utils(addLabelKey)
import qualified BDCS.Label.Service as Service
import BDCS.Label.Types(Label(..))
import BDCS.Label.Utils(addLabelKey)

import Utils.Monad(concatForM)

checks :: [(Files -> Bool, Label)]
checks = [(Docs.matches, DocsLabel),
(Library.matches, LibraryLabel)]
(Library.matches, LibraryLabel),
(Service.matches, ServiceLabel)]

apply :: MonadIO m => [(Files, Key Files)] -> SqlPersistT m [Key FileKeyValues]
apply lst =
Expand Down
29 changes: 29 additions & 0 deletions importer/BDCS/Label/Service.hs
@@ -0,0 +1,29 @@
-- Copyright (C) 2017 Red Hat, Inc.
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}

module BDCS.Label.Service(matches)
where

import qualified Data.Text as T
import System.FilePath.Posix(takeExtension)

import BDCS.DB(Files(..))

matches :: Files -> Bool
matches Files{..} =
takeExtension (T.unpack filesPath) == ".service"
1 change: 1 addition & 0 deletions importer/BDCS/Label/Types.hs
Expand Up @@ -22,6 +22,7 @@ import Database.Persist.TH

data Label = DocsLabel
| LibraryLabel
| ServiceLabel
deriving(Eq, Read, Show)

derivePersistField "Label"
1 change: 1 addition & 0 deletions importer/db.cabal
Expand Up @@ -29,6 +29,7 @@ library
BDCS.Label.Docs,
BDCS.Label.FileLabels,
BDCS.Label.Library,
BDCS.Label.Service,
BDCS.Label.Types,
BDCS.Label.Utils,
BDCS.Packages,
Expand Down

0 comments on commit 8ef6ae6

Please sign in to comment.