what 0.3.5 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: b7547e3ff15bde71d6ea54f59868e2b124607b31
4
- data.tar.gz: 2185de6ea7439e8f42194fa7b02ca50c88f61044
3
+ metadata.gz: caebdb83a2b6cec1541c7b2ec45630db05a7befe
4
+ data.tar.gz: 3c953a8a838ec1583272569c4da7da3dabf4b0f2
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: 1f0b2654728e3e86043c8597f365867c0d822c49a0f0731b2f9b6de35a906df0956e99aec2938603de012b2214e39d1741e095e750bca57ef38a3ba63c42add2
7
- data.tar.gz: f1b70e9215cb2e340211c2274ee59704c2080ff14c6d4e3079a1722a45b8ebec89df4c6746863616116611b75370355f3edb900fbcf169f852e1786df8b35fae
6
+ metadata.gz: 85712eea83510e0052cb44cabd828e9645948d8ca6ffcf6225687c362dd1a5def6368b873d43ed3964a217447082984bdb9d97c64b6c3754486665ca4462e361
7
+ data.tar.gz: 6af36b9d606608572913a284ad93bb929d885add6cb6661e8b2b0af062bda4edb16034f629487dfde3a2ea71d9b34df31555de8674fee3f2269e2e6cefe07e43
data/lib/what/helpers.rb CHANGED
@@ -4,14 +4,15 @@ module What
4
4
  # the principle that overall health == the worst sub-health.
5
5
  HEALTH = %w(ok warning alert)
6
6
  def self.overall_health(healths)
7
- worst_health = healths.map do |health|
8
- HEALTH.index(health) || HEALTH.index('alert')
9
- end.max
7
+ worst_health(healths)
8
+ end
10
9
 
11
- # No news is null news.
12
- if worst_health
13
- HEALTH[worst_health]
14
- end
10
+ def self.worst_health(healths)
11
+ ordered_healths(healths).last
12
+ end
13
+
14
+ def self.best_health(healths)
15
+ ordered_healths(healths).first
15
16
  end
16
17
 
17
18
  # Stolen from Rails (http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html)
@@ -41,5 +42,14 @@ module What
41
42
  def self.process_lines
42
43
  `ps aux`.encode('UTF-16', invalid: :replace, undef: :replace).encode('UTF-8').split("\n")
43
44
  end
45
+
46
+ private
47
+
48
+ def self.ordered_healths(healths)
49
+ healths.sort_by do |health|
50
+ HEALTH.index(health) || HEALTH.index('alert')
51
+ end
52
+ end
53
+
44
54
  end
45
55
  end
data/lib/what/modules.rb CHANGED
@@ -17,6 +17,8 @@ module What
17
17
  end
18
18
  end
19
19
 
20
+ # TODO: Load modules in the correct order (i.e., superclasses before
21
+ # subclasses).
20
22
  def self.require_dir(path)
21
23
  Dir[File.join(path, '*.rb')].each do |fn|
22
24
  require fn
data/lib/what/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module What
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: what
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Fitzgerald
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-01-21 00:00:00.000000000 Z
13
+ date: 2014-10-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project: what
127
- rubygems_version: 2.0.0
127
+ rubygems_version: 2.0.3
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Simple server monitoring tool