goraku 0.1.0 → 0.1.1

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: 059bc4afbf8b0b56f3bbe73a8402dd7ccbb6f1ff
4
- data.tar.gz: 9f8eec45a4021580c9f7c8d28f1b8ddd7077ec08
3
+ metadata.gz: f51da0d9c0b9b2e71d38a563cfe7e25ea217df52
4
+ data.tar.gz: 1148efc3cc87bf5c6834b47ead32e917d3d652e4
5
5
  SHA512:
6
- metadata.gz: 851b17fada04241c28e6aac1e40c35cad7192e72707a8265d1df848dce96d9c00292bf36e89c68660060c247518eec3c10c3f95cc55a79f2a0ebc43f251f9e37
7
- data.tar.gz: 83225d597024613f935dcb2e1a6aa91be71c5b92c3f1e2c72882f3033664facb936dfed3877ac9fd11e6e23dd7abec137354a94f5f2ecd1504c41bf815b81b82
6
+ metadata.gz: ca7426cf3d709caea7df7d090a8d1c5234eaa808692551383668e4b38335427a51cedf6793574cf5b5b9d72b0b6461ac002bc1cff71589711cc56f022d729ac9
7
+ data.tar.gz: 06706b363dfbebef85c54b0bce63080430c7a20a693a4e6880a58bcb2fb1ebd12104849c297b3160f8fb64aec2a565bb577a0d21f47c76fc2ce4b5170653bfc0
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 0.1.1
2
+
3
+ Add option :raises_error
4
+
5
+ # 0.1.0
6
+
7
+ First release
data/lib/goraku/client.rb CHANGED
@@ -67,7 +67,38 @@ module Goraku
67
67
  end
68
68
 
69
69
  def request(method, path, data, options = {})
70
- agent.call(method, URI::Parser.new.escape("/api#{path.to_s}"), data, options).data
70
+ res = agent.call(method, URI::Parser.new.escape("/api#{path.to_s}"), data, options)
71
+ raise_error(res.status) if @raise_error
72
+ res.data
73
+ end
74
+
75
+ def raise_error(code)
76
+ case code
77
+ when 400
78
+ raise Status400.new
79
+ when 401
80
+ raise Status401.new
81
+ when 402
82
+ raise Status402.new
83
+ when 403
84
+ raise Status403.new
85
+ when 404
86
+ raise Status404.new
87
+ when 405
88
+ raise Status405.new
89
+ when 409
90
+ raise Status409.new
91
+ when 410
92
+ raise Status410.new
93
+ when 415
94
+ raise Status415.new
95
+ when 500
96
+ raise Status500.new
97
+ when 501
98
+ raise Status501.new
99
+ when 503
100
+ raise Status503.new
101
+ end
71
102
  end
72
103
 
73
104
  def sawyer_options
@@ -3,6 +3,7 @@ module Goraku
3
3
 
4
4
  attr_reader :api_endpoint, :login, :password
5
5
  attr_reader :connection_options, :middleware, :proxy
6
+ attr_reader :raise_error
6
7
  class << self
7
8
  def keys
8
9
  @keys || [
@@ -11,7 +12,8 @@ module Goraku
11
12
  :password,
12
13
  :connection_options,
13
14
  :middleware,
14
- :proxy
15
+ :proxy,
16
+ :raise_error
15
17
  ]
16
18
  end
17
19
  end
@@ -0,0 +1,15 @@
1
+ module Goraku
2
+ class StatusError < StandardError; end
3
+ class Status400 < StatusError; end
4
+ class Status401 < StatusError; end
5
+ class Status402 < StatusError; end
6
+ class Status403 < StatusError; end
7
+ class Status404 < StatusError; end
8
+ class Status405 < StatusError; end
9
+ class Status409 < StatusError; end
10
+ class Status410 < StatusError; end
11
+ class Status415 < StatusError; end
12
+ class Status500 < StatusError; end
13
+ class Status501 < StatusError; end
14
+ class Status503 < StatusError; end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Goraku
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/goraku.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "goraku/version"
2
2
  require "goraku/client"
3
+ require "goraku/status_error"
3
4
 
4
5
  module Goraku
5
6
  # Your code goes here...
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goraku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kinoshita.Yasuhiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sawyer
@@ -104,6 +104,7 @@ files:
104
104
  - ".gitignore"
105
105
  - ".rspec"
106
106
  - ".travis.yml"
107
+ - CHANGELOG.md
107
108
  - CODE_OF_CONDUCT.md
108
109
  - Gemfile
109
110
  - LICENSE.md
@@ -121,6 +122,7 @@ files:
121
122
  - lib/goraku/client/schedule.rb
122
123
  - lib/goraku/client/scheduler.rb
123
124
  - lib/goraku/configurable.rb
125
+ - lib/goraku/status_error.rb
124
126
  - lib/goraku/version.rb
125
127
  homepage: https://github.com/YasuhiroKinoshita/goraku
126
128
  licenses: