notify-integrity 0.1.0 → 0.2.0
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/VERSION +1 -1
- data/lib/notify-integrity.rb +44 -0
- data/notify-integrity.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8c89f8c3450ca3ac682a2e0c686049a01125689
|
4
|
+
data.tar.gz: 2b42ec166996d271bee1188f54f20b1f1942d616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4065672aee67deed140a8db37f379f364be9436a747581437e2876539de8ddef242467f7b68fb4965e49d40fa8f69cfab8a7b4be291c58f2c403fee9711d6f42
|
7
|
+
data.tar.gz: 5c511db836e46ae67a35fff9c7e92f7d40d52a7f91a4968df6337bae8acd9cd4e4ab208160b5df7f4c43610a5315364d37e521a95746e5fd9f9bc563753a9737
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/notify-integrity.rb
CHANGED
@@ -13,7 +13,12 @@ class NotifyIntegrity
|
|
13
13
|
@integrity_pass = pass
|
14
14
|
end
|
15
15
|
|
16
|
+
# #
|
17
|
+
# Do a POST request to integrity.
|
18
|
+
#
|
19
|
+
# TODO: this should use Mechanize too.
|
16
20
|
# uses Net::HTTP
|
21
|
+
#
|
17
22
|
def post_request host, path, payload = {}
|
18
23
|
uri = URI("#{host}#{path}")
|
19
24
|
req = Net::HTTP::Post.new uri.path
|
@@ -33,7 +38,11 @@ class NotifyIntegrity
|
|
33
38
|
result
|
34
39
|
end
|
35
40
|
|
41
|
+
# #
|
42
|
+
# Requests a page from integrity.
|
43
|
+
#
|
36
44
|
# uses Mechanize
|
45
|
+
#
|
37
46
|
def request_page uri
|
38
47
|
raise "invalid uri" if uri.nil?
|
39
48
|
raise "integrity user or pass missing" if @integrity_user.nil? or @integrity_pass.nil?
|
@@ -42,4 +51,39 @@ class NotifyIntegrity
|
|
42
51
|
agent.add_auth uri, @integrity_user, @integrity_pass
|
43
52
|
agent.get uri
|
44
53
|
end
|
54
|
+
|
55
|
+
# #
|
56
|
+
# Queries integrity until the build has succeeded.
|
57
|
+
#
|
58
|
+
# WARNING: in current form, this continues looping until the integrity
|
59
|
+
# responds success or goes down by some server failure. I’ve had some
|
60
|
+
# situations where Integrity has created infinite build loop,
|
61
|
+
# which would cause this to loop infinitely too. Patches welcome.
|
62
|
+
#
|
63
|
+
# Returns true is success, false if not
|
64
|
+
#
|
65
|
+
def check_for_success uri
|
66
|
+
element = nil
|
67
|
+
|
68
|
+
while true
|
69
|
+
|
70
|
+
base = GerritHooks::Base.new
|
71
|
+
page = base.request_page uri
|
72
|
+
|
73
|
+
element = page.parser.at_xpath "//div[@class='building']"
|
74
|
+
break if element.to_s == ""
|
75
|
+
sleep 1
|
76
|
+
end
|
77
|
+
|
78
|
+
element = page.parser.at_xpath "//div[@class='success']"
|
79
|
+
|
80
|
+
# failure
|
81
|
+
if element.to_s == ""
|
82
|
+
success = false
|
83
|
+
else
|
84
|
+
success = true
|
85
|
+
end
|
86
|
+
|
87
|
+
success
|
88
|
+
end
|
45
89
|
end
|
data/notify-integrity.gemspec
CHANGED