panda 0.4.3 → 0.4.4

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/panda/panda.rb +12 -8
  3. data/panda.gemspec +3 -3
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.4
data/lib/panda/panda.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'restclient'
2
2
 
3
3
  class Panda
4
+ attr_reader :api_host, :api_port, :access_key, :secret_key, :api_version
5
+
4
6
  def initialize(auth_params={})
5
7
  params = {:api_host => 'api.pandastream.com', :api_port => 80 }.merge(auth_params)
6
8
 
@@ -15,26 +17,26 @@ class Panda
15
17
  end
16
18
 
17
19
  def get(request_uri, params={})
18
- rescue_resclient_error do
20
+ rescue_restclient_exception do
19
21
  query = signed_query("GET", request_uri, params)
20
22
  body_of @connection[request_uri + '?' + query].get
21
23
  end
22
24
  end
23
25
 
24
26
  def post(request_uri, params)
25
- rescue_resclient_error do
27
+ rescue_restclient_exception do
26
28
  body_of @connection[request_uri].post(signed_params("POST", request_uri, params))
27
29
  end
28
30
  end
29
31
 
30
32
  def put(request_uri, params)
31
- rescue_resclient_error do
33
+ rescue_restclient_exception do
32
34
  body_of @connection[request_uri].put(signed_params("PUT", request_uri, params))
33
35
  end
34
36
  end
35
37
 
36
38
  def delete(request_uri, params={})
37
- rescue_resclient_error do
39
+ rescue_restclient_exception do
38
40
  query = signed_query("DELETE", request_uri, params)
39
41
  body_of @connection[request_uri + '?' + query].delete
40
42
  end
@@ -55,10 +57,12 @@ class Panda
55
57
 
56
58
  def signed_params(verb, request_uri, params = {}, timestamp_str = nil)
57
59
  auth_params = params
58
- auth_params['cloud_id'] = @cloud_id
60
+ auth_params['cloud_id'] = @cloud_id
59
61
  auth_params['access_key'] = @access_key
60
- auth_params['timestamp'] = timestamp_str || Time.now.iso8601(6)
61
- auth_params['signature'] = ApiAuthentication.generate_signature(verb, request_uri, @api_host, @secret_key, params.merge(auth_params))
62
+ auth_params['timestamp'] = timestamp_str || Time.now.iso8601(6)
63
+
64
+ params_to_sign = auth_params.reject{|k,v| ['file'].include?(k)}
65
+ auth_params['signature'] = ApiAuthentication.generate_signature(verb, request_uri, @api_host, @secret_key, params_to_sign)
62
66
  auth_params
63
67
  end
64
68
 
@@ -73,7 +77,7 @@ class Panda
73
77
 
74
78
  private
75
79
 
76
- def rescue_resclient_error(&block)
80
+ def rescue_restclient_exception(&block)
77
81
  begin
78
82
  yield
79
83
  rescue RestClient::Exception => e
data/panda.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{panda}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
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-03-04}
12
+ s.date = %q{2010-03-08}
13
13
  s.description = %q{Panda Client}
14
14
  s.email = %q{info@pandastream.com}
15
15
  s.extra_rdoc_files = [
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.homepage = %q{http://github.com/newbamboo/panda_gem}
35
35
  s.rdoc_options = ["--charset=UTF-8"]
36
36
  s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.6}
37
+ s.rubygems_version = %q{1.3.5}
38
38
  s.summary = %q{Panda Client}
39
39
  s.test_files = [
40
40
  "spec/panda_spec.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - New Bamboo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-04 00:00:00 +00:00
12
+ date: 2010-03-08 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency