-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update stack.yaml * Update stack.yaml * Changed yaml files to use string-random-0.1.4.3 * Changed yaml files to use text-2.0.2 * Changed yaml files * Changed yaml files * Changed yaml files * Changed yaml files * Changed yaml files * Changed package.yaml file * Changed yaml files * Added stack-lts-2* yaml files * Changed workflow yaml file * Changed workflow yaml file * Changed workflow yaml file * Changed workflow yaml file * Changed stack.yaml file * Changed stack.yaml file * Changed stack.yaml file * Changed stack.yaml file * Added commentary to test/AddressSpec.hs about the reason of random tests failures * Added commentary to test/AddressSpec.hs about the reason of random tests failures * Changed stack.yaml * Added missed data-files in fakedata.cabal * Accepted changes proposed by psibi * Accepted changes proposed by psibi for stack.yaml * Accepted changes proposed by psibi for stack.yaml * Fixed .github/workflows/tests.yml * Added dist/cabal-config-flags to .gitignore file * Removed unneeded binary files * Removed formatting and the commentary * Sanitized fake email domain * Added hyphen into domain name checker in test/TextSpec.hs * Changed domain name checker in test/TextSpec.hs
- Loading branch information
1 parent
0e4dabe
commit 4c23f19
Showing
5 changed files
with
30 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: fakedata | ||
version: 1.0.3 | ||
version: 1.0.4 | ||
github: "psibi/fakedata" | ||
license: BSD3 | ||
author: "Sibi Prabakaran" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,8 @@ module Faker.Company | |
) where | ||
|
||
import Data.Monoid ((<>)) | ||
import Data.Text | ||
import Data.Text (Text) | ||
import qualified Data.Text as T | ||
import qualified Data.Vector as V | ||
import Faker | ||
import Faker.Internal | ||
|
@@ -44,7 +45,7 @@ bs = | |
Fake | ||
(\settings -> do | ||
vec :: V.Vector (V.Vector Text) <- companyBsProvider settings | ||
let item :: V.Vector (IO Text) = V.map (\v -> rvec settings v) vec | ||
let item :: V.Vector (IO Text) = V.map (rvec settings) vec | ||
item' :: IO (V.Vector Text) = sequence item | ||
items <- item' | ||
let txt = V.foldl1' (\a b -> a <> " " <> b) items | ||
|
@@ -72,27 +73,31 @@ domain :: Fake Text | |
domain = do | ||
suffix <- F.domainSuffix | ||
companyName <- name | ||
pure $ fixupName companyName <> "." <> suffix | ||
pure $ sanitise companyName <> "." <> suffix | ||
where | ||
-- Replaces spaces with hyphens and filters out anything that isn't an | ||
-- alphanumeric character or a hyphen, so the domain has a better chance of | ||
-- conforming to RFC 1035. | ||
-- | ||
-- See: https://datatracker.ietf.org/doc/html/rfc1035#section-2.3.1 | ||
sanitise :: Text -> Text | ||
sanitise = T.filter (\c -> isAlphaNum c || c == '-') . T.replace " " "-" | ||
|
||
-- | Generates an email like "[email protected]" | ||
-- | ||
-- @since 0.8.1 | ||
-- | ||
email :: Fake Text | ||
email = do | ||
humanName <- F.name | ||
number <- F.fromRange @Int (0, 999999999) -- reasonable uniqueness | ||
domainName <- domain | ||
let numText :: Text | ||
numText = pack $ show number | ||
pure $ fixupName humanName <> "-" <> numText <> "@" <> domainName | ||
|
||
-- | Ensures the spaces are replaced by "_", | ||
-- and no special characters are in the name. | ||
-- So "Elizabeth Warder!" becomes "Elizabeth_Warder". | ||
-- Any fancy symbols such as "!@#$" etc are filtered out. | ||
-- | ||
-- @since 0.8.1 | ||
-- | ||
fixupName :: Text -> Text | ||
fixupName = Data.Text.filter (\c -> isAlphaNum c || c == '_') . replace " " "_" | ||
numText = T.pack $ show number | ||
pure $ sanitise humanName <> "-" <> numText <> "@" <> domainName | ||
where | ||
-- Ensures the spaces are replaced by "_", | ||
-- and no special characters are in the name. | ||
-- So "Elizabeth Warder!" becomes "Elizabeth_Warder". | ||
-- Any fancy symbols such as "!@#$" etc are filtered out. | ||
sanitise :: Text -> Text | ||
sanitise = T.filter (\c -> isAlphaNum c || c == '_') . T.replace " " "_" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters