traitify 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98fa2d1da00742bcf318b72f1fe24ddd830f7087
4
- data.tar.gz: dad40fe6a7104de1a71a9a0c9986dd64c6b61d27
3
+ metadata.gz: 261a556aad6aecf312c66a850910b0657aeb6c6b
4
+ data.tar.gz: a8fa60ebf999db0fa01260751602b2eca4620fc2
5
5
  SHA512:
6
- metadata.gz: 15a2f74599b77ad331d2c632cf6439d52b2a40fd3894e2b7f34d6db7fdc72799e7243d6950c47d3cecd3aecfcdf6b69035b2911a863c9b024ed33805ffad2928
7
- data.tar.gz: 61dd86b2fd9e77cb002208c5ceaad4b7e3f11dd4efd5ca2ee059334b64e714849da6e3b4f436e05ff85ec22303ba4d954320613b8cc1c2af4688748ab35a085d
6
+ metadata.gz: 445f43a6bb9f9f19276798fe23094bb63d3617c441961b96e82784ee31dd903de84b65c7b29445b4d5561f4d31d4aa53bb43f9a700aa77c5a37e4185518d160b
7
+ data.tar.gz: bba888360a4fd1f8973323a6bdbfd3ce606fe105887426a1b852b3f9fc3c0defeef1bb785e1c3d5daad4497b1e2ab486ae4bb056f884e3eb7dcd8447c5ea4351
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- traitify (1.3.0)
4
+ traitify (1.4.0)
5
5
  faraday (~> 0.9.0)
6
6
  faraday_middleware (~> 0.9.0)
7
7
  hashie
@@ -35,7 +35,7 @@ module Traitify
35
35
 
36
36
  def call(env)
37
37
  @app.call(env).on_complete do |e|
38
- if error = Traitify::Error.from(e.status)
38
+ if error = Traitify::Error.from(e)
39
39
  raise error
40
40
  end
41
41
  end
@@ -2,8 +2,8 @@ module Traitify
2
2
  class Error < StandardError
3
3
  attr_accessor :response
4
4
 
5
- def self.from(status)
6
- if klass = case status
5
+ def self.from(response)
6
+ if klass = case response.status
7
7
  when 400 then Traitify::BadRequest
8
8
  when 401 then Traitify::Unauthorized
9
9
  when 404 then Traitify::NotFound
@@ -24,10 +24,10 @@ module Traitify
24
24
 
25
25
  private
26
26
  def error_message
27
- message = "#{response.env[:method].upcase} | "
28
- message << "#{response.env[:url].to_s} | "
27
+ message = "#{response.method.upcase} | "
28
+ message << "#{response.url.to_s} | "
29
29
  message << "#{response.status} | "
30
- message << "#{response.body}"
30
+ message << "#{response.body.first["message"]}"
31
31
  message
32
32
  end
33
33
  end
@@ -9,10 +9,15 @@ module Traitify
9
9
  end
10
10
 
11
11
  def request(method, path, options = {})
12
- conn(url: api_host).send(method) do |request|
13
- request.url [api_version, path].join
14
- request.body = options.to_json if options
15
- end.body
12
+ begin
13
+ conn(url: api_host).send(method) do |request|
14
+ request.url [api_version, path].join
15
+ request.body = options.to_json if options
16
+ end.body
17
+ rescue => e
18
+ puts e.message
19
+ { error: e.message }
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -1,3 +1,3 @@
1
1
  module Traitify
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traitify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Prats
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2014-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie