]> gitweb.michael.orlitzky.com - dead/harbl.git/blobdiff - src/Network/DNS/RBL/Site.hs
Rename DnsblSite to Site.
[dead/harbl.git] / src / Network / DNS / RBL / Site.hs
similarity index 82%
rename from src/Network/DNS/RBL/DnsblSite.hs
rename to src/Network/DNS/RBL/Site.hs
index d23dfb1c2c73a035e61c144501f59b4b8c29bc5b..de3cae460637fe701ac477b760b394135b50527d 100644 (file)
@@ -1,6 +1,6 @@
--- | This module contains the 'DnsblSite' data type representing one
---   blacklist with its associated return codes and weight. For example,
---   in Postfix's main.cf you might have,
+-- | This module contains the 'Site' data type representing one
+--   blacklist with its associated return codes and weight. For
+--   example, in Postfix's main.cf you might have,
 --
 --     postscreen_dnsbl_sites = bl.mailspike.net=127.0.0.[2;10;11]*2, ...
 --
@@ -8,9 +8,9 @@
 --   return code pattern is \"127.0.0.[2;10;11]\", and the weight is
 --   \"2".
 --
-module Network.DNS.RBL.DnsblSite (
-  dnsbl_site_tests,
-  dnsbl_sites )
+module Network.DNS.RBL.Site (
+  site_tests,
+  sites )
 where
 
 import Data.List ( intercalate )
@@ -43,7 +43,7 @@ instance Pretty Weight where
   pretty_show (Weight w) = show w
 
 
--- | Parse the weight multiplier at the end of a dnsbl_site.
+-- | Parse the weight multiplier at the end of a site.
 --
 --   ==== _Examples_
 --
@@ -97,7 +97,7 @@ weight = try parse_weight <|> return (Weight 1)
 --   (DNS) name, a pattern of addresses to use for a \"hit\", and a
 --   weight multiplier.
 --
-data DnsblSite = DnsblSite UserDomain (Maybe IPv4Pattern) Weight
+data Site = Site UserDomain (Maybe IPv4Pattern) Weight
 
 
 -- | Pretty print DNSBL sites. This is straightforward except for the
@@ -110,8 +110,8 @@ data DnsblSite = DnsblSite UserDomain (Maybe IPv4Pattern) Weight
 --   to just choose one of these behaviors rather than pass around a
 --   @Maybe Weight@. We always print the multiplier, even when it's @1@.
 --
-instance Pretty DnsblSite where
-  pretty_show (DnsblSite d p w) =
+instance Pretty Site where
+  pretty_show (Site d p w) =
     (pretty_show d) ++ pattern_string ++ "*" ++ (pretty_show w)
     where
       pattern_string = case p of
@@ -119,40 +119,40 @@ instance Pretty DnsblSite where
                          Just pat -> "=" ++ pretty_show pat
 
 
--- | Parse a single 'DnsblSite'.
+-- | Parse a single 'Site'.
 --
 --   ==== _Examples_
 --
 --   >>> import Text.Parsec ( parse )
 --
 --   >>> let spamhaus = "zen.spamhaus.org*3"
---   >>> pretty_print $ parse dnsbl_site "" spamhaus
+--   >>> pretty_print $ parse site "" spamhaus
 --   zen.spamhaus.org*3
 --
 --   >>> let mailspike = "bl.mailspike.net=127.0.0.[2;10;11]*2"
---   >>> pretty_print $ parse dnsbl_site "" mailspike
+--   >>> pretty_print $ parse site "" mailspike
 --   bl.mailspike.net=127.0.0.[2;10;11]*2
 --
 --   If the weight is left unspecified, it defaults to \"1\" which is
 --   then printed:
 --
 --   >>> let hostkarma = "hostkarma.junkemailfilter.com=127.0.0.2"
---   >>> pretty_print $ parse dnsbl_site "" hostkarma
+--   >>> pretty_print $ parse site "" hostkarma
 --   hostkarma.junkemailfilter.com=127.0.0.2*1
 --
 --   >>> let ubl = "ubl.unsubscore.com"
---   >>> pretty_print $ parse dnsbl_site "" ubl
+--   >>> pretty_print $ parse site "" ubl
 --   ubl.unsubscore.com*1
 --
-dnsbl_site :: Parser DnsblSite
-dnsbl_site = do
+site :: Parser Site
+site = do
   d <- user_domain
   return_codes <- optionMaybe $ char '=' >> v4pattern
   w <- weight
-  return $ DnsblSite d return_codes w
+  return $ Site d return_codes w
 
 
--- | Parse more than one 'DnsblSite', separated by commas and/or
+-- | Parse more than one 'Site', separated by commas and/or
 --   whitespace.
 --
 --   ==== _Examples_
@@ -164,13 +164,13 @@ dnsbl_site = do
 --   >>> let spamhaus = "zen.spamhaus.org*3"
 --   >>> let mailspike = "bl.mailspike.net=127.0.0.[2;10;11]*2"
 --   >>> let bl_list = spamhaus ++ "," ++ mailspike
---   >>> pretty_print $ parse dnsbl_sites "" bl_list
+--   >>> pretty_print $ parse sites "" bl_list
 --   ["zen.spamhaus.org*3","bl.mailspike.net=127.0.0.[2;10;11]*2"]
 --   >>> let bl_list = spamhaus ++ " ,   " ++ mailspike
---   >>> pretty_print $ parse dnsbl_sites "" bl_list
+--   >>> pretty_print $ parse sites "" bl_list
 --   ["zen.spamhaus.org*3","bl.mailspike.net=127.0.0.[2;10;11]*2"]
 --   >>> let bl_list = spamhaus ++ " " ++ mailspike
---   >>> pretty_print $ parse dnsbl_sites "" bl_list
+--   >>> pretty_print $ parse sites "" bl_list
 --   ["zen.spamhaus.org*3","bl.mailspike.net=127.0.0.[2;10;11]*2"]
 --
 --   Any whitespace, in fact, should work:
@@ -178,31 +178,31 @@ dnsbl_site = do
 --   >>> let spamhaus = "zen.spamhaus.org*3"
 --   >>> let mailspike = "bl.mailspike.net=127.0.0.[2;10;11]*2"
 --   >>> let bl_list = spamhaus ++ "\n,\t   \t\r" ++ mailspike
---   >>> pretty_print $ parse dnsbl_sites "" bl_list
+--   >>> pretty_print $ parse sites "" bl_list
 --   ["zen.spamhaus.org*3","bl.mailspike.net=127.0.0.[2;10;11]*2"]
 --
-dnsbl_sites :: Parser [DnsblSite]
-dnsbl_sites = dnsbl_site `sepBy1` many1 (choice [char ',', space])
+sites :: Parser [Site]
+sites = site `sepBy1` many1 (choice [char ',', space])
 
 
 
 -- * Tests
 
-dnsbl_site_tests :: TestTree
-dnsbl_site_tests =
+site_tests :: TestTree
+site_tests =
   testGroup
-    "DnsblSite tests"
+    "Site tests"
     [ test_full_maincf_sites_parsed ]
 
 
 -- | This is a sample \"postscreen_dnsbl_sites\" from a real main.cf.
---   We should be able to parse it as a list of 'DnsblSite's.
+--   We should be able to parse it as a list of 'Site's.
 --
 test_full_maincf_sites_parsed :: TestTree
 test_full_maincf_sites_parsed =
   testCase "a full main.cf list of postscreen_dnsbl_sites is parsed" $ do
     -- Whatever, it's a test.
-    let actual = pretty_show $ parse dnsbl_sites "" input
+    let actual = pretty_show $ parse sites "" input
     actual @?= expected
     where
       input = intercalate ",\n\t" [