packages feed

bird 0.0.16 → 0.0.17

raw patch · 3 files changed

+32/−15 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

bin/bird.hs view
@@ -3,6 +3,8 @@ import System.Process import System.Environment (getArgs) import List+import Data.List+import Data.List.Utils (join)  main = do   args <- getArgs@@ -15,11 +17,12 @@     ["nest"] -> do       appModuleNamePath <- getCurrentDirectory       appModuleName <- return $ head . reverse $ split '/' appModuleNamePath-      partialRouteFile <- readFile $ appModuleName ++ ".bird.hs"-      writeFile (appModuleName ++ ".hs") ((appModulePrelude appModuleName)++ "\n" ++ partialRouteFile ++ "\n" ++ appModuleEpilogue)+      app <- readFile $ appModuleName ++ ".bird.hs"+      let reformattedApp = reformatApp (lines app)+      writeFile (appModuleName ++ ".hs") ((appModulePrelude appModuleName)++ "\n" ++ reformattedApp ++ "\n")       system "ghc --make -O2 Main.hs"       files <- getDirectoryContents appModuleNamePath-      system $ "rm *.o *.hi " ++ appModuleName ++ ".hs"+      system "rm *.o *.hi "       renameFile "Main" (appModuleName ++ "App")       return ()     ["fly"] -> do@@ -33,6 +36,14 @@       printHelp     [] -> printHelp +reformatApp app = join "\n" $ strippedApp ++ getFunction ++ postFunction ++ putFunction ++ deleteFunction+  where+    getFunction = extractFunction "get" app+    postFunction = extractFunction "post" app+    putFunction = extractFunction "put" app+    deleteFunction = extractFunction "delete" app+    strippedApp = app \\ (concat [getFunction, postFunction, putFunction, deleteFunction])+ printHelp = do   putStrLn $ "Usage: bird action [options]\n\n" ++              "  Actions:\n" ++@@ -46,12 +57,6 @@   "import Bird\n" ++   "import Prelude hiding( log )\n\n" -appModuleEpilogue =-  "get _ = status 404\n" ++-  "post _ = status 404\n" ++-  "put _ = status 404\n" ++-  "delete _ = status 404\n"- createBirdApp a = do   createDirectory a   createDirectory (a ++ "/" ++ a ++ "/")@@ -101,6 +106,19 @@   "main = do\n" ++   "  putStrLn \"A bird was just spotted in flight at http://localhost:3000\"\n" ++   "  run app\n"++extractFunction :: String -> [String] -> [String]+extractFunction f program = (concat (findAll f program)) ++ [(f ++ " _ = status 404")]++findAll _ [] = []+findAll function program =  +  case (dropWhile (not . ((function ++ " ") `isPrefixOf`)) program) of +    [] -> []+    (l:ls) -> +      f : findAll function remainingProgram+        where+          (functionBody, remainingProgram) = break (not . (" " `isPrefixOf`)) ls+          f = [l] ++ functionBody  split :: Char -> String -> [String] split d s
bird.cabal view
@@ -1,5 +1,5 @@ Name:                 bird-Version:              0.0.16+Version:              0.0.17 Build-type:           Simple Synopsis:             A simple, sinatra-inspired web framework. Description:          Bird is a hack-compatible framework for simple websites.
readme.markdown view
@@ -17,6 +17,7 @@ ## Create an app      λ bird hatch StarWars+      A fresh bird app has been created in StarWars.  ## Compile your app @@ -31,15 +32,13 @@ ## Start your app (runs on port 3000)      λ bird fly+      A bird was just spotted in flight at http://localhost:3000  ## Try it out      λ curl http://localhost:3000       Hello, Bird! -    λ curl http://localhost:3000?name=Luke-      Hello, Luke- ## Improvise!      -- StarWars.bird.hs@@ -57,7 +56,7 @@       log "I'm about to greet a Jedi. Teehee!"       body $ "Greetings, " ++ (maybe "Jedi!" id name) -now recompile your app and start it flying:+Now recompile your app and start it flying:      λ bird nest     λ bird fly &@@ -87,7 +86,7 @@  You have four functions to implement: get, post, put, and delete. They each accept a Bird Request. -Inside the function body, you can use the following methods (don't worry, this list will grow):+Inside the function body, you can use the following methods (don't worry, this is a growing list):      param :: String -> Maybe String     -- ex: for the request GET /droids?name=c3po,