heroku-persistent (empty) → 0.1.0
raw patch · 5 files changed
+94/−0 lines, 5 filesdep +basedep +bytestringdep +herokusetup-changed
Dependencies added: base, bytestring, heroku, heroku-persistent, hspec, persistent-postgresql, text
Files
- LICENSE +19/−0
- Setup.hs +2/−0
- heroku-persistent.cabal +42/−0
- src/Web/Heroku/Persist/Postgresql.hs +30/−0
- test/Spec.hs +1/−0
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2014 thoughtbot <hello@thoughtbot.com>++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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ heroku-persistent.cabal view
@@ -0,0 +1,42 @@+name: heroku-persistent+version: 0.1.0+author: Pat Brisbin <pbrisbin@gmail.com>+maintainer: Pat Brisbin <pbrisbin@gmail.com>+license: MIT+license-File: LICENSE+synopsis: Parse DATABASE_URL into configuration types for Persistent+description:+ A thin wrapper over the heroku package. Converts the parameters parsed from+ DATABASE_URL to the concrete configuration types required by persistent.+ .+ Currently, only persistent-postgresql's PostgresConf is provided.+ .++cabal-Version: >= 1.10+build-Type: Simple++library+ default-language: Haskell2010+ hs-source-dirs: src+ ghc-options: -Wall+ exposed-modules: Web.Heroku.Persist.Postgresql+ build-depends: base >= 4 && < 5+ , bytestring+ , heroku >= 0.1.2 && < 0.2+ , persistent-postgresql >= 1.0.0+ , text >= 0.11 && < 2.0++test-suite spec+ type: exitcode-stdio-1.0+ default-language: Haskell2010+ hs-source-dirs: test+ ghc-options: -Wall+ main-is: Spec.hs+ build-depends: base >= 4.7.0.0+ , hspec+ , heroku-persistent+ , persistent-postgresql++source-repository head+ type: git+ location: https://github.com/thoughtbot/heroku-persistent
+ src/Web/Heroku/Persist/Postgresql.hs view
@@ -0,0 +1,30 @@+{-# LANGUAGE OverloadedStrings #-}+module Web.Heroku.Persist.Postgresql+ ( postgresConf+ ) where++import Control.Applicative ((<$>))+import Data.ByteString (ByteString)+import Data.Text (Text)+import Data.Text.Encoding (encodeUtf8)+import Data.Monoid ((<>))+import Database.Persist.Postgresql (PostgresConf(..))+import Web.Heroku (dbConnParams)++import qualified Data.Text as T++-- | Build a @'PostgresConf'@ by parsing @DATABASE_URL@+postgresConf :: Int -> IO PostgresConf+postgresConf size = do+ connStr <- formatParams <$> dbConnParams++ return PostgresConf+ { pgConnStr = connStr+ , pgPoolSize = size+ }++formatParams :: [(Text, Text)] -> ByteString+formatParams = encodeUtf8 . T.unwords . map toKeyValue++toKeyValue :: (Text, Text) -> Text+toKeyValue (k, v) = k <> "=" <> v
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}