conferer-hspec (empty) → 0.1.0.1
raw patch · 6 files changed
+167/−0 lines, 6 filesdep +basedep +confererdep +conferer-hspecsetup-changed
Dependencies added: base, conferer, conferer-hspec, hspec, hspec-core, text
Files
- LICENSE +21/−0
- README.md +1/−0
- Setup.hs +2/−0
- conferer-hspec.cabal +56/−0
- src/Conferer/FetchFromConfig/Hspec.hs +86/−0
- test/Spec.hs +1/−0
+ LICENSE view
@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2019 Lucas David Traverso++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
+ README.md view
@@ -0,0 +1,1 @@+# conferer-hspec
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ conferer-hspec.cabal view
@@ -0,0 +1,56 @@+cabal-version: 1.18++-- This file has been generated from package.yaml by hpack version 0.31.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 300a44cd4387c2dd01e079c306841d050c3ccb2458a707f70116faf40a022380++name: conferer-hspec+version: 0.1.0.1+synopsis: conferer's FromConfig instances for hspec Config++description: Library to abstract the parsing of many haskell config values from different config sources+category: Configuration+homepage: https://github.com/ludat/conferer#readme+author: Lucas David Traverso+maintainer: lucas6246@gmail.com+copyright: MIT+license: BSD3+license-file: LICENSE+build-type: Simple+extra-doc-files:+ README.md+ LICENSE++library+ exposed-modules:+ Conferer.FetchFromConfig.Hspec+ other-modules:+ Paths_conferer_hspec+ hs-source-dirs:+ src+ default-extensions: OverloadedStrings LambdaCase QuasiQuotes ScopedTypeVariables+ build-depends:+ base >=4.3 && <5+ , conferer >=0.1.0.3 && <0.2.0.0+ , hspec-core >=2.0.0 && <2.8.0+ , text >=1.1 && <1.3+ default-language: Haskell2010++test-suite conferer-hspec-test+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ other-modules:+ Paths_conferer_hspec+ hs-source-dirs:+ test+ default-extensions: OverloadedStrings LambdaCase QuasiQuotes ScopedTypeVariables+ build-depends:+ base >=4.3 && <5+ , conferer >=0.1.0.3 && <0.2.0.0+ , conferer-hspec+ , hspec+ , hspec-core >=2.0.0 && <2.8.0+ , text >=1.1 && <1.3+ default-language: Haskell2010
+ src/Conferer/FetchFromConfig/Hspec.hs view
@@ -0,0 +1,86 @@+{-# LANGUAGE CPP #-}+module Conferer.FetchFromConfig.Hspec+ (+ -- * How to use this+ -- | FetchFromConfig instance for snap server configuration+ --+ -- @+ -- import Conferer+ -- import Conferer.FetchFromConfig.Snap ()+ --+ -- main = do+ -- config <- 'defaultConfig' \"awesomeapp\"+ -- snapConfig <- 'getFromConfig' \"snap\" config+ -- @+ --+ -- * Internal utility functions+ -- | These may be useful for someone but are subject to change at any point so+ -- use with care+ ) where++import Conferer.Core+import Conferer.Types+import Conferer.FetchFromConfig.Basics++import Data.Either (rights)+import Data.String (fromString)+import Data.Text (Text, unpack, toLower)++import qualified Test.Hspec.Core.Runner as Hspec+import qualified Test.Hspec.Core.Formatters as Hspec++instance FetchFromConfig Hspec.ColorMode where+ fetch =+ fetchFromConfigWith+ (\t -> case t of+ "ColorAuto" -> Just Hspec.ColorAuto+ "ColorNever" -> Just Hspec.ColorNever+ "ColorAlways" -> Just Hspec.ColorAlways+ _ -> Nothing+ )++instance FetchFromConfig Hspec.Formatter where+ fetch =+ fetchFromConfigWith+ (\t -> case toLower t of+ "silent" -> Just Hspec.silent+ "specdoc" -> Just Hspec.specdoc+ "progress" -> Just Hspec.progress+ "failed_examples" -> Just Hspec.failed_examples+ _ -> Nothing+ )++instance FetchFromConfig Hspec.Config where+ fetch k config = do+ pure (Right Hspec.defaultConfig)+ >>= findKeyAndApplyConfig config k "dry-run" (\v c -> c { Hspec.configDryRun = v })+ >>= findKeyAndApplyConfig config k "fast-fail" (\v c -> c { Hspec.configFastFail = v })+ >>= findKeyAndApplyConfig config k "rerun" (\v c -> c { Hspec.configRerun = v })+ >>= findKeyAndApplyConfig config k "quickCheck-max-success" (\v c -> c { Hspec.configQuickCheckMaxSuccess = v })+ >>= findKeyAndApplyConfig config k "quickCheck-max-discard-ratio" (\v c -> c { Hspec.configQuickCheckMaxDiscardRatio = v })+ >>= findKeyAndApplyConfig config k "quickCheck-max-size" (\v c -> c { Hspec.configQuickCheckMaxSize = v })+ >>= findKeyAndApplyConfig config k "quickCheck-seed" (\v c -> c { Hspec.configQuickCheckSeed = v })+ >>= findKeyAndApplyConfig config k "smallCheck-depth" (\v c -> c { Hspec.configSmallCheckDepth = v })+ >>= findKeyAndApplyConfig config k "color-mode" (\v c -> c { Hspec.configColorMode = v })+ >>= findKeyAndApplyConfig config k "html-output" (\v c -> c { Hspec.configHtmlOutput = v })+ >>= findKeyAndApplyConfig config k "formatter" (\v c -> c { Hspec.configFormatter = v })+#if MIN_VERSION_hspec_core(2,1,1)+ -- We ignore configuration of type function that don't have defaults provided by the lib+ -- >>= findKeyAndApplyConfig config k "skip-predicate" (\v c -> c { Hspec.configSkipPredicate = v })+#endif+#if MIN_VERSION_hspec_core(2,1,9)+ >>= findKeyAndApplyConfig config k "concurrent-jobs" (\v c -> c { Hspec.configConcurrentJobs = v })+#endif+#if MIN_VERSION_hspec_core(2,4,0)+ >>= findKeyAndApplyConfig config k "ignore-config-file" (\v c -> c { Hspec.configIgnoreConfigFile = v })+ >>= findKeyAndApplyConfig config k "print-cpu-time" (\v c -> c { Hspec.configPrintCpuTime = v })+ >>= findKeyAndApplyConfig config k "diff" (\v c -> c { Hspec.configDiff = v })+#endif+#if MIN_VERSION_hspec_core(2,4,2)+ >>= findKeyAndApplyConfig config k "failure-report" (\v c -> c { Hspec.configFailureReport = v })+#endif+#if MIN_VERSION_hspec_core(2,7,0)+ >>= findKeyAndApplyConfig config k "focused-only" (\v c -> c { Hspec.configFocusedOnly = v })+ >>= findKeyAndApplyConfig config k "fail-on-focused" (\v c -> c { Hspec.configFailOnFocused = v })+#endif+
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}