pingdom 0.1.2 → 0.1.4
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 +4 -4
- data/lib/pingdom/base.rb +8 -9
- data/lib/pingdom/summary_outage.rb +8 -0
- data/lib/pingdom/summary_performance.rb +11 -0
- data/lib/pingdom/validator.rb +80 -0
- data/lib/pingdom/version.rb +1 -1
- data/lib/pingdom.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec0019c8887e2600c0ad0b892ebd9e00ccd427d1
|
4
|
+
data.tar.gz: d9f0c1b704fa686b34720798c4d2f53f440aa1e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e2cdb42f5084b038f8ccba8f03fa6d5bfb09893b0dde8576fb076269485930ed80092a06c8811895d8f3aca041e724661c9483ae88fc69c06fe0cbfeef86ced
|
7
|
+
data.tar.gz: 5d9fd6ddfca6d3fde03125758c94032f5563b867d269d9773e21837152baae904e85cf952162d28a568df4c0197591bf3baa9b8f7a63ae18634ab9efc90bb101
|
data/lib/pingdom/base.rb
CHANGED
@@ -17,15 +17,10 @@ module Pingdom
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def find id,
|
20
|
+
def find id, *args
|
21
|
+
validator=Pingdom::Validator.new
|
21
22
|
|
22
|
-
@@params=
|
23
|
-
|
24
|
-
@@params[:from]= from.to_i if from
|
25
|
-
@@params[:to]= to.to_i if to
|
26
|
-
@@params[:order]= order if order and %q(ask desc).include?(order)
|
27
|
-
@@params[:resolution]= resolution if resolution and %q(hour day week).include?(resolution)
|
28
|
-
@@params[:includeuptime]= includeuptime if includeuptime and %q(true false).include?(includeuptime)
|
23
|
+
@@params=validator.validate input: args, permit: permit, params: params
|
29
24
|
|
30
25
|
parse client.get( path: "#{path}/#{id}" , params: params)
|
31
26
|
|
@@ -38,6 +33,10 @@ module Pingdom
|
|
38
33
|
def path
|
39
34
|
end
|
40
35
|
|
36
|
+
def permit
|
37
|
+
{}
|
38
|
+
end
|
39
|
+
|
41
40
|
def collection_type
|
42
41
|
path[1..-2]
|
43
42
|
end
|
@@ -82,6 +81,7 @@ module Pingdom
|
|
82
81
|
def limited
|
83
82
|
body['counts']['limited']
|
84
83
|
end
|
84
|
+
|
85
85
|
end
|
86
86
|
|
87
87
|
attr_accessor :additional_field
|
@@ -121,6 +121,5 @@ module Pingdom
|
|
121
121
|
def is_time_attribute? key
|
122
122
|
time_attributes.include?(key)
|
123
123
|
end
|
124
|
-
|
125
124
|
end
|
126
125
|
end
|
@@ -18,6 +18,17 @@ module Pingdom
|
|
18
18
|
'summary'
|
19
19
|
end
|
20
20
|
|
21
|
+
def permit
|
22
|
+
{
|
23
|
+
probes: :valid_int_list?,
|
24
|
+
to: :valid_time?,
|
25
|
+
from: :valid_time?,
|
26
|
+
resolution: :valid_resolution?,
|
27
|
+
order: :valid_order?,
|
28
|
+
includeuptime: :valid_boolean_str?
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
21
32
|
end
|
22
33
|
|
23
34
|
attr_accessor :hours, :days, :weeks
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Pingdom
|
2
|
+
class Validator
|
3
|
+
|
4
|
+
attr :input, :permit, :params
|
5
|
+
|
6
|
+
def validate input: , permit: , params:
|
7
|
+
@input= input.first || {}
|
8
|
+
@permit=permit
|
9
|
+
@params=params
|
10
|
+
|
11
|
+
params.merge(format)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def filter
|
17
|
+
input.select do |k,v|
|
18
|
+
permit.keys.include?k and !v.nil?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate_all
|
23
|
+
filter.each_pair do |key, value|
|
24
|
+
raise "'#{key}' param with value: '#{value}', cannot pass the '#{permit[key]}' validation" unless send(permit[key], value)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def format
|
29
|
+
validate_all.each_pair.map do |key, value|
|
30
|
+
value=value.to_i if permit[key]==:valid_time?
|
31
|
+
[key, value]
|
32
|
+
end.to_h
|
33
|
+
end
|
34
|
+
|
35
|
+
def valid_time? time
|
36
|
+
time.is_a? Time
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid_positive_int? value
|
40
|
+
value.is_a? Integer and value>=0
|
41
|
+
end
|
42
|
+
|
43
|
+
def valid_order? order
|
44
|
+
['asc','desc'].include? order
|
45
|
+
end
|
46
|
+
|
47
|
+
def valid_resolution? resolution
|
48
|
+
%q(hour day week).include? resolution
|
49
|
+
end
|
50
|
+
|
51
|
+
def valid_boolean_str? boolstring
|
52
|
+
['true','false'].include? boolstring
|
53
|
+
end
|
54
|
+
|
55
|
+
def valid_int_list? int_list
|
56
|
+
|
57
|
+
list=int_list.split(',')
|
58
|
+
raise 'Not valid list' if list.empty?
|
59
|
+
|
60
|
+
list.each do |i|
|
61
|
+
raise "Not valid Integer" if Integer(i)!=i.to_i
|
62
|
+
end
|
63
|
+
|
64
|
+
true
|
65
|
+
rescue
|
66
|
+
false
|
67
|
+
end
|
68
|
+
|
69
|
+
def valid_str_list? str_list
|
70
|
+
|
71
|
+
list=str_list.split(',')
|
72
|
+
raise 'Not valid list' if list.empty? || str_list.count(' ')>0
|
73
|
+
|
74
|
+
true
|
75
|
+
rescue
|
76
|
+
false
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
data/lib/pingdom/version.rb
CHANGED
data/lib/pingdom.rb
CHANGED
@@ -5,6 +5,7 @@ require "pingdom/base"
|
|
5
5
|
require 'pingdom/check'
|
6
6
|
require 'pingdom/summary_outage'
|
7
7
|
require 'pingdom/summary_performance'
|
8
|
+
require 'pingdom/validator'
|
8
9
|
require 'active_support/core_ext/numeric/time'
|
9
10
|
require 'active_support/core_ext/time/acts_like'
|
10
11
|
require 'active_support/core_ext/time/calculations'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingdom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Piccinini Lagos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/pingdom/client.rb
|
132
132
|
- lib/pingdom/summary_outage.rb
|
133
133
|
- lib/pingdom/summary_performance.rb
|
134
|
+
- lib/pingdom/validator.rb
|
134
135
|
- lib/pingdom/version.rb
|
135
136
|
- pingdom.gemspec
|
136
137
|
homepage: https://github.com/diegopiccinini/pingdom
|