quinoa 0.0.6 → 0.0.7

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: 09a422a353b5c8594abff8e280cb247b2784b992
4
- data.tar.gz: a373bf8ea1021939e4f20c208d7832a4f6d494f8
3
+ metadata.gz: 6e9e2963793d9613b5cd69cbbcccc993a788b291
4
+ data.tar.gz: f5f189e9874bb3d49355467f39a2f1b0fa55e504
5
5
  SHA512:
6
- metadata.gz: f9e0a10fc74665aa9f428e8291c52d2113320d7e900756763fffddff1aad475a1ced2cfd170432f42206c87f73cbff0093c0cdd95e99cc476092a944a77963d4
7
- data.tar.gz: f6708b08501f673acd3ff244dbfe460aa64ab3b13b6c251f4347904c37241e65a324e529cbab0a4c5125633c17ede23d8c7ef7c0bb57278e0b6253cdc85e9bd2
6
+ metadata.gz: 7c702d708f6ca12a1627c2067e46ddf5b2b9f9e69238e5721a51a800ee40ad67b10f3399e71cd3b4cbb8ab4dafa99d784c1334716d8186616fcb231f20d4fd8b
7
+ data.tar.gz: 30a42aeb7558abe4bd63a96f2867d352f0c9556c7c203ef4a8f4482ec2ba55385a3a70b27eeaad7b7ac7393092c3a6c738583c5f13c965f1cd4aeebca7b0c112
data/changelog CHANGED
@@ -1,5 +1,5 @@
1
- 0.0.7:
2
- -
1
+ 0.0.7: Adding support to custom headers
2
+ - Now you can send custom headers in the requests
3
3
 
4
4
  0.0.6: Adding overite url
5
5
  - Now you can pass a url to a post or get and overite it.
@@ -3,20 +3,21 @@ require "rest-client"
3
3
  module Quinoa
4
4
  class Service
5
5
 
6
- attr_accessor :url, :content_type, :accept, :body, :response, :path, :authorization
6
+ attr_accessor :url, :content_type, :accept, :body, :response, :path, :authorization, :custom_headers
7
7
 
8
8
  def initialize url
9
9
  self.path = ""
10
10
  self.authorization = ""
11
+ self.custom_headers = {}
11
12
  self.url = url
12
13
  end
13
14
 
14
15
  def post! url=nil
15
16
  begin
16
17
  if url == nil
17
- self.response = RestClient.post self.url + self.path, self.body, :accept => self.accept, :content_type => self.content_type, :authorization => self.authorization
18
+ self.response = RestClient.post self.url + self.path, self.body, {:accept => self.accept, :content_type => self.content_type, :authorization => self.authorization}.merge!(self.custom_headers)
18
19
  else
19
- self.response = RestClient.post url, self.body, :accept => self.accept, :content_type => self.content_type, :authorization => self.authorization
20
+ self.response = RestClient.post url, self.body, {:accept => self.accept, :content_type => self.content_type, :authorization => self.authorization}.merge!(self.custom_headers)
20
21
  end
21
22
  rescue => e
22
23
  self.response = e.response
@@ -55,5 +56,9 @@ module Quinoa
55
56
  self.response.headers[:location]
56
57
  end
57
58
 
59
+ def add_custom_header custom_header_name, custom_header_value
60
+ self.custom_headers.merge! custom_header_name.to_sym => custom_header_value.to_s
61
+ end
62
+
58
63
  end
59
64
  end
@@ -1,3 +1,3 @@
1
1
  module Quinoa
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -40,6 +40,22 @@ describe Quinoa do
40
40
  expect(@service.body).to eq "text"
41
41
  end
42
42
 
43
+ it "Should be able to add a single custom header" do
44
+ expect(@service.custom_headers).to eq Hash[]
45
+
46
+ @service.add_custom_header :"my-company-custom-header", "text"
47
+ expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text"]
48
+ end
49
+
50
+ it "Should be able to add many custom headers" do
51
+ expect(@service.custom_headers).to eq Hash[]
52
+
53
+ @service.add_custom_header "my-company-custom-header", "text"
54
+ @service.add_custom_header "headerx", "bar"
55
+ @service.add_custom_header :"my-foo-custom-header", "foo"
56
+ expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :headerx => "bar", :"my-foo-custom-header" => "foo"]
57
+ end
58
+
43
59
  end
44
60
 
45
61
  describe "overwiting the entire url to post and get" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quinoa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Ribeiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-07 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov