panda 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,5 +6,5 @@ gem "json"
6
6
 
7
7
  gem "jeweler"
8
8
  gem "rake"
9
- gem "rspec"
10
- gem "webmock"
9
+ gem "rspec", "1.3.1"
10
+ gem "webmock", "1.6.1"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -26,11 +26,9 @@ module Panda
26
26
 
27
27
  # param keys should be strings, not symbols please. return a string joined
28
28
  # by & in canonical order.
29
- def self.canonical_querystring(params)
30
- # I hope this built-in sort sorts by byte order, that's what's required.
31
- params.keys.sort.collect {|key| [url_encode(key), url_encode(params[key])].join("=") }.join("&")
29
+ def self.canonical_querystring(h)
30
+ _recursion(h).join('&')
32
31
  end
33
-
34
32
  # Turns a hash into a query string, returns the query string.
35
33
  # url-encodes everything to Amazon's specifications.
36
34
  def self.hash_to_query(hash)
@@ -42,5 +40,26 @@ module Panda
42
40
  def self.url_encode(string)
43
41
  CGI.escape(string.to_s).gsub("%7E", "~").gsub("+", "%20")
44
42
  end
43
+
44
+ def self._recursion(h, base = nil)
45
+ pairs = []
46
+ h.keys.sort.each do |key|
47
+ value = h[key]
48
+ if value.kind_of? Hash
49
+ pairs += _recursion(value, key)
50
+ else
51
+ new_pair = nil
52
+ if base
53
+ new_pair = "#{base}[#{url_encode(key)}]=#{url_encode(value)}"
54
+ else
55
+ new_pair = "#{url_encode(key)}=#{url_encode(value)}"
56
+ end
57
+ pairs << new_pair
58
+ end
59
+ end
60
+ pairs
61
+ end
62
+
63
+
45
64
  end
46
65
  end
@@ -13,7 +13,7 @@ module Panda
13
13
  find(this_id)
14
14
  end
15
15
 
16
- def end_class_name
16
+ def sti_name
17
17
  "#{name.split('::').last}"
18
18
  end
19
19
  end
@@ -22,7 +22,7 @@ module Panda
22
22
 
23
23
  private
24
24
  def build_resource(attributes)
25
- Panda::const_get("#{end_class_name}").new(attributes.merge(:cloud_id => cloud.id))
25
+ Panda::const_get("#{sti_name}").new(attributes.merge(:cloud_id => cloud.id))
26
26
  end
27
27
  end
28
28
 
@@ -15,7 +15,7 @@ module Panda
15
15
 
16
16
  def find_by_path(url, map={})
17
17
  object = find_object_by_path(url, map)
18
- kclass = Panda::const_get("#{end_class_name}")
18
+ kclass = Panda::const_get("#{sti_name}")
19
19
 
20
20
  if object.is_a?(Array)
21
21
  object.map{|o| kclass.new(o)}
@@ -10,7 +10,7 @@ module Panda
10
10
  module ClassMethods
11
11
 
12
12
  def resource_path
13
- @url || "/#{end_class_name.downcase}s"
13
+ @url || "/#{sti_name.downcase}s"
14
14
  end
15
15
 
16
16
  def match(url)
@@ -17,8 +17,8 @@ module Panda
17
17
  @parent.is_a?(Cloud) ? @parent : @parent.cloud
18
18
  end
19
19
 
20
- def end_class_name
21
- klass.end_class_name
20
+ def sti_name
21
+ klass.sti_name
22
22
  end
23
23
 
24
24
  end
@@ -81,7 +81,7 @@ module Panda
81
81
  end
82
82
 
83
83
  def parent_relation_name
84
- "#{@parent.class.end_class_name.downcase}_id"
84
+ "#{@parent.class.sti_name.downcase}_id"
85
85
  end
86
86
  end
87
87
  end
@@ -19,7 +19,7 @@ module Panda
19
19
 
20
20
  # delegate to the scope if the method exists
21
21
  def method_missing(method_symbol, *args, &block)
22
- scope = Panda::const_get("#{end_class_name}Scope").new(self)
22
+ scope = Panda::const_get("#{sti_name}Scope").new(self)
23
23
  if scope.respond_to?(method_symbol)
24
24
  scope.send(method_symbol, *args, &block)
25
25
  else
@@ -1,74 +1,72 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{panda}
8
- s.version = "1.1.0"
8
+ s.version = "1.2.0"
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-10-19}
12
+ s.date = %q{2010-11-25}
13
13
  s.description = %q{Panda Client}
14
14
  s.email = %q{info@pandastream.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.md"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
- ".gitignore",
21
- "Gemfile",
22
- "LICENSE",
23
- "README.md",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/panda.rb",
27
- "lib/panda/api_authentication.rb",
28
- "lib/panda/base.rb",
29
- "lib/panda/connection.rb",
30
- "lib/panda/error.rb",
31
- "lib/panda/modules/associations.rb",
32
- "lib/panda/modules/builders.rb",
33
- "lib/panda/modules/cloud_connection.rb",
34
- "lib/panda/modules/finders.rb",
35
- "lib/panda/modules/router.rb",
36
- "lib/panda/modules/short_status.rb",
37
- "lib/panda/modules/updatable.rb",
38
- "lib/panda/panda.rb",
39
- "lib/panda/proxies/encoding_scope.rb",
40
- "lib/panda/proxies/profile_scope.rb",
41
- "lib/panda/proxies/proxy.rb",
42
- "lib/panda/proxies/scope.rb",
43
- "lib/panda/proxies/video_scope.rb",
44
- "lib/panda/resources/cloud.rb",
45
- "lib/panda/resources/encoding.rb",
46
- "lib/panda/resources/profile.rb",
47
- "lib/panda/resources/resource.rb",
48
- "lib/panda/resources/video.rb",
49
- "panda.gemspec",
50
- "spec/cloud_spec.rb",
51
- "spec/encoding_spec.rb",
52
- "spec/heroku_spec.rb",
53
- "spec/panda_spec.rb",
54
- "spec/profile_spec.rb",
55
- "spec/spec.opts",
56
- "spec/spec_helper.rb",
57
- "spec/video_spec.rb"
20
+ "Gemfile",
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/panda.rb",
26
+ "lib/panda/api_authentication.rb",
27
+ "lib/panda/base.rb",
28
+ "lib/panda/connection.rb",
29
+ "lib/panda/error.rb",
30
+ "lib/panda/modules/associations.rb",
31
+ "lib/panda/modules/builders.rb",
32
+ "lib/panda/modules/cloud_connection.rb",
33
+ "lib/panda/modules/finders.rb",
34
+ "lib/panda/modules/router.rb",
35
+ "lib/panda/modules/short_status.rb",
36
+ "lib/panda/modules/updatable.rb",
37
+ "lib/panda/panda.rb",
38
+ "lib/panda/proxies/encoding_scope.rb",
39
+ "lib/panda/proxies/profile_scope.rb",
40
+ "lib/panda/proxies/proxy.rb",
41
+ "lib/panda/proxies/scope.rb",
42
+ "lib/panda/proxies/video_scope.rb",
43
+ "lib/panda/resources/cloud.rb",
44
+ "lib/panda/resources/encoding.rb",
45
+ "lib/panda/resources/profile.rb",
46
+ "lib/panda/resources/resource.rb",
47
+ "lib/panda/resources/video.rb",
48
+ "panda.gemspec",
49
+ "spec/cloud_spec.rb",
50
+ "spec/encoding_spec.rb",
51
+ "spec/heroku_spec.rb",
52
+ "spec/panda_spec.rb",
53
+ "spec/profile_spec.rb",
54
+ "spec/spec.opts",
55
+ "spec/spec_helper.rb",
56
+ "spec/video_spec.rb"
58
57
  ]
59
58
  s.homepage = %q{http://github.com/newbamboo/panda_gem}
60
- s.rdoc_options = ["--charset=UTF-8"]
61
59
  s.require_paths = ["lib"]
62
60
  s.rubygems_version = %q{1.3.7}
63
61
  s.summary = %q{Panda Client}
64
62
  s.test_files = [
65
63
  "spec/cloud_spec.rb",
66
- "spec/encoding_spec.rb",
67
- "spec/heroku_spec.rb",
68
- "spec/panda_spec.rb",
69
- "spec/profile_spec.rb",
70
- "spec/spec_helper.rb",
71
- "spec/video_spec.rb"
64
+ "spec/encoding_spec.rb",
65
+ "spec/heroku_spec.rb",
66
+ "spec/panda_spec.rb",
67
+ "spec/profile_spec.rb",
68
+ "spec/spec_helper.rb",
69
+ "spec/video_spec.rb"
72
70
  ]
73
71
 
74
72
  if s.respond_to? :specification_version then
@@ -76,15 +74,36 @@ Gem::Specification.new do |s|
76
74
  s.specification_version = 3
77
75
 
78
76
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
77
+ s.add_runtime_dependency(%q<ruby-hmac>, [">= 0.3.2"])
78
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
79
+ s.add_runtime_dependency(%q<json>, [">= 0"])
80
+ s.add_runtime_dependency(%q<jeweler>, [">= 0"])
81
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
82
+ s.add_runtime_dependency(%q<rspec>, ["= 1.3.1"])
83
+ s.add_runtime_dependency(%q<webmock>, ["= 1.6.1"])
79
84
  s.add_runtime_dependency(%q<ruby-hmac>, [">= 0.3.2"])
80
85
  s.add_runtime_dependency(%q<rest-client>, [">= 1.4"])
81
86
  s.add_runtime_dependency(%q<json>, [">= 1.2"])
82
87
  else
88
+ s.add_dependency(%q<ruby-hmac>, [">= 0.3.2"])
89
+ s.add_dependency(%q<rest-client>, [">= 0"])
90
+ s.add_dependency(%q<json>, [">= 0"])
91
+ s.add_dependency(%q<jeweler>, [">= 0"])
92
+ s.add_dependency(%q<rake>, [">= 0"])
93
+ s.add_dependency(%q<rspec>, ["= 1.3.1"])
94
+ s.add_dependency(%q<webmock>, ["= 1.6.1"])
83
95
  s.add_dependency(%q<ruby-hmac>, [">= 0.3.2"])
84
96
  s.add_dependency(%q<rest-client>, [">= 1.4"])
85
97
  s.add_dependency(%q<json>, [">= 1.2"])
86
98
  end
87
99
  else
100
+ s.add_dependency(%q<ruby-hmac>, [">= 0.3.2"])
101
+ s.add_dependency(%q<rest-client>, [">= 0"])
102
+ s.add_dependency(%q<json>, [">= 0"])
103
+ s.add_dependency(%q<jeweler>, [">= 0"])
104
+ s.add_dependency(%q<rake>, [">= 0"])
105
+ s.add_dependency(%q<rspec>, ["= 1.3.1"])
106
+ s.add_dependency(%q<webmock>, ["= 1.6.1"])
88
107
  s.add_dependency(%q<ruby-hmac>, [">= 0.3.2"])
89
108
  s.add_dependency(%q<rest-client>, [">= 1.4"])
90
109
  s.add_dependency(%q<json>, [">= 1.2"])
@@ -5,7 +5,7 @@ require 'spec'
5
5
  require 'spec/autorun'
6
6
 
7
7
  require 'webmock/rspec'
8
- include WebMock
8
+ include WebMock::API
9
9
 
10
10
  def hputs(*args)
11
11
  puts ERB::Util.html_escape(args.join("\n")).gsub(/\r?\n/, '<br/>') + '<br/>'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - New Bamboo
@@ -15,12 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-19 00:00:00 +01:00
18
+ date: 2010-11-25 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: ruby-hmac
23
- prerelease: false
24
22
  requirement: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
24
  requirements:
@@ -33,11 +31,115 @@ dependencies:
33
31
  - 2
34
32
  version: 0.3.2
35
33
  type: :runtime
34
+ name: ruby-hmac
35
+ prerelease: false
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
38
48
  name: rest-client
39
49
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ name: json
63
+ prerelease: false
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :runtime
76
+ name: jeweler
77
+ prerelease: false
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ type: :runtime
90
+ name: rake
91
+ prerelease: false
92
+ version_requirements: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - "="
98
+ - !ruby/object:Gem::Version
99
+ hash: 25
100
+ segments:
101
+ - 1
102
+ - 3
103
+ - 1
104
+ version: 1.3.1
105
+ type: :runtime
106
+ name: rspec
107
+ prerelease: false
108
+ version_requirements: *id006
109
+ - !ruby/object:Gem::Dependency
110
+ requirement: &id007 !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - "="
114
+ - !ruby/object:Gem::Version
115
+ hash: 13
116
+ segments:
117
+ - 1
118
+ - 6
119
+ - 1
120
+ version: 1.6.1
121
+ type: :runtime
122
+ name: webmock
123
+ prerelease: false
124
+ version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ requirement: &id008 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 23
132
+ segments:
133
+ - 0
134
+ - 3
135
+ - 2
136
+ version: 0.3.2
137
+ type: :runtime
138
+ name: ruby-hmac
139
+ prerelease: false
140
+ version_requirements: *id008
141
+ - !ruby/object:Gem::Dependency
142
+ requirement: &id009 !ruby/object:Gem::Requirement
41
143
  none: false
42
144
  requirements:
43
145
  - - ">="
@@ -48,11 +150,11 @@ dependencies:
48
150
  - 4
49
151
  version: "1.4"
50
152
  type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: json
153
+ name: rest-client
54
154
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
155
+ version_requirements: *id009
156
+ - !ruby/object:Gem::Dependency
157
+ requirement: &id010 !ruby/object:Gem::Requirement
56
158
  none: false
57
159
  requirements:
58
160
  - - ">="
@@ -63,7 +165,9 @@ dependencies:
63
165
  - 2
64
166
  version: "1.2"
65
167
  type: :runtime
66
- version_requirements: *id003
168
+ name: json
169
+ prerelease: false
170
+ version_requirements: *id010
67
171
  description: Panda Client
68
172
  email: info@pandastream.com
69
173
  executables: []
@@ -74,7 +178,6 @@ extra_rdoc_files:
74
178
  - LICENSE
75
179
  - README.md
76
180
  files:
77
- - .gitignore
78
181
  - Gemfile
79
182
  - LICENSE
80
183
  - README.md
@@ -117,8 +220,8 @@ homepage: http://github.com/newbamboo/panda_gem
117
220
  licenses: []
118
221
 
119
222
  post_install_message:
120
- rdoc_options:
121
- - --charset=UTF-8
223
+ rdoc_options: []
224
+
122
225
  require_paths:
123
226
  - lib
124
227
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC