doyoubuzz-showcase 0.0.1 → 0.0.2
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/README.md +1 -1
- data/lib/doyoubuzz/showcase.rb +16 -3
- data/lib/doyoubuzz/showcase/version.rb +1 -1
- data/spec/showcase_spec.rb +7 -1
- 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: 2ca622ca780c6a6ae46844f5dc79b9829853d762
|
4
|
+
data.tar.gz: ed83ff11c9e0a86112031b411d917e5332465287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 690bc10606bfcca681a22504807f92c49f5a42b19a8ec9cf6baa66c06b11db0106d379e70802939d3d07eba8f7396d277c2caf52f2a8f724d6279e9b074daae0
|
7
|
+
data.tar.gz: 7df9e9526cc9b5cabb51b50bf031ee8696fecf095e854de3ff233ff288ad9cfb48e685a643d04465c5ef5ef2753db122611a92a0d153146bd99bacfa4cc57cd5
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ The `doyoubuzz-showcase` gem is a thin ruby wrapper for the DoYouBuzz Showcase A
|
|
13
13
|
|
14
14
|
Add this line to your application's Gemfile:
|
15
15
|
|
16
|
-
gem 'doyoubuzz-showcase'
|
16
|
+
gem 'doyoubuzz-showcase'
|
17
17
|
|
18
18
|
And then execute:
|
19
19
|
|
data/lib/doyoubuzz/showcase.rb
CHANGED
@@ -26,7 +26,7 @@ module Doyoubuzz
|
|
26
26
|
|
27
27
|
# The actual api call
|
28
28
|
def call_api(verb, method, params)
|
29
|
-
res = self.class.send(verb, method,
|
29
|
+
res = self.class.send(verb, method, build_request_parameters(params, verb))
|
30
30
|
return process_response(res)
|
31
31
|
end
|
32
32
|
|
@@ -45,10 +45,23 @@ module Doyoubuzz
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
# Build the request parameters
|
49
|
+
def build_request_parameters(params, verb)
|
50
|
+
additional_parameters = {:apikey => @api_key, :timestamp => Time.now.to_i}
|
51
|
+
|
52
|
+
# GET, DELETE requests : the parameters are in the request query
|
53
|
+
if [:get, :delete].include? verb
|
54
|
+
return {:query => sign_params(params.merge additional_parameters)}
|
55
|
+
|
56
|
+
# Otherwise, they are in the body
|
57
|
+
else
|
58
|
+
return {:body => params, :query => sign_params(additional_parameters)}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
48
62
|
|
49
63
|
# The arguments processing and signing
|
50
|
-
def
|
51
|
-
params.merge!({:apikey => @api_key, :timestamp => Time.now.to_i})
|
64
|
+
def sign_params(params)
|
52
65
|
params[:hash] = compute_signature(params)
|
53
66
|
params
|
54
67
|
end
|
data/spec/showcase_spec.rb
CHANGED
@@ -17,7 +17,6 @@ describe Doyoubuzz::Showcase do
|
|
17
17
|
|
18
18
|
describe '#call' do
|
19
19
|
let(:showcase){ Doyoubuzz::Showcase.new(api_key, api_secret) }
|
20
|
-
let(:method){ '/a_method' }
|
21
20
|
let(:arguments){ {:foo => 'bar', :zab => 'baz'} }
|
22
21
|
let(:timestamp){ 1370534334 }
|
23
22
|
|
@@ -38,6 +37,13 @@ describe Doyoubuzz::Showcase do
|
|
38
37
|
showcase.get('/path', arguments)
|
39
38
|
end
|
40
39
|
|
40
|
+
it "should put the parameters in the body for PUT requests" do
|
41
|
+
showcase.stub!(:process_response) # We only want to check the sent parameters here
|
42
|
+
showcase.class.should_receive(:put).with("/path", {:query => {:apikey => "an_api_key", :timestamp => timestamp, :hash => "11a68a1bb9e23c681438efb714c9ad4d"}, :body => {:foo => "bar", :zab => "baz"}})
|
43
|
+
|
44
|
+
showcase.put('/path', arguments)
|
45
|
+
end
|
46
|
+
|
41
47
|
it "should handle HTTP verbs" do
|
42
48
|
expect(showcase).to respond_to :get
|
43
49
|
expect(showcase).to respond_to :post
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doyoubuzz-showcase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David RUYER
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|