namira 0.1.3 → 0.1.4

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: c9d1a802826c3bd3ec790f47cabae4fdf8c99de7
4
- data.tar.gz: ee75280c787449661c62c29d8dd198bb2000e292
3
+ metadata.gz: 9847678dcc4df200c97bad41e62b525401335eb3
4
+ data.tar.gz: 72c72e7726a2972dc1fbd561bb178810ea348e71
5
5
  SHA512:
6
- metadata.gz: 6ee876b831b2783a578b69cecd91430eed3fd1076cbbbf976850943d0dd1c521f13493b8c773aa5bd69411ef2426ba012263c4118119afd3fea0cdb00022df92
7
- data.tar.gz: af35305fe49becfecc3ec32f3e1bd8bc0d143b0879c04a3869ad1c8b3cf248cecea9ec0887eccd4a1aa4f41f5dc6b5b4e54a2251bfaaf3edbf2239074aea5c96
6
+ metadata.gz: e0fb5f3ae1b7425b845a9c0ac63ed9aca8014a16b211b0b56d4beae656ba5725e44eb0cff634e28d1bc116d291da3cdedb9f233261d6a9a42f242f2298f47988
7
+ data.tar.gz: ee3a92d409a1d39b2e102c6243c02defbef48c38e6c30becf241dc7020d4ebc3379ba29e6e4432c095307e5e01a6211ed7e9e0d522665c9f1a5ab5db54918650
data/.gitignore CHANGED
@@ -8,4 +8,3 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  *.gem
11
- .box-location
data/README.md CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Sending a basic `GET` request
21
+ ### GET
22
22
 
23
23
  ```ruby
24
24
  # Create a request
@@ -31,6 +31,23 @@ response = request.response
31
31
  response.from_json
32
32
  ```
33
33
 
34
+ ### POST
35
+
36
+ ```ruby
37
+ # Create a request
38
+ request = Namira::Request.new(
39
+ uri: 'https://httpbin.org/headers',
40
+ http_method: :post,
41
+ request_body: JSON.dump({})
42
+ )
43
+
44
+ # Send the request
45
+ response = request.response
46
+
47
+ # Parse a JSON response
48
+ response.from_json
49
+ ```
50
+
34
51
  #### Configuration
35
52
 
36
53
  There are a few settings you can pass.
@@ -47,7 +47,7 @@ module Namira
47
47
  raise Errors::RedirectError, 'Request redirected but no location was supplied' if location.nil?
48
48
  send_request(location, method, headers, max_redirect, timeout, body, auth)
49
49
  else
50
- raise Errors::HTTPError.new("http_error/#{response.status}", response.status)
50
+ raise Errors::HTTPError.new("http_error/#{response.status}", response.status, Namira::Response.new(response))
51
51
  end
52
52
 
53
53
  rescue HTTP::TimeoutError => e
@@ -1,10 +1,11 @@
1
1
  module Namira
2
2
  module Errors
3
3
  class HTTPError < Base
4
- attr_reader :status
4
+ attr_reader :status, :response
5
5
 
6
- def initialize(msg, status)
6
+ def initialize(msg, status, response)
7
7
  @status = status
8
+ @response = response
8
9
  super(msg)
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module Namira
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skylar Schipper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2017-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.5.1
145
+ rubygems_version: 2.5.2
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: A simple wrapper around HTTP