packages feed

servant-ruby 0.1.0.1 → 0.1.1.0

raw patch · 2 files changed

+10/−55 lines, 2 files

Files

servant-ruby.cabal view
@@ -1,5 +1,5 @@ name:                servant-ruby-version:             0.1.0.1+version:             0.1.1.0 synopsis:            Generate a Ruby client from a Servant API with Net::HTTP. description:         Generate a Ruby client from a Servant API with Net::HTTP. homepage:            https://github.com/joneshf/servant-ruby#readme
src/Servant/Ruby.hs view
@@ -95,20 +95,11 @@   end <BLANKLINE>   def get()-    uri = URI("#{origin}")+    uri = URI("#{@origin}") <BLANKLINE>     req = Net::HTTP::Get.new(uri)-    req["Accept"] = "application/json" <BLANKLINE>-    request(req)-  end-<BLANKLINE>-  private-<BLANKLINE>-  def request(req, body = nil)-    res = http.request(req, body)-    res.body = JSON.parse(res.body, symbolize_names: true)-    res+    @http.request(req)   end end @@ -128,20 +119,11 @@       end <BLANKLINE>       def get()-        uri = URI("#{origin}")+        uri = URI("#{@origin}") <BLANKLINE>         req = Net::HTTP::Get.new(uri)-        req["Accept"] = "application/json" <BLANKLINE>-        request(req)-      end-<BLANKLINE>-      private-<BLANKLINE>-      def request(req, body = nil)-        res = http.request(req, body)-        res.body = JSON.parse(res.body, symbolize_names: true)-        res+        @http.request(req)       end     end   end@@ -164,22 +146,13 @@   end <BLANKLINE>   def post_foo_by_foo_id(foo_id, bar, body:, max_forwards:)-    uri = URI("#{origin}/foo/#{fooId}?bar=#{bar}")+    uri = URI("#{@origin}/foo/#{fooId}?bar=#{bar}") <BLANKLINE>     req = Net::HTTP::Post.new(uri)-    req["Accept"] = "application/json"     req["Content-Type"] = "application/json"     req["Max-Forwards"] = max_forwards <BLANKLINE>-    request(req, body)-  end-<BLANKLINE>-  private-<BLANKLINE>-  def request(req, body = nil)-    res = http.request(req, body)-    res.body = JSON.parse(res.body, symbolize_names: true)-    res+    @http.request(req, body)   end end -}@@ -198,7 +171,6 @@   body =     initialize indent     ++ foldMap (public indent) api-    ++ private indent   api =     listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) p   prologue =@@ -230,19 +202,6 @@     , Just "end"     ] -private :: Int -> [Text]-private indent =-  properIndent indent-    [ Nothing-    , Just "private"-    , Nothing-    , Just "def request(req, body = nil)"-    , Just "  res = http.request(req, body)"-    , Just "  res.body = JSON.parse(res.body, symbolize_names: true)"-    , Just "  res"-    , Just "end"-    ]- public :: Int -> Req NoContent -> [Text] public indent req =   properIndent indent $@@ -255,7 +214,7 @@     ++ requestHeaders     ++     [ Nothing-    , Just $ "  request" <> request+    , Just $ "  @http.request" <> request     , Just "end"     ]   where@@ -293,9 +252,6 @@       Just _  -> "(req, body)"       Nothing -> "(req)" -  accept :: [Maybe Text]-  accept = [Just "  req[\"Accept\"] = \"application/json\""]-   contentType :: [Maybe Text]   contentType =     case req ^. reqBody of@@ -307,8 +263,7 @@    requestHeaders :: [Maybe Text]   requestHeaders =-    accept-    ++ contentType+    contentType     ++ (requestHeader <$> rawHeaders)    headerArgs :: [Text]@@ -324,7 +279,7 @@       Left _  -> "Get"    url :: Text-  url = "\"#{origin}" <> urlArgs <> queryArgs <> "\""+  url = "\"#{@origin}" <> urlArgs <> queryArgs <> "\""    urlArgs :: Text   urlArgs = req ^.. reqUrl.path.traverse & rbSegments