packages feed

inflections 0.1.0.3 → 0.1.0.4

raw patch · 6 files changed

+49/−14 lines, 6 files

Files

Text/Inflections.hs view
@@ -15,6 +15,9 @@      , transliterate     , transliterateCustom++    , ordinal+    , ordinalize     ) where @@ -32,6 +35,8 @@ import Text.Inflections.Camelize ( camelize, camelizeCustom )  import Text.Inflections.Dasherize ( dasherize, dasherizeCustom )++import Text.Inflections.Ordinal ( ordinal, ordinalize )  -- |Returns a String after default approximations for changing Unicode characters -- to a valid ASCII range are applied. If you want to supplement the default
+ Text/Inflections/Ordinal.hs view
@@ -0,0 +1,21 @@+module Text.Inflections.Ordinal (ordinal, ordinalize)+where++-- |Returns the suffix that should be added to a number to denote the position+-- in an ordered sequence such as 1st, 2nd, 3rd, 4th.+ordinal :: Integer -> String+ordinal number+        | remainder100 `elem` [11..13] = "th"+        | remainder10 == 1             = "st"+        | remainder10 == 2             = "nd"+        | remainder10 == 3             = "rd"+        | otherwise                    = "th"+  where abs_number   = abs number+        remainder10  = abs_number `mod` 10+        remainder100 = abs_number `mod` 100++-- |Turns a number into an ordinal string used to denote the position in an+-- ordered sequence such as 1st, 2nd, 3rd, 4th.+ordinalize :: Integer -> String+ordinalize n = show n ++ ordinal n+
Text/Inflections/Parameterize.hs view
@@ -27,6 +27,7 @@ parameterize :: String -> String parameterize = parameterizeCustom defaultMap +-- |Transliterate a String with a custom transliteration table. parameterizeCustom :: Transliterations -> String -> String parameterizeCustom ts s =     case parsed of
Text/Inflections/Parse/CamelCase.hs view
@@ -9,14 +9,15 @@ import Text.Inflections.Parse.Types (Word(..)) import Text.Inflections.Parse.Acronym (acronym) -word :: P.Stream s m Char => P.ParsecT s u m Word-word = do-  firstChar <- C.upper P.<|> C.lower-  restChars <- P.many C.lower-  return $ Word $ firstChar : restChars-+-- |Recognizes an input String in CamelCase. parser :: P.Stream s m Char => [String] -> P.ParsecT s u m [Word] parser acronyms = do   ws <- P.many $ P.choice [ acronym acronyms, word ]   P.eof   return ws++word :: P.Stream s m Char => P.ParsecT s u m Word+word = do+  firstChar <- C.upper P.<|> C.lower+  restChars <- P.many C.lower+  return $ Word $ firstChar : restChars
inflections.cabal view
@@ -1,5 +1,5 @@ name:                inflections-version:             0.1.0.3+version:             0.1.0.4 synopsis:            Inflections library for Haskell description:   Inflections provides methods for singularization, pluralization, dasherizing, etc. The library is based on Rails' inflections library.@@ -20,16 +20,21 @@  library   exposed-modules:       Text.Inflections-                       , Text.Inflections.Parse.CamelCase-                       , Text.Inflections.Parse.SnakeCase-                       , Text.Inflections.Parse.Parameterizable-                       , Text.Inflections.Parse.Types+   other-modules:         Text.Inflections.Data                        , Text.Inflections.Parameterize                        , Text.Inflections.Underscore                        , Text.Inflections.Camelize-                       , Text.Inflections.Parse.Acronym                        , Text.Inflections.Dasherize+                       , Text.Inflections.Ordinal++                       , Text.Inflections.Parse.Acronym+                       , Text.Inflections.Parse.SnakeCase+                       , Text.Inflections.Parse.Parameterizable+                       , Text.Inflections.Parse.CamelCase+                       , Text.Inflections.Parse.Types++   ghc-options:         -Wall   build-depends:       base >=4.5 && <4.7, parsec, containers   default-language:    Haskell2010
test/Suite.hs view
@@ -3,8 +3,10 @@ import  Test.Framework (defaultMain)  import qualified Text.Inflections.Tests-import qualified Text.Inflections.Parse.CamelCaseTest+import qualified Text.Inflections.UnderscoreTest+import qualified Text.Inflections.OrdinalTest  main :: IO () main = defaultMain $ Text.Inflections.Tests.tests ++-                     Text.Inflections.Parse.CamelCaseTest.tests+                     Text.Inflections.UnderscoreTest.tests +++                     Text.Inflections.OrdinalTest.tests