Skip to content

Commit

Permalink
Add support for binary dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tmspzz committed Jan 4, 2018
1 parent 531fc28 commit f23b4a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/Data/Carthage/Cartfile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ newtype Location = Location { unLocation :: String }
deriving (Eq, Show, Ord)


data RepoHosting = GitHub | Git
data RepoHosting = GitHub | Git | Binary
deriving (Eq, Show)

data CartfileEntry = CartfileEntry { hosting :: RepoHosting
Expand All @@ -46,8 +46,11 @@ parseGitHub = Parsec.string "github" >> Parsec.many1 Parsec.space >> pure GitHub
parseGit :: Parsec.Parsec String () RepoHosting
parseGit = Parsec.string "git" >> Parsec.many1 Parsec.space >> pure Git

parseBinary :: Parsec.Parsec String () RepoHosting
parseBinary = Parsec.string "binary" >> Parsec.many1 Parsec.space >> pure Binary

repoHosting :: Parsec.Parsec String () RepoHosting
repoHosting = Parsec.try parseGit <|> parseGitHub
repoHosting = Parsec.try parseGit <|> parseGitHub <|> parseBinary

quotedContent :: Parsec.Parsec String () String
quotedContent = Parsec.char '"' *> Parsec.parseUnquotedString <* Parsec.char '"'
Expand Down
11 changes: 4 additions & 7 deletions src/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ filterCartfileEntriesByGitRepoNames repoNames cartfileEntries = [c | c <- cartfi
gitRepoNameFromCartfileEntry :: CartfileEntry -> GitRepoName
gitRepoNameFromCartfileEntry (CartfileEntry GitHub (Location l) _) = GitRepoName . T.unpack . last . splitWithSeparator '/' . T.pack $ l
gitRepoNameFromCartfileEntry (CartfileEntry Git (Location l) _) = GitRepoName . T.unpack . T.replace ".git" "" . last . splitWithSeparator '/' . T.pack $ l
gitRepoNameFromCartfileEntry (CartfileEntry Binary (Location l) _) = GitRepoName . T.unpack . T.replace ".json" "" . last . splitWithSeparator '/' . T.pack $ l



Expand Down Expand Up @@ -317,14 +318,10 @@ deriveFrameworkNamesAndVersion romeMap = concatMap (deriveFrameworkNameAndVersio
-- | `FrameworkVersion` by attaching the `Version` information from the
-- | `FrameworkName` in the `CartfileEntry`.
deriveFrameworkNameAndVersion :: RepositoryMap -> CartfileEntry -> [FrameworkVersion]
deriveFrameworkNameAndVersion romeMap cfe@(CartfileEntry GitHub (Location _) v) = map (`FrameworkVersion` v) $
fromMaybe [FrameworkName gitHubRepositoryName] (M.lookup (gitRepoNameFromCartfileEntry cfe) romeMap)
deriveFrameworkNameAndVersion romeMap cfe@(CartfileEntry _ _ v) = map (`FrameworkVersion` v) $
fromMaybe [FrameworkName repositoryName] (M.lookup (gitRepoNameFromCartfileEntry cfe) romeMap)
where
gitHubRepositoryName = unGitRepoName $ gitRepoNameFromCartfileEntry cfe
deriveFrameworkNameAndVersion romeMap cfe@(CartfileEntry Git (Location _) v) = map (`FrameworkVersion` v) $
fromMaybe [FrameworkName gitRepositoryName] (M.lookup (gitRepoNameFromCartfileEntry cfe) romeMap)
where
gitRepositoryName = unGitRepoName $ gitRepoNameFromCartfileEntry cfe
repositoryName = unGitRepoName $ gitRepoNameFromCartfileEntry cfe



Expand Down

0 comments on commit f23b4a4

Please sign in to comment.