packages feed

marmalade-upload 0.7 → 0.8

raw patch · 5 files changed

+55/−40 lines, 5 filesdep ~exceptionsdep ~mtldep ~networkPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: exceptions, mtl, network, optparse-applicative, transformers

API changes (from Hackage documentation)

- Web.Marmalade: MarmaladeBadRequest :: (Maybe String) -> MarmaladeError
+ Web.Marmalade: MarmaladeBadRequest :: String -> MarmaladeError
- Web.Marmalade: MarmaladeInvalidResponseStatus :: Status -> (Maybe String) -> MarmaladeError
+ Web.Marmalade: MarmaladeInvalidResponseStatus :: Status -> String -> MarmaladeError

Files

CHANGES.md view
@@ -1,3 +1,9 @@+0.8 (Jun 5, 2014)+=================++- Bump dependencies+- Try harder to show reasonable error descriptions+ 0.7 (Apr 28, 2014) ================== 
README.md view
@@ -18,23 +18,43 @@ [stable packages][] now, and bringing Marmalade a big step closer to its passing.  Well done, folks! +[badge-travis]: https://travis-ci.org/lunaryorn/marmalade-upload.svg?branch=master+[travis]: https://travis-ci.org/lunaryorn/marmalade-upload+[badge-hackage]: https://img.shields.io/hackage/v/marmalade-upload.svg?dummy+[hackage]: https://hackage.haskell.org/package/marmalade-upload+[badge-license]: https://img.shields.io/badge/license-MIT-green.svg?dummy+[license]: https://github.com/lunaryorn/marmalade-upload/blob/master/LICENSE+[Marmalade]: http://marmalade-repo.org+[MELPA]: http://melpa.milkbox.net+[stable packages]: https://github.com/milkypostman/melpa#stable-packages+ Installation ------------ -```console-$ cabal install marmalade-upload-```+### Binaries -**OS X**: If this command fails on OS X, either install libmagic with `brew-install libmagic` or use:+- [OS X 10.9](https://github.com/lunaryorn/marmalade-upload/releases/download/0.7/marmalade-upload-0.7_osx-10.9.zip)+- [Linux x86_64](https://github.com/lunaryorn/marmalade-upload/releases/download/0.7/marmalade-upload-0.7_linux-x86_64.zip) +To install, `unzip` the archive, and move the contained `marmalade-upload` file+somewhere into `$PATH`, e.g. `/usr/local/bin/`. +These binaries are statically linked and to not require Haskell or any Haskell+libraries.++### Building from Source++Install [Haskell Platform][] and type the following command to install+marmalade-upload from source:+ ```console-$ cabal install -f '-libmagic' marmalade-upload+$ cabal install marmalade-upload ```  Don't forget to add `~/.cabal/bin` to `$PATH`. +[Haskell Platform]: http://www.haskell.org/platform/+ Usage ----- @@ -66,13 +86,3 @@ 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.--[badge-travis]: https://travis-ci.org/lunaryorn/marmalade-upload.svg?branch=master-[travis]: https://travis-ci.org/lunaryorn/marmalade-upload-[badge-hackage]: https://img.shields.io/hackage/v/marmalade-upload.svg?dummy-[hackage]: https://hackage.haskell.org/package/marmalade-upload-[badge-license]: https://img.shields.io/badge/license-MIT-green.svg?dummy-[license]: https://github.com/lunaryorn/marmalade-upload/blob/master/LICENSE-[Marmalade]: http://marmalade-repo.org-[MELPA]: http://melpa.milkbox.net-[stable packages]: https://github.com/milkypostman/melpa#stable-packages
marmalade-upload.cabal view
@@ -1,5 +1,5 @@ name:                marmalade-upload-version:             0.7+version:             0.8 synopsis:            Upload packages to Marmalade description:   Upload Emacs packages to the <http://marmalade-repo.org/ Marmalade> ELPA@@ -25,7 +25,7 @@ source-repository this   type:              git   location:          https://github.com/lunaryorn/marmalade-upload.git-  tag:               0.7+  tag:               0.8  flag LibMagic   description:       Use libmagic to determine the mimetypes of packages@@ -36,13 +36,13 @@   exposed-modules:     Web.Marmalade   ghc-options:         -Wall   build-depends:       base >=4.6 && <4.8,-                       mtl >=2.1 && <2.2,-                       transformers >=0.3 && <0.4,-                       exceptions >=0.5 && <0.6,+                       mtl >=2.1 && <2.3,+                       transformers >=0.3 && <0.5,+                       exceptions >=0.5 && <0.7,                        bytestring >=0.10 && <1.11,                        utf8-string >=0.3 && <0.4,                        aeson >=0.7 && <0.8,-                       network >=2.4 && <2.5,+                       network >=2.4 && <2.6,                        http-types >=0.8 && <0.9,                        http-client >=0.3 && <0.4   default-language:    Haskell2010@@ -52,7 +52,7 @@   ghc-options:         -Wall   build-depends:       base >=4.6 && <4.8,                        transformers >=0.3 && <0.4,-                       optparse-applicative >=0.8 && <0.9,+                       optparse-applicative >=0.8 && <0.10,                        keyring >=0.1 && <0.2,                        marmalade-upload   default-language:    Haskell2010@@ -62,8 +62,8 @@   main-is:             marmalade-tests.hs   hs-source-dirs:      test/   build-depends:       base >=4.6 && <4.8,-                       transformers >=0.3 && <0.4,-                       exceptions >=0.5 && <0.6,+                       transformers >=0.3 && <0.5,+                       exceptions >=0.5 && <0.7,                        aeson >=0.7 && <0.8,                        tasty >=0.8 && <0.9,                        tasty-hunit >=0.8 && <0.9,
src/Web/Marmalade.hs view
@@ -42,6 +42,7 @@  import qualified Data.Aeson as JSON import qualified Data.ByteString.UTF8 as UTF8+import qualified Data.ByteString.Lazy.UTF8 as UTF8L import qualified Network as N import qualified Network.HTTP.Client as C @@ -56,7 +57,7 @@ import Data.Typeable (Typeable) import Network.HTTP.Client (Manager,Request,Response) import Network.HTTP.Client.MultipartFormData-import Network.HTTP.Types.Header (hUserAgent)+import Network.HTTP.Types.Header (hUserAgent,hAccept) import Network.HTTP.Types.Status (Status(statusCode,statusMessage)) import Text.Printf (printf) @@ -112,12 +113,12 @@                       , marmaladeManager :: Manager }  -- |Errors thrown by Marmalade.-data MarmaladeError = MarmaladeInvalidResponseStatus Status (Maybe String)+data MarmaladeError = MarmaladeInvalidResponseStatus Status String                       -- ^An invalid response from Marmalade, with a status and                       -- probably an error message from Marmalade.                     | MarmaladeInvalidResponseBody ByteString                       -- ^Invalid response body-                    | MarmaladeBadRequest (Maybe String)+                    | MarmaladeBadRequest String                       -- ^A bad request error from Marmalade.                       --                       -- Marmalade raises this error for failed logins and for@@ -129,17 +130,13 @@                       deriving Typeable  instance Show MarmaladeError where-  show (MarmaladeInvalidResponseStatus status (Just message)) =+  show (MarmaladeInvalidResponseStatus status message) =     printf "Marmalade error: Invalid response status: %s (%s)" msgString message     where msgString = UTF8.toString (statusMessage status)-  show (MarmaladeInvalidResponseStatus status Nothing) =-    printf "Marmalade error: Invalid response status: %s" msgString-    where msgString = UTF8.toString (statusMessage status)   show (MarmaladeInvalidResponseBody s) =     "Marmalade error: Invalid response body: " ++ show s-  show (MarmaladeBadRequest (Just message)) =+  show (MarmaladeBadRequest message) =     "Marmalade error: Bad Request: " ++ message-  show (MarmaladeBadRequest Nothing) = "Marmalade error: Bad Request"   show (MarmaladeInvalidPackage f m) =     printf "Marmalade error: %s: invalid package: %s" f m @@ -212,7 +209,8 @@ makeRequest endpoint = do   initReq <- C.parseUrl (marmaladeURL ++ endpoint)   userAgent <- gets marmaladeUserAgent-  return initReq { C.requestHeaders = [(hUserAgent, UTF8.fromString userAgent)]+  return initReq { C.requestHeaders = [(hUserAgent, UTF8.fromString userAgent)+                                      ,(hAccept, "application/json")]                  -- We keep every bad status, because we handle these later                  , C.checkStatus = \_ _ _ -> Nothing                  }@@ -229,7 +227,8 @@     _ -> throwM (MarmaladeInvalidResponseStatus status message)   where body = C.responseBody response         status = C.responseStatus response-        message = fmap messageContents (JSON.decode' body)+        message = maybe (UTF8L.toString body)+                        messageContents (JSON.decode' body)  -- |@'uploadPackage' package@ uploads a @package@ file to Marmalade. --
test/marmalade-tests.hs view
@@ -67,14 +67,14 @@ invalidUsernameAndPassword :: TestTree invalidUsernameAndPassword =   testCase "Invalid username and password" $-  handleJust badRequestWithMessage assertMessage $ do+  handleJust badRequest assertMessage $ do     _ <- runMarmalade testUserAgent auth login     assertFailure "Expected MarmaladeBadRequest not thrown"   where     auth = BasicAuth (Username "marmalade-upload-test-user") (return "test-password")-    badRequestWithMessage (MarmaladeBadRequest msg) = msg-    badRequestWithMessage _ = Nothing-    assertMessage msg = msg @?= "Username or password invalid"+    badRequest (MarmaladeBadRequest msg) = Just msg+    badRequest _ = Nothing+    assertMessage msg = msg @?= "<h1>Bad request</h1><p>bad authentication</p>\r\n"  uploadNonExistingPackage :: TestTree uploadNonExistingPackage =