packages feed

package-description-remote (empty) → 0.1.0.0

raw patch · 5 files changed

+95/−0 lines, 5 filesdep +Cabaldep +basedep +bytestringsetup-changed

Dependencies added: Cabal, base, bytestring, lens, lens-aeson, package-description-remote, wreq

Files

+ LICENSE view
@@ -0,0 +1,21 @@+The MIT License (MIT)++Copyright (c) 2015 Pedro Tacla Yamada++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ package-description-remote.cabal view
@@ -0,0 +1,37 @@+name:                package-description-remote+version:             0.1.0.0+synopsis:            Fetches a 'GenericPackageDescription' from Hackage+description:         Please see README.md+homepage:            http://github.com/yamadapc/stack-run-auto/package-description-remote+license:             MIT+license-file:        LICENSE+author:              Pedro Tacla Yamada+maintainer:          tacla.yamada@gmail.com+copyright:           Copyright (c) 2015 Pedro Tacla Yamada+category:            Web+build-type:          Simple+cabal-version:       >=1.10++library+  hs-source-dirs:      src+  exposed-modules:     Distribution.PackageDescription.Remote+  build-depends:       Cabal >= 1.22.4.0+                     , base >= 4.7 && < 5+                     , bytestring >= 0.10.6.0+                     , lens >= 4.12.3+                     , lens-aeson >= 1.0.0.5+                     , wreq >= 0.4.0.0+  default-language:    Haskell2010++test-suite package-description-remote-test+  type:                exitcode-stdio-1.0+  hs-source-dirs:      test+  main-is:             Spec.hs+  build-depends:       base+                     , package-description-remote+  ghc-options:         -threaded -rtsopts -with-rtsopts=-N+  default-language:    Haskell2010++source-repository head+  type:     git+  location: https://github.com/yamadapc/stack-run-auto
+ src/Distribution/PackageDescription/Remote.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE OverloadedStrings #-}+module Distribution.PackageDescription.Remote+  where++import           Control.Lens                          ((&), (.~), (^.), (^..))+import           Data.Aeson.Lens                       (key, values, _Integral)+import           Data.ByteString.Lazy.Char8            (unpack)+import           Distribution.PackageDescription       (GenericPackageDescription)+import           Distribution.PackageDescription.Parse (ParseResult (..),+                                                        parsePackageDescription)+import           Network.Wreq                          (defaults, get, getWith,+                                                        header, responseBody)++getPackage :: String -> Integer -> IO (ParseResult GenericPackageDescription)+getPackage pkg revision = do+    res <- get uri+    return $ parsePackageDescription (unpack (res ^. responseBody))+  where+    uri = "http://hackage.haskell.org/package/" ++ pkg ++ "/revision/" +++          show revision++getPackageRevisions :: String -> IO [Integer]+getPackageRevisions pkg = do+    res <- getWith opt uri+    return $ res ^.. responseBody . values . key "number" . _Integral+  where+    opt = defaults & header "Accept" .~ ["application/json"]+    uri = "http://hackage.haskell.org/package/" ++ pkg ++ "/revisions/"++getPackageLatestRevision :: String -> IO Integer+getPackageLatestRevision pkg = do+    revisions <- getPackageRevisions pkg+    return (maximum revisions)
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"