inflections 0.1.0.8 → 0.1.0.9
raw patch · 4 files changed
+48/−7 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Text.Inflections: toCamelCased :: Bool -> String -> String
+ Text.Inflections: toDashed :: String -> String
+ Text.Inflections: toUnderscore :: String -> String
+ Text.Inflections.Parse.Types: mapWord :: (String -> String) -> Word -> Word
Files
- Text/Inflections.hs +35/−0
- Text/Inflections/Parse/Types.hs +5/−1
- inflections.cabal +1/−1
- test/Suite.hs +7/−5
Text/Inflections.hs view
@@ -96,6 +96,10 @@ , parseSnakeCase , parseCamelCase , Transliterations+ -- * Often used combinators+ , toUnderscore+ , toDashed+ , toCamelCased ) where @@ -122,4 +126,35 @@ import Text.Inflections.Parse.SnakeCase ( parseSnakeCase ) +import Text.Inflections.Parse.Types ( mapWord )+ import Text.Inflections.Parse.CamelCase ( parseCamelCase )++import Data.Char ( toLower )++-- | Transforms CamelCasedString to+-- snake_cased_string_with_underscores. Throws exception if parsing failed+toUnderscore :: String -> String+toUnderscore =+ underscore+ . either (error . ("toUnderscore: " ++) . show) id+ . parseCamelCase []++-- | Transforms CamelCasedString to snake-cased-string-with-dashes. Throws+-- exception if parsing failed.+toDashed :: String -> String+toDashed =+ dasherize+ . map (mapWord (map toLower))+ . either (error . ("toDashed: " ++) . show) id+ . parseCamelCase []++-- | Transforms underscored_text to CamelCasedText. If first argument is+-- 'True' then FirstCharacter in result string will be in upper case. If+-- 'False' then firstCharacter will be in lower case. Throws exception if+-- parsing failed+toCamelCased :: Bool -> String -> String+toCamelCased t =+ camelizeCustom t+ . either (error . ("toCamelCased: " ++) . show) id+ . parseSnakeCase []
Text/Inflections/Parse/Types.hs view
@@ -1,4 +1,4 @@-module Text.Inflections.Parse.Types ( Word(..) ) where+module Text.Inflections.Parse.Types ( Word(..), mapWord ) where -- | A 'String' that should be kept whole through applied inflections data Word@@ -10,3 +10,7 @@ | Acronym String deriving (Show, Eq)++mapWord :: (String -> String) -> Word -> Word+mapWord f (Word s) = Word $ f s+mapWord f (Acronym s) = Acronym $ f s
inflections.cabal view
@@ -1,5 +1,5 @@ name: inflections-version: 0.1.0.8+version: 0.1.0.9 synopsis: Inflections library for Haskell description: Inflections provides methods for singularization, pluralization,
test/Suite.hs view
@@ -2,6 +2,7 @@ import Test.Framework (defaultMain) +import qualified Text.InflectionsTest import qualified Text.Inflections.Tests import qualified Text.Inflections.UnderscoreTest import qualified Text.Inflections.OrdinalTest@@ -9,8 +10,9 @@ import qualified Text.Inflections.TitleizeTest main :: IO ()-main = defaultMain $ Text.Inflections.Tests.tests ++- Text.Inflections.UnderscoreTest.tests ++- Text.Inflections.OrdinalTest.tests ++- Text.Inflections.HumanizeTest.tests ++- Text.Inflections.TitleizeTest.tests+main = defaultMain $ Text.InflectionsTest.tests +++ Text.Inflections.Tests.tests +++ Text.Inflections.UnderscoreTest.tests +++ Text.Inflections.OrdinalTest.tests +++ Text.Inflections.HumanizeTest.tests +++ Text.Inflections.TitleizeTest.tests