capacity 0.0.5 → 0.0.6
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.tar.gz.sig +0 -0
- data/Rakefile +1 -1
- data/capacity.gemspec +2 -2
- data/lib/capacity/response.rb +29 -15
- metadata +3 -3
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('capacity', '0.0.
|
5
|
+
Echoe.new('capacity', '0.0.6') do |p|
|
6
6
|
p.summary = "Driver for the Capacity API"
|
7
7
|
p.description = 'Not even alpha, not for production use, and not much use to anyone but us at the moment!'
|
8
8
|
p.url = 'http://getcapacity.com/'
|
data/capacity.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{capacity}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Peat Bakke"]
|
9
9
|
s.cert_chain = ["/Users/peat/.ssh/gem-public_cert.pem"]
|
10
|
-
s.date = %q{2010-10-
|
10
|
+
s.date = %q{2010-10-27}
|
11
11
|
s.description = %q{Not even alpha, not for production use, and not much use to anyone but us at the moment!}
|
12
12
|
s.email = %q{peat@getcapacity.com}
|
13
13
|
s.extra_rdoc_files = ["lib/capacity.rb", "lib/capacity/api.rb", "lib/capacity/response.rb"]
|
data/lib/capacity/response.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
module Capacity
|
2
|
+
|
2
3
|
class Response
|
3
|
-
|
4
4
|
include Enumerable
|
5
|
-
|
6
|
-
# Expects '
|
7
|
-
def initialize(
|
5
|
+
|
6
|
+
# Expects 'raw' to be a hash, created from the API's JSON response
|
7
|
+
def initialize( raw )
|
8
8
|
# setup the local key/value store
|
9
9
|
@data = {}
|
10
10
|
|
11
|
-
@status =
|
11
|
+
@status = raw['status']
|
12
12
|
|
13
|
-
if
|
13
|
+
if error?
|
14
14
|
# see if there's an error
|
15
|
-
@error =
|
15
|
+
@error = raw['error']
|
16
16
|
else
|
17
17
|
@error = nil
|
18
|
-
# find and convert
|
19
|
-
|
18
|
+
# find and convert rawonse data into the local format
|
19
|
+
raw.each do |k,v|
|
20
20
|
if v.is_a?( Hash ) # process ye olde hash
|
21
21
|
v.each { |kp,vp| @data[kp.to_sym] = vp } # symbolize keys
|
22
22
|
break
|
23
23
|
end
|
24
24
|
if v.is_a?( Array ) # we're just an array
|
25
|
-
@data
|
25
|
+
@data = v
|
26
26
|
break
|
27
27
|
end
|
28
28
|
end
|
@@ -31,7 +31,7 @@ module Capacity
|
|
31
31
|
|
32
32
|
# returns boolean for whether or not there was an error
|
33
33
|
def error?
|
34
|
-
|
34
|
+
@status != 'OK'
|
35
35
|
end
|
36
36
|
|
37
37
|
# returns the error message
|
@@ -51,11 +51,25 @@ module Capacity
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
# provides string/symbol agnostic, hash-like accessor
|
55
54
|
def []( key )
|
56
|
-
|
55
|
+
if key.is_a?( Fixnum )
|
56
|
+
@data[key]
|
57
|
+
else
|
58
|
+
@data[key.to_sym]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def hash?
|
63
|
+
@data.is_a? Hash
|
64
|
+
end
|
65
|
+
|
66
|
+
def array?
|
67
|
+
@data.is_a? Array
|
68
|
+
end
|
69
|
+
|
70
|
+
def length
|
71
|
+
@data.length
|
57
72
|
end
|
58
|
-
|
59
73
|
end
|
60
|
-
|
74
|
+
|
61
75
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Peat Bakke
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
xMeJ822ms/e03A==
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-10-
|
38
|
+
date: 2010-10-27 00:00:00 -07:00
|
39
39
|
default_executable:
|
40
40
|
dependencies: []
|
41
41
|
|
metadata.gz.sig
CHANGED
Binary file
|