heartcheck-webservice 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5287acb8573ebce1aed07b1c437978068e9da634
4
+ data.tar.gz: 4c3de5001452c1f8d14a476d89596ce9b2254156
5
+ SHA512:
6
+ metadata.gz: 45c178ffec85212afe50a883bd9afa3f7c4bd9900f803b8f7a58d789710fb2ee47345ae24edd136ec192f98c1596b025043cd7591d4e81b2e67328541a9bb27c
7
+ data.tar.gz: 4d0042be71bde25148bb6eea13da955adb569e8769d8459e4bb3c61c39f83498557a732ccd0396798a03bfb70ee1ca6e50446ed08c7b5465c2129eaa26f49649
@@ -0,0 +1,87 @@
1
+ module Heartcheck
2
+ module Checks
3
+ # Check for a webservice service
4
+ # Base is set in heartcheck gem
5
+ class Webservice < Base
6
+ # validate each service
7
+ #
8
+ # @retun [void]
9
+ def validate
10
+ services.each do |service|
11
+ execute service
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ # customize the error message
18
+ # It's called in Heartcheck::Checks::Base#append_error
19
+ #
20
+ # @param name [String] An identifier of service
21
+ # @param key_error [Symbol] name of action
22
+ #
23
+ # @return [void]
24
+ def custom_error(name, key_error)
25
+ @errors << "#{name} fails to #{key_error}"
26
+ end
27
+
28
+ # execute and validation request
29
+ #
30
+ # @param service [Hash] An identifier of service
31
+ #
32
+ # @return [void]
33
+ def execute(service)
34
+ response = request_for(service)
35
+ error = valid?(response, service)
36
+
37
+ append_error(service, error) if error
38
+ rescue SocketError
39
+ append_error service, 'inaccessible'
40
+ rescue Timeout::Error
41
+ append_error service, 'timeout'
42
+ rescue => e
43
+ append_error service, e.message
44
+ end
45
+
46
+ # validate response
47
+ #
48
+ # @param response [Net:HTTP] HTTP response
49
+ # @param service [Hash] An identifier of service
50
+ #
51
+ # @return [String]
52
+ def valid?(response, service)
53
+ return nil if valid_status?(response) && valid_body?(response, service)
54
+ 'unexpected_response'
55
+ end
56
+
57
+ # validate if response is Net::HTTPSuccess
58
+ #
59
+ # @param response [Net:HTTP] HTTP response
60
+ #
61
+ # @return [Bollean]
62
+ def valid_status?(response)
63
+ response.is_a?(Net::HTTPSuccess)
64
+ end
65
+
66
+ # validate if response body contains body_match params
67
+ #
68
+ # @param response [Net:HTTP] HTTP response
69
+ # @param service [Hash] An identifier of service
70
+ #
71
+ # @return [Bollean]
72
+ def valid_body?(response, service)
73
+ service[:body_match] && response.body =~ service[:body_match]
74
+ end
75
+
76
+ # execute request
77
+ #
78
+ # @param service [Hash] An identifier of service
79
+ #
80
+ # @return [Net:HTTP]
81
+ def request_for(service)
82
+ uri = URI(service[:url])
83
+ Net::HTTP.get_response(uri)
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,7 @@
1
+ # from hearcheck gem
2
+ module Heartcheck
3
+ # gem version
4
+ module Webservice
5
+ VERSION = '1.0.1'
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require 'heartcheck'
2
+ require 'heartcheck/checks/webservice'
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: heartcheck-webservice
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Locaweb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: heartcheck
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: pry-nav
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.2.0
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.2.4
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.2.0
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.2.4
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 3.1.0
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.1.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 3.1.0
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 3.1.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: rubocop
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: 0.27.0
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.27.1
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.27.0
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 0.27.1
93
+ - !ruby/object:Gem::Dependency
94
+ name: fakeweb
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: 1.3.0
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 1.3.0
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.3.0
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.3.0
113
+ - !ruby/object:Gem::Dependency
114
+ name: yard
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: 0.8.0
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 0.8.7
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 0.8.0
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 0.8.7
133
+ - !ruby/object:Gem::Dependency
134
+ name: redcarpet
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: 3.2.0
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 3.2.2
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: 3.2.0
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 3.2.2
153
+ description: Plugin to check webservice connection in heartcheck.
154
+ email:
155
+ - desenvolvedores@locaweb.com.br
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - lib/heartcheck/checks/webservice.rb
161
+ - lib/heartcheck/webservice.rb
162
+ - lib/heartcheck/webservice/version.rb
163
+ homepage: http://developer.locaweb.com.br
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.4.3
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: A webservice checker.
187
+ test_files: []
188
+ has_rdoc: