summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Network/Gravatar.hs13
-rw-r--r--gravatar.cabal14
-rw-r--r--tests/tests.hs5
3 files changed, 26 insertions, 6 deletions
diff --git a/Network/Gravatar.hs b/Network/Gravatar.hs
index 12fe9f1..c9a9c3f 100644
--- a/Network/Gravatar.hs
+++ b/Network/Gravatar.hs
@@ -13,6 +13,15 @@
-- Return the URL of a gravatar image - an image associated with an
-- email address.
--
+-- Simple use:
+--
+-- > > gravatar "dons@galois.com"
+-- > "http://www.gravatar.com/avatar.php?gravatar_id=f21827076a1d0725c4f4bd5a640102e9"
+--
+-- Optional arguments to specify the maximum classification rating
+-- allowed, a size of the image (between 1 and 80 pixels) and a default url
+-- to redirect to are provided by 'gravatarWith'.
+--
module Network.Gravatar (
gravatar, gravatarWith
@@ -35,6 +44,7 @@ data Rating = G | PG | R | X
-- | An image size in pixels from 1 to 80.
newtype Size = Size Int
+ deriving (Eq,Ord,Show)
-- | A smart constructor for the Size type, ensuring it is between 1 and 80
size :: Int -> Maybe Size
@@ -53,7 +63,8 @@ gravatar :: String -> String
gravatar who = gravatarWith who Nothing Nothing Nothing
-- | Construct the url of a gravatar with optional classification
--- ratings, an optional size, and optional default image.
+-- rating to limit to, an optional size in pixels, and optional default
+-- url to redirect to, should no image be found.
--
gravatarWith :: String
-> Maybe Rating
diff --git a/gravatar.cabal b/gravatar.cabal
index 64fc580..a4451fe 100644
--- a/gravatar.cabal
+++ b/gravatar.cabal
@@ -1,12 +1,16 @@
name: gravatar
-version: 0.2
+version: 0.3
homepage: http://code.haskell.org/~dons/code/gravatar
synopsis: Find the url of the gravatar associated with an email address.
description:
- Gravatars (<http://gravatar.com>) are globally unique images associated with an email
- address, widely used in social networking sites. This library
- lets you find the URL of a gravatar .png associated with an email
- address.
+ Gravatars (<http://gravatar.com>) are globally unique images
+ associated with an email address, widely used in social networking
+ sites. This library lets you find the URL of a gravatar image
+ associated with an email address.
+ .
+ Test coverage data for this library is available at:
+ <http://code.haskell.org/~dons/tests/gravatar/hpc_index.html>
+ .
category: Network
license: BSD3
license-file: LICENSE
diff --git a/tests/tests.hs b/tests/tests.hs
index 2964df0..60ab08e 100644
--- a/tests/tests.hs
+++ b/tests/tests.hs
@@ -5,3 +5,8 @@ main = do
print $ (gravatarWith "dons@galois.com" (Just R) Nothing (Just "http://haskell.org") ) == "http://www.gravatar.com/avatar.php?gravatar_id=f21827076a1d0725c4f4bd5a640102e9&rating=R&default=http%3A%2F%2Fhaskell.org"
+ print $ (gravatarWith "dons@galois.com" (Just R) (size 20) (Just "http://haskell.org") ) == "http://www.gravatar.com/avatar.php?gravatar_id=f21827076a1d0725c4f4bd5a640102e9&rating=R&size=20&default=http%3A%2F%2Fhaskell.org"
+
+ -- illegal size
+ print $ (gravatarWith "dons@galois.com" (Just R) (size 200) (Just "http://haskell.org") ) == "http://www.gravatar.com/avatar.php?gravatar_id=f21827076a1d0725c4f4bd5a640102e9&rating=R&default=http%3A%2F%2Fhaskell.org"
+