notify-integrity 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d2b2b2993e0a101e21c67759c16235564ee3983
4
- data.tar.gz: 24b612dfc9ddb3f0833f4e60f5e2c086749650c8
3
+ metadata.gz: c8c89f8c3450ca3ac682a2e0c686049a01125689
4
+ data.tar.gz: 2b42ec166996d271bee1188f54f20b1f1942d616
5
5
  SHA512:
6
- metadata.gz: 296a5343681ad9f1bf7edc523b3ee1bb991eea8572ee53905735aadcd9ccaac43e09f378260a8db0208075a73eee9eb70364fd03683e3b68f8933d2f2438fb67
7
- data.tar.gz: a883cbc3a0aa8175de457312b9ecb51952e849e2afce7f4448f0b7db7bf6b15639647faa3e51d668f6c0f596c15d5c9411f1029d93aa4b76402c933e39773a28
6
+ metadata.gz: 4065672aee67deed140a8db37f379f364be9436a747581437e2876539de8ddef242467f7b68fb4965e49d40fa8f69cfab8a7b4be291c58f2c403fee9711d6f42
7
+ data.tar.gz: 5c511db836e46ae67a35fff9c7e92f7d40d52a7f91a4968df6337bae8acd9cd4e4ab208160b5df7f4c43610a5315364d37e521a95746e5fd9f9bc563753a9737
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "notify-integrity"
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Samu Voutilainen"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notify-integrity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samu Voutilainen