quinoa 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/changelog +2 -2
- data/lib/quinoa/service.rb +8 -3
- data/lib/quinoa/version.rb +1 -1
- data/spec/service_object_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9e2963793d9613b5cd69cbbcccc993a788b291
|
4
|
+
data.tar.gz: f5f189e9874bb3d49355467f39a2f1b0fa55e504
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c702d708f6ca12a1627c2067e46ddf5b2b9f9e69238e5721a51a800ee40ad67b10f3399e71cd3b4cbb8ab4dafa99d784c1334716d8186616fcb231f20d4fd8b
|
7
|
+
data.tar.gz: 30a42aeb7558abe4bd63a96f2867d352f0c9556c7c203ef4a8f4482ec2ba55385a3a70b27eeaad7b7ac7393092c3a6c738583c5f13c965f1cd4aeebca7b0c112
|
data/changelog
CHANGED
data/lib/quinoa/service.rb
CHANGED
@@ -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
|
data/lib/quinoa/version.rb
CHANGED
data/spec/service_object_spec.rb
CHANGED
@@ -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.
|
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:
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|