okcomputer 0.7.1 → 0.7.3

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
  SHA1:
3
- metadata.gz: 6156e73e1c89ea69f5fabf39f4de0fb1dd1c1cdd
4
- data.tar.gz: d2b95792fb610387123fc0e2959c032fe5c79b9a
3
+ metadata.gz: 6fed0ca2f50d8a090b2264bd27f7908d7263b68b
4
+ data.tar.gz: f2ccdd2c93336ee08c8e1195be27e79679995659
5
5
  SHA512:
6
- metadata.gz: f90e47d7333941a0338d75f4e9d7f33653a47c3941b9abf03b820079ae013aa8ba9c5685d2289f2411313d0727ca0f11e8933589061ce22acec19513ff84ab96
7
- data.tar.gz: 7b9a87257b583e127ace648920630a82bde370c26eab12bfb50135ba93f6e14b7ffb2db1ac6eb53ce8cfe4e1f9ff3d10be4f9ac9460a5991446f0f424802d46b
6
+ metadata.gz: 3989f82168e393cfbe1baaaaad2ecfe6f393ec1c85585e44a87576b485e9b08c7e149b0a8df85af8a43868c0cf05b1baa59fdd4ac3f177ab2ccd775627561a3d
7
+ data.tar.gz: 8e13747aba25230218b07627f16880d37cbad822e71f07501c1178a74db1f7762b11b538395b4fc5483204916911b341b5315d40b2fb48507df6a60fce9b347e
@@ -173,10 +173,8 @@ example:
173
173
  #### Deprecation of Check#call
174
174
 
175
175
  Versions before 0.2.0 implemented a "#call" method which returned the message.
176
- This has been deprecated and will be removed in a future version. Please
177
- define a #check method which calls `mark_failure` and `mark_message` as
178
- appropriate. In the meantime, OkComputer displays a warning and uses the result
179
- of the #call method as the message.
176
+ This was deprecated at the time and removed in 1.0.0. Please define a #check
177
+ method which calls `mark_failure` and `mark_message` as appropriate.
180
178
 
181
179
  ## Contributing
182
180
 
@@ -2,10 +2,11 @@ module OkComputer
2
2
  class DelayedJobBackedUpCheck < SizeThresholdCheck
3
3
  attr_accessor :priority
4
4
  attr_accessor :threshold
5
+ attr_accessor :greater_than_priority
5
6
 
6
7
  # Public: Initialize a check for backed-up Delayed Job jobs
7
8
  #
8
- # priority - Which priority (or greater) to check for
9
+ # priority - Which priority to check for
9
10
  # threshold - An Integer to compare the jobs count against
10
11
  # to consider it backed up
11
12
  #
@@ -14,19 +15,22 @@ module OkComputer
14
15
  # # => The check will look for jobs with priority between
15
16
  # # 0 and 10, considering the jobs as backed up if there
16
17
  # # are more than 50 of them
17
- def initialize(priority, threshold)
18
+ def initialize(priority, threshold, options = {})
18
19
  self.priority = Integer(priority)
19
20
  self.threshold = Integer(threshold)
20
- self.name = "Delayed Jobs within priority '#{priority}'"
21
+ self.greater_than_priority = !!options[:greater_than_priority]
22
+ self.name = greater_than_priority ? "Delayed Jobs with priority higher than '#{priority}'" : "Delayed Jobs with priority lower than '#{priority}'"
21
23
  end
22
24
 
23
25
  # Public: How many delayed jobs are pending within the given priority
24
26
  def size
25
27
  if defined?(::Delayed::Backend::Mongoid::Job) && Delayed::Worker.backend == Delayed::Backend::Mongoid::Job
26
- Delayed::Job.lte(priority: priority).where(:locked_at => nil, :last_error => nil).count
28
+ query = greater_than_priority ? Delayed::Job.gte(priority: priority) : Delayed::Job.lte(priority: priority)
27
29
  else
28
- Delayed::Job.where("priority <= ?", priority).where(:locked_at => nil, :last_error => nil).count
30
+ operator = greater_than_priority ? ">=" : "<="
31
+ query = Delayed::Job.where("priority #{operator} ?", priority)
29
32
  end
33
+ query.where(:locked_at => nil, :last_error => nil).count
30
34
  end
31
35
  end
32
36
  end
@@ -29,7 +29,7 @@ module OkComputer
29
29
  # expensive operation from happening more than once
30
30
  size = self.size
31
31
  if size <= threshold
32
- mark_message " #{name} at reasonable level (#{size})"
32
+ mark_message "#{name} at reasonable level (#{size})"
33
33
  else
34
34
  mark_failure
35
35
  mark_message "#{name} is #{size - threshold} over threshold! (#{size})"
@@ -1,7 +1,5 @@
1
1
  module OkComputer
2
2
  class Check
3
- CALL_DEPRECATION_MESSAGE = "Deprecation warning: Please define #check rather than defining #call"
4
-
5
3
  # to be set by Registry upon registration
6
4
  attr_accessor :registrant_name
7
5
  # nil by default, only set to true if the check deems itself failed
@@ -20,13 +18,7 @@ module OkComputer
20
18
  # Your subclass of Check must define its own #check method. This method
21
19
  # must return the string to render when performing the check.
22
20
  def check
23
- if respond_to? :call
24
- warn CALL_DEPRECATION_MESSAGE
25
- # The old #call methods returned the message, so use that to set the message output
26
- mark_message call
27
- else
28
- raise(CheckNotDefined, "Your subclass must define its own #check.")
29
- end
21
+ raise(CheckNotDefined, "Your subclass must define its own #check.")
30
22
  end
31
23
  private :check
32
24
 
@@ -1,3 +1,3 @@
1
1
  module OkComputer
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.3"
3
3
  end
@@ -15,12 +15,5 @@ require "ok_computer/built_in_checks/delayed_job_backed_up_check"
15
15
  require "ok_computer/built_in_checks/ruby_version_check"
16
16
  require "ok_computer/built_in_checks/cache_check"
17
17
 
18
- # Remove the following code in version 1.0.0
19
- module OKComputer
20
- def self.method_missing(*args)
21
- raise 'Please replace all usages of `OKComputer` with `OkComputer` (lowercase `k`)'
22
- end
23
- end
24
-
25
18
  OkComputer::Registry.register "default", OkComputer::DefaultCheck.new
26
19
  OkComputer::Registry.register "database", OkComputer::ActiveRecordCheck.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okcomputer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Byrne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-18 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rspec-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement