doyoubuzz-showcase 0.0.1 → 0.0.2

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: d14295790c6ff76c60fe43b6e484f91b8adfb8fd
4
- data.tar.gz: 8845df115a005dccccea9c8d248194b33acbe7ee
3
+ metadata.gz: 2ca622ca780c6a6ae46844f5dc79b9829853d762
4
+ data.tar.gz: ed83ff11c9e0a86112031b411d917e5332465287
5
5
  SHA512:
6
- metadata.gz: b38d9b40e0769446971a27324a61005f6e167174f6e50ed7873f68714a558a71f50cfac4b48027d0d5ee0dce7b00a89dba55486c55586fbcabd128592cf4a2ec
7
- data.tar.gz: 48cc99484f86a48626a3938ec2f7464e7ac6d4d874c3f209e512cede7c8ace8170a2b2f1e32f9a0e86b749ac4061aa828cbe4abd16cc30ed5296daf38239d911
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', :git => 'git://github.com/MrRuru/doyoubuzz-showcase.git'
16
+ gem 'doyoubuzz-showcase'
17
17
 
18
18
  And then execute:
19
19
 
@@ -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, :query => process_params(params))
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 process_params(params)
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
@@ -1,3 +1,3 @@
1
1
  module Doyoubuzz
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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.1
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-06 00:00:00.000000000 Z
11
+ date: 2013-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler