panda 0.4.0 → 0.4.1

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.
data/README.md CHANGED
@@ -85,6 +85,25 @@ Panda gem provides an interface to access the [Panda](http://pandastream.com) AP
85
85
 
86
86
  panda.delete('/videos/0ee6b656-0063-11df-a433-1231390041c1.json')
87
87
 
88
+ ## Generating signatures
89
+
90
+ All requests to your Panda cloud are signed using HMAC-SHA256, based on a timestamp and your Panda secret key. This is handled transparently. However, sometimes you will want to generate only this signature, in order to make a request by means other than this library. This is the case when using the [JavaScript panda_uploader](http://github.com/newbamboo/panda_uploader).
91
+
92
+ To do this, a method `signed_params()` is supported:
93
+
94
+ panda.signed_params('POST', '/videos.json')
95
+ # => {'access_key' => '8df50af4-074f-11df-b278-1231350015b1',
96
+ # 'cloud_id' => 'your-cloud-id',
97
+ # 'signature' => 'LejCdm0O83+jk6/Q5SfGmk14WTO1pB6Sh6Z5eA2w5C0=',
98
+ # 'timestamp' => '2010-02-26T15:01:46.221513'}
99
+
100
+ panda.signed_params('GET', '/videos.json', {'some_params' => 'some_value'})
101
+ # => {'access_key' => '8df50af4-074f-11df-b278-1231350015b1',
102
+ # 'cloud_id' => 'your-cloud-id',
103
+ # 'signature' => 'uHnGZ+kI9mT3C4vW71Iop9z2N7UKCv38v2l2dvREUIQ=',
104
+ # 'some_param' => 'some_value',
105
+ # 'timestamp' => '2010-02-26T15:04:27.039620'}
106
+
88
107
  Copyright
89
108
  ---------
90
109
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -16,20 +16,20 @@ class Panda
16
16
 
17
17
  def get(request_uri, params={})
18
18
  query = signed_query("GET", request_uri, params)
19
- @connection[request_uri + '?' + query].get
19
+ body_of @connection[request_uri + '?' + query].get
20
20
  end
21
21
 
22
22
  def post(request_uri, params)
23
- @connection[request_uri].post(signed_params("POST", request_uri, params))
23
+ body_of @connection[request_uri].post(signed_params("POST", request_uri, params))
24
24
  end
25
25
 
26
26
  def put(request_uri, params)
27
- @connection[request_uri].put(signed_params("PUT", request_uri, params))
27
+ body_of @connection[request_uri].put(signed_params("PUT", request_uri, params))
28
28
  end
29
29
 
30
30
  def delete(request_uri, params={})
31
31
  query = signed_query("DELETE", request_uri, params)
32
- @connection[request_uri + '?' + query].delete
32
+ body_of @connection[request_uri + '?' + query].delete
33
33
  end
34
34
 
35
35
  def authentication_params(verb, request_uri, params)
@@ -57,4 +57,12 @@ class Panda
57
57
  def api_url
58
58
  "http://#{@api_host}:#{@api_port}/#{@prefix}"
59
59
  end
60
+
61
+
62
+ private
63
+
64
+ # API change on rest-client 1.4
65
+ def body_of(response)
66
+ response.respond_to?(:body) ? response.body : response
67
+ end
60
68
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{panda}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["New Bamboo"]
12
- s.date = %q{2010-02-23}
12
+ s.date = %q{2010-03-04}
13
13
  s.description = %q{Panda Client}
14
14
  s.email = %q{info@pandastream.com}
15
15
  s.extra_rdoc_files = [
@@ -43,4 +43,19 @@ describe Panda do
43
43
  }
44
44
  end
45
45
 
46
+
47
+ it "should create a signed version of the parameters and difficult characters" do
48
+ signed_params = @panda.signed_params('POST',
49
+ '/videos.json',
50
+ {"tilde" => '~', "space" => ' '}
51
+ )
52
+ signed_params.should == {
53
+ 'access_key' => "my_access_key",
54
+ 'timestamp' => "2009-11-04T17:54:11+00:00",
55
+ 'cloud_id' => 'my_cloud_id',
56
+ 'signature' => 'w5P9+xPpQpRlweTh0guFYqQOmF+ZuTKXCmaKpUP3sH0=',
57
+ 'tilde' => '~',
58
+ 'space' => ' '
59
+ }
60
+ end
46
61
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - New Bamboo
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-23 00:00:00 +00:00
17
+ date: 2010-03-04 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency