cfoundry 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ require "net/https"
2
2
  require "net/http/post/multipart"
3
3
  require "multi_json"
4
4
  require "fileutils"
5
+ require "base64"
5
6
 
6
7
  module CFoundry
7
8
  class BaseClient # :nodoc:
@@ -17,12 +18,6 @@ module CFoundry
17
18
  @log = false
18
19
  end
19
20
 
20
- def request_path(method, path, options = {})
21
- path = url(path) if path.is_a?(Array)
22
-
23
- request(method, path, options)
24
- end
25
-
26
21
  # grab the metadata from a token that looks like:
27
22
  #
28
23
  # bearer (base64 ...)
@@ -31,20 +26,15 @@ module CFoundry
31
26
  tok.sub!(/\{.+?\}/, "") # clear algo
32
27
  MultiJson.load(tok[/\{.+?\}/], :symbolize_keys => true)
33
28
 
34
- # normally i don't catch'em all, but can't expect all tokens to be the
35
- # proper format, so just silently fail as this is not critical
36
- rescue
29
+ # can't expect all tokens to be the proper format
30
+ rescue MultiJson::DecodeError
37
31
  {}
38
32
  end
39
33
 
40
- private
34
+ def request_path(method, path, options = {})
35
+ path = url(path) if path.is_a?(Array)
41
36
 
42
- def parse_json(x)
43
- if x.empty?
44
- raise MultiJson::DecodeError.new("Empty JSON string", [], "")
45
- else
46
- MultiJson.load(x, :symbolize_keys => true)
47
- end
37
+ request(method, path, options)
48
38
  end
49
39
 
50
40
  def request(method, path, options = {})
@@ -151,6 +141,16 @@ module CFoundry
151
141
  raise TargetRefused, e.message
152
142
  end
153
143
 
144
+ private
145
+
146
+ def parse_json(x)
147
+ if x.empty?
148
+ raise MultiJson::DecodeError.new("Empty JSON string", [], "")
149
+ else
150
+ MultiJson.load(x, :symbolize_keys => true)
151
+ end
152
+ end
153
+
154
154
  def mimetype(content)
155
155
  case content
156
156
  when String
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1".freeze
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Suraci
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-11-19 00:00:00 -08:00
18
+ date: 2012-11-30 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency