chicanery 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/chicanery/cctray.rb +11 -5
- data/lib/chicanery/state_comparison.rb +1 -0
- data/lib/chicanery.rb +16 -11
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/chicanery/cctray.rb
CHANGED
@@ -4,15 +4,15 @@ require 'date'
|
|
4
4
|
|
5
5
|
module Chicanery
|
6
6
|
class Cctray
|
7
|
-
attr_reader :name, :uri, :
|
7
|
+
attr_reader :name, :uri, :options
|
8
8
|
|
9
|
-
def initialize name, url,
|
10
|
-
@name, @uri, @
|
9
|
+
def initialize name, url, options={}
|
10
|
+
@name, @uri, @options = name, URI(url), options
|
11
11
|
end
|
12
12
|
|
13
13
|
def get
|
14
14
|
req = Net::HTTP::Get.new(uri.path)
|
15
|
-
req.basic_auth user, password
|
15
|
+
req.basic_auth user, password if options[:user] and options[:password]
|
16
16
|
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', verify_mode: OpenSSL::SSL::VERIFY_NONE) do |https|
|
17
17
|
https.request(req)
|
18
18
|
end
|
@@ -22,15 +22,21 @@ module Chicanery
|
|
22
22
|
def jobs
|
23
23
|
jobs = {}
|
24
24
|
Nokogiri::XML(get).css("Project").each do |project|
|
25
|
-
|
25
|
+
job = {
|
26
26
|
activity: project[:activity],
|
27
27
|
last_build_status: project[:lastBuildStatus] == 'Success' ? :success : :failure,
|
28
28
|
last_build_time: DateTime.parse(project[:lastBuildTime]),
|
29
29
|
url: project[:webUrl],
|
30
30
|
last_label: project[:lastBuildLabel]
|
31
31
|
}
|
32
|
+
jobs[project[:name]] = job unless filtered project[:name]
|
32
33
|
end
|
33
34
|
jobs
|
34
35
|
end
|
36
|
+
|
37
|
+
def filtered name
|
38
|
+
return true unless options[:include]
|
39
|
+
!options[:include].match(name)
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
@@ -8,6 +8,7 @@ module Chicanery
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def compare_job name, current, previous
|
11
|
+
return unless current and previous
|
11
12
|
return unless current[:last_build_time] > previous[:last_build_time]
|
12
13
|
succeeded_handlers.each {|handler| handler.call name, current } if current[:last_build_status] == :success
|
13
14
|
failed_handlers.each {|handler| handler.call name, current } if current[:last_build_status] == :failure
|
data/lib/chicanery.rb
CHANGED
@@ -9,20 +9,25 @@ module Chicanery
|
|
9
9
|
include Handlers
|
10
10
|
include StateComparison
|
11
11
|
|
12
|
-
VERSION = "0.0.
|
12
|
+
VERSION = "0.0.3"
|
13
13
|
|
14
14
|
def execute *args
|
15
15
|
load args.shift
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
poll_period = args.shift
|
17
|
+
loop do
|
18
|
+
previous_state = restore
|
19
|
+
current_state = {
|
20
|
+
servers: {}
|
21
|
+
}
|
22
|
+
servers.each do |server|
|
23
|
+
current_jobs = server.jobs
|
24
|
+
compare_jobs current_jobs, previous_state[:servers][server.name] if previous_state[:servers]
|
25
|
+
current_state[:servers][server.name] = current_jobs
|
26
|
+
end
|
27
|
+
run_handlers.each {|handler| handler.call current_state }
|
28
|
+
persist current_state
|
29
|
+
exit unless poll_period
|
30
|
+
sleep poll_period.to_i
|
24
31
|
end
|
25
|
-
run_handlers.each {|handler| handler.call current_state }
|
26
|
-
persist current_state
|
27
32
|
end
|
28
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chicanery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -118,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
segments:
|
120
120
|
- 0
|
121
|
-
hash: -
|
121
|
+
hash: -2729598607174781804
|
122
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
123
|
none: false
|
124
124
|
requirements:
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash: -
|
130
|
+
hash: -2729598607174781804
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
133
|
rubygems_version: 1.8.23
|