cfoundry 0.3.47 → 0.3.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,6 +62,7 @@ module CFoundry
62
62
  payload = options.delete(:payload)
63
63
  params = options.delete(:params)
64
64
  return_headers = options.delete(:return_headers)
65
+ return_response = options.delete(:return_response)
65
66
 
66
67
  headers = {}
67
68
  headers["Authorization"] = @token if @token
@@ -137,6 +138,8 @@ module CFoundry
137
138
 
138
139
  if return_headers
139
140
  sane_headers(response)
141
+ elsif return_response
142
+ response
140
143
  elsif [Net::HTTP::Get, Net::HTTP::Head].include?(method) && \
141
144
  response.is_a?(Net::HTTPRedirection)
142
145
  request_uri(URI.parse(response["location"]), method, original_options)
@@ -23,14 +23,24 @@ module CFoundry
23
23
  :redirect_uri => @redirect_uri
24
24
  }
25
25
 
26
- extract_token(
26
+ auth =
27
27
  post(
28
28
  { :credentials => credentials },
29
29
  "oauth", "authorize",
30
- :return_headers => true,
30
+ :return_response => true,
31
31
  :content => :form,
32
32
  :accept => :json,
33
- :params => query)["location"])
33
+ :params => query)
34
+
35
+ case auth
36
+ when Net::HTTPRedirection
37
+ extract_token(auth["location"])
38
+ else
39
+ json = parse_json(auth.body)
40
+ raise CFoundry::Denied.new(
41
+ auth.code.to_i,
42
+ json[:error_description])
43
+ end
34
44
  end
35
45
 
36
46
  def users
@@ -38,7 +38,7 @@ module CFoundry::V1
38
38
  end
39
39
 
40
40
  def system_services
41
- get("info", "services", :accept => :json)
41
+ get("services", "v1", "offerings", :content => :json, :accept => :json)
42
42
  end
43
43
 
44
44
  def system_runtimes
@@ -87,10 +87,13 @@ module CFoundry::V1
87
87
  services = []
88
88
 
89
89
  @base.system_services.each do |type, vendors|
90
- vendors.each do |vendor, versions|
91
- versions.each do |num, meta|
92
- services <<
93
- Service.new(vendor.to_s, num.to_s, meta[:description], type)
90
+ vendors.each do |vendor, providers|
91
+ providers.each do |provider, versions|
92
+ versions.each do |num, meta|
93
+ services <<
94
+ Service.new(vendor.to_s, num.to_s, meta[:description],
95
+ type, provider.to_s)
96
+ end
94
97
  end
95
98
  end
96
99
  end
@@ -1,12 +1,14 @@
1
1
  module CFoundry::V1
2
2
  class Service
3
- attr_accessor :label, :version, :description, :type
3
+ attr_accessor :label, :version, :description, :type, :provider
4
4
 
5
- def initialize(label, version = nil, description = nil, type = nil)
5
+ def initialize(label, version = nil, description = nil,
6
+ type = nil, provider = "core")
6
7
  @label = label
7
8
  @description = description
8
9
  @version = version
9
- @type = nil
10
+ @type = type
11
+ @provider = provider
10
12
  end
11
13
 
12
14
  def eql?(other)
@@ -14,10 +16,6 @@ module CFoundry::V1
14
16
  end
15
17
  alias :== :eql?
16
18
 
17
- def provider
18
- "core"
19
- end
20
-
21
19
  def active
22
20
  true
23
21
  end
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.3.47"
3
+ VERSION = "0.3.48"
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: 77
4
+ hash: 115
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 47
10
- version: 0.3.47
9
+ - 48
10
+ version: 0.3.48
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-10-19 00:00:00 Z
18
+ date: 2012-10-22 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: multipart-post