build_status_server 0.15 → 0.17
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.
- data/.gitignore +1 -0
- data/Gemfile +0 -9
- data/README.md +2 -1
- data/build_status_server.gemspec +2 -1
- data/lib/build_status_server/cli.rb +24 -24
- data/lib/build_status_server/config.rb +1 -1
- data/lib/build_status_server/server.rb +3 -3
- data/lib/build_status_server/version.rb +1 -1
- data/spec/lib/build_status_server/config_spec.rb +3 -3
- data/spec/lib/build_status_server/server_spec.rb +8 -8
- data/spec/spec_helper.rb +3 -1
- metadata +20 -5
- data/Gemfile.lock +0 -66
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Build Notifier
|
2
2
|
[](http://travis-ci.org/jcmuller/build_status_server)
|
3
|
-
[](https://gemnasium.com/jcmuller/build_status_server)
|
4
|
+
[](https://codeclimate.com/github/jcmuller/build_status_server)
|
4
5
|
|
5
6
|
This utility is part of an XFD (eXtreme Feedback Device) solution designed and
|
6
7
|
built for my employer [ChallengePost](http://challengepost.com). It works in
|
data/build_status_server.gemspec
CHANGED
@@ -28,9 +28,10 @@ Notification Plugin)) and an Arduino powered Traffic Light controller
|
|
28
28
|
s.test_files = Dir["spec/**/*_spec.rb"]
|
29
29
|
|
30
30
|
s.add_development_dependency("rake")
|
31
|
-
s.add_development_dependency("
|
31
|
+
s.add_development_dependency("pry-debugger")
|
32
32
|
s.add_development_dependency("sinatra")
|
33
33
|
|
34
34
|
s.add_dependency("json")
|
35
|
+
s.add_dependency("command_line_helper")
|
35
36
|
end
|
36
37
|
|
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'getoptlong'
|
2
|
+
require 'command_line_helper'
|
2
3
|
|
3
4
|
module BuildStatusServer
|
4
5
|
class CLI
|
6
|
+
include CommandLineHelper::HelpText
|
7
|
+
|
5
8
|
attr_reader :options
|
6
9
|
|
7
10
|
def initialize
|
11
|
+
set_program_name
|
8
12
|
begin
|
9
13
|
process_command_line_options
|
10
14
|
rescue GetoptLong::MissingArgument
|
@@ -17,17 +21,19 @@ module BuildStatusServer
|
|
17
21
|
|
18
22
|
private
|
19
23
|
|
24
|
+
def options_possible
|
25
|
+
[
|
26
|
+
['--config', '-c', GetoptLong::REQUIRED_ARGUMENT, 'Override the configuration file location'],
|
27
|
+
['--help', '-h', GetoptLong::NO_ARGUMENT, 'Show this text'],
|
28
|
+
['--verbose', '-v', GetoptLong::NO_ARGUMENT, ''],
|
29
|
+
['--version', '-V', GetoptLong::NO_ARGUMENT, 'Show version info'],
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
20
33
|
def process_command_line_options
|
21
34
|
@options = {}
|
22
35
|
|
23
|
-
|
24
|
-
['--config', '-c', GetoptLong::REQUIRED_ARGUMENT],
|
25
|
-
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
26
|
-
['--verbose', '-v', GetoptLong::NO_ARGUMENT],
|
27
|
-
['--version', '-V', GetoptLong::NO_ARGUMENT],
|
28
|
-
]
|
29
|
-
|
30
|
-
GetoptLong.new(*possible_arguments).each do |opt, arg|
|
36
|
+
cli_options.each do |opt, arg|
|
31
37
|
case opt
|
32
38
|
when '--help'
|
33
39
|
show_help_and_exit
|
@@ -36,15 +42,19 @@ module BuildStatusServer
|
|
36
42
|
when '--verbose'
|
37
43
|
options[:verbose] = true
|
38
44
|
when '--version'
|
39
|
-
puts
|
45
|
+
puts version_info
|
40
46
|
exit
|
41
47
|
end
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
45
|
-
def
|
51
|
+
def cli_options
|
52
|
+
@cli_options ||= GetoptLong.new(*options_possible.map{ |o| o.first(3) })
|
53
|
+
end
|
54
|
+
|
55
|
+
def version_info
|
46
56
|
<<-EOV
|
47
|
-
#{
|
57
|
+
#{program_name}, version #{VERSION}
|
48
58
|
|
49
59
|
(c) Juan C. Muller, 2012
|
50
60
|
http://github.com/jcmuller/build_status_server
|
@@ -52,22 +62,12 @@ http://github.com/jcmuller/build_status_server
|
|
52
62
|
end
|
53
63
|
|
54
64
|
def show_help_and_exit
|
55
|
-
puts
|
56
|
-
Usage: #{get_program_name} [options]
|
57
|
-
|
58
|
-
Options:
|
59
|
-
-c, --config CONFIGURATION Specify what configuration file to load
|
60
|
-
-h, --help Display this very helpful text
|
61
|
-
-v, --verbose Be more informative about what's going on
|
62
|
-
-V, --version Print out current version info
|
63
|
-
|
64
|
-
#{get_version}
|
65
|
-
EOT
|
65
|
+
STDOUT.puts help_info
|
66
66
|
exit
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
70
|
-
File.basename($0)
|
69
|
+
def set_program_name
|
70
|
+
$0 = "#{File.basename($0)} (#{VERSION})"
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -68,7 +68,7 @@ strongly recommended to create one in any of the following locations:
|
|
68
68
|
#{get_example_config}
|
69
69
|
|
70
70
|
Also, you can specify what configuration file to load by passing --config as an
|
71
|
-
argument (see "
|
71
|
+
argument (see "build_status_server --help")
|
72
72
|
|
73
73
|
EOT
|
74
74
|
|
@@ -24,7 +24,7 @@ module BuildStatusServer
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def process_loop
|
27
|
-
data,
|
27
|
+
data, _ = udp_server.recvfrom(2048)
|
28
28
|
|
29
29
|
if process_job(data)
|
30
30
|
status = process_all_statuses
|
@@ -69,7 +69,7 @@ The address configured is not available (#{address})
|
|
69
69
|
def process_job(data = "{}")
|
70
70
|
job = begin
|
71
71
|
JSON.parse(data)
|
72
|
-
rescue JSON::ParserError
|
72
|
+
rescue JSON::ParserError
|
73
73
|
STDERR.puts "Invalid JSON! (Or at least JSON wasn't able to parse it...)\nReceived: #{data}"
|
74
74
|
return false
|
75
75
|
end
|
@@ -144,7 +144,7 @@ The address configured is not available (#{address})
|
|
144
144
|
timeout(5) do
|
145
145
|
attempts += 1
|
146
146
|
client = TCPSocket.new(tcp_client["host"], tcp_client["port"])
|
147
|
-
client.print "GET #{light} HTTP/1.0\n\n"
|
147
|
+
client.print "GET #{light} HTTP/1.0\r\n\r\n"
|
148
148
|
answer = client.gets(nil)
|
149
149
|
STDOUT.puts answer if config.verbose
|
150
150
|
end
|
@@ -55,7 +55,7 @@ describe BuildStatusServer::Config do
|
|
55
55
|
|
56
56
|
it "should throw an exception if the config file doesn't exist" do
|
57
57
|
file_name = "/tmp/i_dont_exist.yml"
|
58
|
-
expect { config.send(:load_config_file, file_name) }.
|
58
|
+
expect { config.send(:load_config_file, file_name) }.to raise_error RuntimeError, "Supplied config file (#{file_name}) doesn't seem to exist"
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should throw an exception if the config file isn't a hash" do
|
@@ -64,7 +64,7 @@ describe BuildStatusServer::Config do
|
|
64
64
|
f.puts "YADDA YADDA"
|
65
65
|
file_name = f.path
|
66
66
|
end
|
67
|
-
expect { config.send(:load_config_file, file_name) }.
|
67
|
+
expect { config.send(:load_config_file, file_name) }.to raise_error RuntimeError, "This is an invalid configuration file!"
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should return the default options if no default location is found" do
|
@@ -94,7 +94,7 @@ describe BuildStatusServer::Config do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should not respond to methods named after elements that don't exist" do
|
97
|
-
expect
|
97
|
+
expect{ config.blah }.to raise_error NoMethodError
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -228,7 +228,7 @@ describe BuildStatusServer::Server do
|
|
228
228
|
|
229
229
|
it "doesn't die if invalid JSON is passed in" do
|
230
230
|
STDERR.should_receive(:puts).with("Invalid JSON! (Or at least JSON wasn't able to parse it...)\nReceived: {b => \"123\"}")
|
231
|
-
expect { server.send(:process_job, '{b => "123"}') }.
|
231
|
+
expect { server.send(:process_job, '{b => "123"}') }.to_not raise_error(JSON::ParserError)
|
232
232
|
end
|
233
233
|
|
234
234
|
it "returns false and says so on stderr if payload doesn't have a hash for build" do
|
@@ -319,12 +319,12 @@ describe BuildStatusServer::Server do
|
|
319
319
|
end
|
320
320
|
|
321
321
|
it "should send passing packet to tcp socket when status is true" do
|
322
|
-
client.should_receive(:print).with("GET pass HTTP/1.0\n\n")
|
322
|
+
client.should_receive(:print).with("GET pass HTTP/1.0\r\n\r\n")
|
323
323
|
server.send(:notify, true)
|
324
324
|
end
|
325
325
|
|
326
326
|
it "should send failing packet to tcp socket when status is false" do
|
327
|
-
client.should_receive(:print).with("GET fail HTTP/1.0\n\n")
|
327
|
+
client.should_receive(:print).with("GET fail HTTP/1.0\r\n\r\n")
|
328
328
|
server.send(:notify, false)
|
329
329
|
end
|
330
330
|
end
|
@@ -350,8 +350,8 @@ describe BuildStatusServer::Server do
|
|
350
350
|
it "should time out and retry 2 times" do
|
351
351
|
TCPSocket.should_receive(:new).exactly(3).with("host", "port").and_return(client)
|
352
352
|
STDERR.should_receive(:puts).exactly(2).with("Error: Timeout::Error while trying to send fail")
|
353
|
-
client.should_receive(:print).exactly(2).with("GET fail HTTP/1.0\n\n").and_raise(Timeout::Error)
|
354
|
-
client.should_receive(:print).with("GET fail HTTP/1.0\n\n")
|
353
|
+
client.should_receive(:print).exactly(2).with("GET fail HTTP/1.0\r\n\r\n").and_raise(Timeout::Error)
|
354
|
+
client.should_receive(:print).with("GET fail HTTP/1.0\r\n\r\n")
|
355
355
|
|
356
356
|
server.send(:notify, false)
|
357
357
|
end
|
@@ -373,7 +373,7 @@ describe BuildStatusServer::Server do
|
|
373
373
|
server.should_receive(:sleep).with(4)
|
374
374
|
server.should_receive(:sleep).with(8)
|
375
375
|
|
376
|
-
client.should_receive(:print).with("GET fail HTTP/1.0\n\n")
|
376
|
+
client.should_receive(:print).with("GET fail HTTP/1.0\r\n\r\n")
|
377
377
|
|
378
378
|
server.send(:notify, false)
|
379
379
|
end
|
@@ -396,8 +396,8 @@ describe BuildStatusServer::Server do
|
|
396
396
|
client.should_receive(:gets).and_return("answer")
|
397
397
|
TCPSocket.should_receive(:new).exactly(3).with("host", "port").and_return(client)
|
398
398
|
STDERR.should_receive(:puts).exactly(2).with("Error: Timeout::Error while trying to send fail")
|
399
|
-
client.should_receive(:print).exactly(2).with("GET fail HTTP/1.0\n\n").and_raise(Timeout::Error)
|
400
|
-
client.should_receive(:print).with("GET fail HTTP/1.0\n\n")
|
399
|
+
client.should_receive(:print).exactly(2).with("GET fail HTTP/1.0\r\n\r\n").and_raise(Timeout::Error)
|
400
|
+
client.should_receive(:print).with("GET fail HTTP/1.0\r\n\r\n")
|
401
401
|
|
402
402
|
server.send(:notify, false)
|
403
403
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build_status_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.17'
|
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-
|
12
|
+
date: 2012-11-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: pry-debugger
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: command_line_helper
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
description: A build notifier server for Jenkins CI that controls an XFD over HTTP
|
79
95
|
email: jcmuller@gmail.com
|
80
96
|
executables:
|
@@ -85,7 +101,6 @@ files:
|
|
85
101
|
- .gitignore
|
86
102
|
- .travis.yml
|
87
103
|
- Gemfile
|
88
|
-
- Gemfile.lock
|
89
104
|
- LICENSE
|
90
105
|
- README.md
|
91
106
|
- Rakefile
|
@@ -127,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
142
|
version: '0'
|
128
143
|
requirements: []
|
129
144
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.8.
|
145
|
+
rubygems_version: 1.8.24
|
131
146
|
signing_key:
|
132
147
|
specification_version: 3
|
133
148
|
summary: This utility is part of an XFD (eXtreeme Feedback Device) solution designed
|
data/Gemfile.lock
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
build_status_server (0.15)
|
5
|
-
json
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
archive-tar-minitar (0.5.2)
|
11
|
-
builder (3.0.0)
|
12
|
-
ci_reporter (1.7.0)
|
13
|
-
builder (>= 2.1.2)
|
14
|
-
columnize (0.3.6)
|
15
|
-
diff-lcs (1.1.3)
|
16
|
-
json (1.7.0)
|
17
|
-
linecache19 (0.5.12)
|
18
|
-
ruby_core_source (>= 0.1.4)
|
19
|
-
multi_json (1.3.4)
|
20
|
-
rack (1.4.1)
|
21
|
-
rack-protection (1.2.0)
|
22
|
-
rack
|
23
|
-
rake (0.9.2.2)
|
24
|
-
rspec (2.10.0)
|
25
|
-
rspec-core (~> 2.10.0)
|
26
|
-
rspec-expectations (~> 2.10.0)
|
27
|
-
rspec-mocks (~> 2.10.0)
|
28
|
-
rspec-core (2.10.0)
|
29
|
-
rspec-expectations (2.10.0)
|
30
|
-
diff-lcs (~> 1.1.3)
|
31
|
-
rspec-mocks (2.10.1)
|
32
|
-
ruby-debug-base19 (0.11.25)
|
33
|
-
columnize (>= 0.3.1)
|
34
|
-
linecache19 (>= 0.5.11)
|
35
|
-
ruby_core_source (>= 0.1.4)
|
36
|
-
ruby-debug19 (0.11.6)
|
37
|
-
columnize (>= 0.3.1)
|
38
|
-
linecache19 (>= 0.5.11)
|
39
|
-
ruby-debug-base19 (>= 0.11.19)
|
40
|
-
ruby_core_source (0.1.5)
|
41
|
-
archive-tar-minitar (>= 0.5.2)
|
42
|
-
simplecov (0.6.2)
|
43
|
-
multi_json (~> 1.3)
|
44
|
-
simplecov-html (~> 0.5.3)
|
45
|
-
simplecov-html (0.5.3)
|
46
|
-
simplecov-rcov (0.2.3)
|
47
|
-
simplecov (>= 0.4.1)
|
48
|
-
sinatra (1.3.2)
|
49
|
-
rack (~> 1.3, >= 1.3.6)
|
50
|
-
rack-protection (~> 1.2)
|
51
|
-
tilt (~> 1.3, >= 1.3.3)
|
52
|
-
tilt (1.3.3)
|
53
|
-
|
54
|
-
PLATFORMS
|
55
|
-
ruby
|
56
|
-
|
57
|
-
DEPENDENCIES
|
58
|
-
build_status_server!
|
59
|
-
ci_reporter
|
60
|
-
json
|
61
|
-
rake
|
62
|
-
rspec
|
63
|
-
ruby-debug19
|
64
|
-
simplecov
|
65
|
-
simplecov-rcov
|
66
|
-
sinatra
|