updawg 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 0.3.6:
2
+ * ADD unless_below, unless_above filters to deviation check
1
3
  0.3.3:
2
4
  * ADD text reporting
3
5
  * ADD check timeouts
@@ -49,6 +49,8 @@ Checks are defined with a simple DSL:
49
49
  # Supports options:
50
50
  # scale_factor - multiple of the std_dev to user (default: 2)
51
51
  # smoothing - whether to ignore outliers in the dataset (default: true)
52
+ # skip_if_minimum_below - set to a value to skip this check for values that would be very small (default: false)
53
+ # skip_if_maximum_above - set to a value to skip this check for values that would be very large (default: false)
52
54
  deviation 'Hourly Transaction Value' do
53
55
  Transaction.group('hour').order('hour ASC') # will report if the last hour of data is our of range
54
56
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.5
1
+ 0.3.6
@@ -5,7 +5,9 @@ module Updawg
5
5
  def initialize(name, options = {}, &block)
6
6
  super(name, options, &block)
7
7
 
8
- unknown_keys = options.keys - [:deviates_high, :deviates_low, :scale_factor, :smoothing].flatten
8
+ unknown_keys = options.keys - [
9
+ :deviates_high, :deviates_low, :scale_factor, :smoothing, :unless_below, :unless_above
10
+ ].flatten
9
11
  raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty?
10
12
 
11
13
  @options = options
@@ -47,7 +49,10 @@ module Updawg
47
49
 
48
50
  min = mean - scale_factor * std_dev
49
51
  max = mean + scale_factor * std_dev
50
-
52
+
53
+ return pass("SKIP due to low minimum value") if @options[:unless_below] && min < @options[:unless_below]
54
+ return pass("SKIP due to high maximum value") if @options[:unless_above] && max > @options[:unless_above]
55
+
51
56
  return low(sample, min) if sample < min
52
57
  return high(sample, max) if sample > max
53
58
  return pass("#{sample} within expected range (#{min..max})")
@@ -120,6 +120,42 @@ describe Updawg::DeviationCheck do
120
120
  check = Updawg::DeviationCheck.new('test', @options){ @values + [@avg - 2 * @std_dev + 0.01] }
121
121
  check.perform.should be_success
122
122
  end
123
- end
124
- end
123
+ end
124
+
125
+ describe 'when unless_below is set' do
126
+ before(:each) do
127
+ @dataset = @values + [@avg - 2 * @std_dev - 1]
128
+ end
129
+
130
+ it 'should be error if values are above threshold' do
131
+ @options[:unless_below] = 1
132
+ check = Updawg::DeviationCheck.new('test', @options){ @dataset }
133
+ check.perform.should be_error
134
+ end
135
+
136
+ it 'should pass if values are below threshold' do
137
+ @options[:unless_below] = 100
138
+ check = Updawg::DeviationCheck.new('test', @options){ @dataset }
139
+ check.perform.should be_success
140
+ end
141
+ end
142
+
143
+ describe 'when unless_above is set' do
144
+ before(:each) do
145
+ @dataset = @values + [@avg + 2 * @std_dev + 1]
146
+ end
147
+
148
+ it 'should be error if values are below threshold' do
149
+ @options[:unless_above] = 100
150
+ check = Updawg::DeviationCheck.new('test', @options){ @dataset }
151
+ check.perform.should be_error
152
+ end
153
+
154
+ it 'should pass if values are above threshold' do
155
+ @options[:unless_above] = 1
156
+ check = Updawg::DeviationCheck.new('test', @options){ @dataset }
157
+ check.perform.should be_success
158
+ end
159
+ end
160
+ end
125
161
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{updawg}
8
- s.version = "0.3.5"
8
+ s.version = "0.3.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Griffin"]
12
- s.date = %q{2011-03-23}
12
+ s.date = %q{2011-04-14}
13
13
  s.email = %q{matt@griffinonline.org}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: updawg
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 5
10
- version: 0.3.5
9
+ - 6
10
+ version: 0.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Griffin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-28 00:00:00 -04:00
18
+ date: 2011-04-14 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency