cfoundry 0.3.49 → 0.3.50

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.
@@ -41,7 +41,7 @@ module CFoundry
41
41
 
42
42
  def parse_json(x)
43
43
  if x.empty?
44
- raise MultiJson::DecodeError, "Empty JSON string"
44
+ raise MultiJson::DecodeError, "Empty JSON string", [], ""
45
45
  else
46
46
  MultiJson.load(x, :symbolize_keys => true)
47
47
  end
@@ -170,6 +170,7 @@ module CFoundry::V1
170
170
  if s == "STARTED"
171
171
  healthy_count = running_instances
172
172
  expected = total_instances
173
+
173
174
  if healthy_count && expected > 0
174
175
  ratio = healthy_count / expected.to_f
175
176
  if ratio == 1.0
@@ -155,18 +155,40 @@ module CFoundry::V2
155
155
  #
156
156
  # Otherwise, returns application's status.
157
157
  def health
158
- state
158
+ if state == "STARTED"
159
+ healthy_count = running_instances
160
+ expected = total_instances
161
+
162
+ if expected > 0
163
+ ratio = healthy_count / expected.to_f
164
+ if ratio == 1.0
165
+ "RUNNING"
166
+ else
167
+ "#{(ratio * 100).to_i}%"
168
+ end
169
+ else
170
+ "N/A"
171
+ end
172
+ else
173
+ state
174
+ end
175
+ end
176
+
177
+ def running_instances
178
+ running = 0
179
+
180
+ instances.each do |i|
181
+ running += 1 if i.state == "RUNNING"
182
+ end
183
+
184
+ running
159
185
  end
160
186
 
161
187
  # Check that all application instances are running.
162
188
  def healthy?
163
189
  # invalidate cache so the check is fresh
164
190
  @manifest = nil
165
-
166
- case health
167
- when "RUNNING", "STARTED"
168
- true
169
- end
191
+ health == "RUNNING"
170
192
  end
171
193
  alias_method :running?, :healthy?
172
194
 
@@ -3,6 +3,7 @@ require "cfoundry/v2/model"
3
3
  module CFoundry::V2
4
4
  class Domain < Model
5
5
  attribute :name, :string
6
+ attribute :wildcard, :boolean, :default => true
6
7
  to_one :owning_organization, :as => :organization
7
8
 
8
9
  scoped_to_organization :owning_organization
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.3.49"
3
+ VERSION = "0.3.50"
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: 113
4
+ hash: 119
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 49
10
- version: 0.3.49
9
+ - 50
10
+ version: 0.3.50
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-25 00:00:00 Z
18
+ date: 2012-10-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: multipart-post