darrinholst-build-lights 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/buildlights +5 -29
- data/build-lights.gemspec +9 -15
- data/lib/buildlights.rb +38 -0
- data/lib/ccnet.rb +28 -0
- data/lib/hudson.rb +29 -0
- data/lib/lights.rb +35 -16
- data/test/{ccnet_xml_scanner_test.rb → ccnet_test.rb} +5 -6
- data/test/{hudson_feed_scanner_test.rb → hudson_test.rb} +5 -6
- data/test/lights_test.rb +2 -3
- data/test/test_helper.rb +4 -3
- metadata +9 -15
- data/lib/bottle_rocket.rb +0 -15
- data/lib/build_lights.rb +0 -7
- data/lib/ccnet_xml_scanner.rb +0 -13
- data/lib/config.rb +0 -31
- data/lib/feed_parser.rb +0 -8
- data/lib/hudson_feed_scanner.rb +0 -15
- data/lib/xml_parser.rb +0 -8
- data/test/config_test.rb +0 -70
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/bin/buildlights
CHANGED
@@ -1,32 +1,8 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
lib_dir = File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
$LOAD_PATH.unshift lib_dir if File.directory?(lib_dir)
|
5
5
|
|
6
|
-
|
6
|
+
require 'buildlights'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
url = config.ccnet_url
|
11
|
-
|
12
|
-
if(url)
|
13
|
-
puts "checking #{url}"
|
14
|
-
failed_jobs << BuildLights::CcNetXmlScanner.new(url)
|
15
|
-
else
|
16
|
-
puts "skipping ccnet, ccnet_url not found"
|
17
|
-
end
|
18
|
-
|
19
|
-
url = config.hudson_url
|
20
|
-
|
21
|
-
if(url)
|
22
|
-
puts "checking #{url}"
|
23
|
-
failed_jobs << BuildLights::HudsonFeedScanner.new(url)
|
24
|
-
else
|
25
|
-
puts "skipping hudson, hudson_url not found"
|
26
|
-
end
|
27
|
-
|
28
|
-
if(failed_jobs.compact.empty?)
|
29
|
-
BuildLights::Lights.new.success
|
30
|
-
else
|
31
|
-
BuildLights::Lights.new.failed
|
32
|
-
end
|
8
|
+
BuildLights.cli ARGV
|
data/build-lights.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{build-lights}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Darrin Holst"]
|
9
|
-
s.date = %q{2009-08-
|
9
|
+
s.date = %q{2009-08-13}
|
10
10
|
s.default_executable = %q{buildlights}
|
11
11
|
s.email = %q{darrinholst@gmail.com}
|
12
12
|
s.executables = ["buildlights"]
|
@@ -23,17 +23,12 @@ Gem::Specification.new do |s|
|
|
23
23
|
"VERSION",
|
24
24
|
"bin/buildlights",
|
25
25
|
"build-lights.gemspec",
|
26
|
-
"lib/
|
27
|
-
"lib/
|
28
|
-
"lib/
|
29
|
-
"lib/config.rb",
|
30
|
-
"lib/feed_parser.rb",
|
31
|
-
"lib/hudson_feed_scanner.rb",
|
26
|
+
"lib/buildlights.rb",
|
27
|
+
"lib/ccnet.rb",
|
28
|
+
"lib/hudson.rb",
|
32
29
|
"lib/lights.rb",
|
33
|
-
"
|
34
|
-
"test/
|
35
|
-
"test/config_test.rb",
|
36
|
-
"test/hudson_feed_scanner_test.rb",
|
30
|
+
"test/ccnet_test.rb",
|
31
|
+
"test/hudson_test.rb",
|
37
32
|
"test/lights_test.rb",
|
38
33
|
"test/test_helper.rb"
|
39
34
|
]
|
@@ -44,9 +39,8 @@ Gem::Specification.new do |s|
|
|
44
39
|
s.rubygems_version = %q{1.3.5}
|
45
40
|
s.summary = %q{build monitor that will trigger lights via x10}
|
46
41
|
s.test_files = [
|
47
|
-
"test/
|
48
|
-
"test/
|
49
|
-
"test/hudson_feed_scanner_test.rb",
|
42
|
+
"test/ccnet_test.rb",
|
43
|
+
"test/hudson_test.rb",
|
50
44
|
"test/lights_test.rb",
|
51
45
|
"test/test_helper.rb"
|
52
46
|
]
|
data/lib/buildlights.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'ccnet'
|
3
|
+
require 'hudson'
|
4
|
+
require 'lights'
|
5
|
+
|
6
|
+
module BuildLights
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def cli(args)
|
10
|
+
urls = []
|
11
|
+
|
12
|
+
OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: buildlights [options]"
|
14
|
+
|
15
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
16
|
+
$verbose = true
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("--hudson [URL]", "Hudson url") do |url|
|
20
|
+
urls << [Hudson, url]
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("--ccnet [URL]", "CruiseControl.net url") do |url|
|
24
|
+
urls << [CcNet, url]
|
25
|
+
end
|
26
|
+
end.parse!
|
27
|
+
|
28
|
+
raise "must supply at least one url to check" if urls.empty?
|
29
|
+
|
30
|
+
failed_jobs = []
|
31
|
+
|
32
|
+
urls.each do |url|
|
33
|
+
failed_jobs << url.first.new(url.last).failed_jobs
|
34
|
+
end
|
35
|
+
|
36
|
+
Lights.new.send(failed_jobs.flatten.empty? ? :success : :failed)
|
37
|
+
end
|
38
|
+
end
|
data/lib/ccnet.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'hpricot'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module BuildLights
|
5
|
+
class CcNet
|
6
|
+
def initialize(uri, parser = XmlParser)
|
7
|
+
puts "CruiseControl.net url: #{uri}" if $verbose
|
8
|
+
@doc = parser.parse(uri)
|
9
|
+
end
|
10
|
+
|
11
|
+
def failed_jobs
|
12
|
+
@doc.search(:Project).map do |project|
|
13
|
+
name = project[:name]
|
14
|
+
status = project[:lastBuildStatus]
|
15
|
+
puts "#{name} -> #{status}" if $verbose
|
16
|
+
failed = /FAIL/i.match(status)
|
17
|
+
name if failed
|
18
|
+
end.compact
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class XmlParser
|
23
|
+
def self.parse(uri)
|
24
|
+
Hpricot::XML(open(uri))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/lib/hudson.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'simple-rss'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module BuildLights
|
5
|
+
class Hudson
|
6
|
+
def initialize(uri, parser = FeedParser)
|
7
|
+
puts "Hudson url: #{uri}" if $verbose
|
8
|
+
@feed = parser.parse uri
|
9
|
+
end
|
10
|
+
|
11
|
+
def failed_jobs
|
12
|
+
@feed.entries.each.map do |entry|
|
13
|
+
match = /(.*) #\d+ (.*)/.match(entry.title)
|
14
|
+
raise "Invalid rss title #{entry.title}" unless match
|
15
|
+
name = match[1]
|
16
|
+
status = match[2]
|
17
|
+
puts "#{name} -> #{status}" if $verbose
|
18
|
+
failed = /FAIL/i.match(status)
|
19
|
+
name if failed
|
20
|
+
end.compact
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class FeedParser
|
25
|
+
def self.parse(uri)
|
26
|
+
SimpleRSS.parse(open(uri))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/lights.rb
CHANGED
@@ -1,20 +1,39 @@
|
|
1
|
-
|
1
|
+
module BuildLights
|
2
|
+
class Lights
|
3
|
+
GREEN = 1
|
4
|
+
RED = 2
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(implementation = BuildLights::BottleRocket)
|
8
|
-
@implementation = implementation
|
9
|
-
end
|
6
|
+
def initialize(implementation = BottleRocket)
|
7
|
+
@implementation = implementation
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def success
|
11
|
+
@implementation.turn_on GREEN
|
12
|
+
@implementation.turn_off RED
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def failed
|
16
|
+
@implementation.turn_on RED
|
17
|
+
@implementation.turn_off GREEN
|
18
|
+
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
class BottleRocket
|
22
|
+
def self.turn_on(unit, house='A')
|
23
|
+
send('on', unit, house)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.turn_off(unit, house='A')
|
27
|
+
send('off', unit, house)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def self.send(command, unit, house)
|
33
|
+
cmd = "br -v --house=#{house} --#{command}=#{unit}"
|
34
|
+
puts "sending X10 command -> #{cmd}" if $verbose
|
35
|
+
system cmd
|
36
|
+
raise "bottlerocket command failed with status code #{$?.exitstatus}" if $?.exitstatus > 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,30 +1,29 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'ccnet_xml_scanner'
|
3
2
|
|
4
|
-
class
|
3
|
+
class CcNetTest < Test::Unit::TestCase
|
5
4
|
URI = "some uri"
|
6
5
|
|
7
6
|
def test_failed_jobs
|
8
7
|
parser = parser_for(URI, ["job 1", "Failed"], ["job 2", "Failed"])
|
9
|
-
scanner =
|
8
|
+
scanner = BuildLights::CcNet.new(URI, parser)
|
10
9
|
assert_equal(["job 1", "job 2"], scanner.failed_jobs)
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_successful_jobs
|
14
13
|
parser = parser_for(URI, ["job 1", "Success"], ["job 2", "Success"])
|
15
|
-
scanner =
|
14
|
+
scanner = BuildLights::CcNet.new(URI, parser)
|
16
15
|
assert_equal([], scanner.failed_jobs)
|
17
16
|
end
|
18
17
|
|
19
18
|
def test_mixed_jobs
|
20
19
|
parser = parser_for(URI, ["job 1", "Success"], ["job 2", "Failed"])
|
21
|
-
scanner =
|
20
|
+
scanner = BuildLights::CcNet.new(URI, parser)
|
22
21
|
assert_equal(["job 2"], scanner.failed_jobs)
|
23
22
|
end
|
24
23
|
|
25
24
|
def test_mixed_case
|
26
25
|
parser = parser_for(URI, ["job 1", "FAILED"], ["job 2", "SUCCESS"], ["job 3", "FAIL"])
|
27
|
-
scanner =
|
26
|
+
scanner = BuildLights::CcNet.new(URI, parser)
|
28
27
|
assert_equal(["job 1", "job 3"], scanner.failed_jobs)
|
29
28
|
end
|
30
29
|
|
@@ -1,30 +1,29 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'hudson_feed_scanner'
|
3
2
|
|
4
|
-
class
|
3
|
+
class HudsonTest < Test::Unit::TestCase
|
5
4
|
URI = "some uri"
|
6
5
|
|
7
6
|
def test_all_successful
|
8
7
|
parser = feed_parser_for(URI, "job 1 #1 (SUCCESS)", "job 2 #1 (SUCCESS)")
|
9
|
-
scanner =
|
8
|
+
scanner = BuildLights::Hudson.new(URI, parser)
|
10
9
|
assert_equal([], scanner.failed_jobs)
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_all_failed
|
14
13
|
parser = feed_parser_for(URI, "job 1 #1 (FAILED)", "job 2 #1 (FAILED)")
|
15
|
-
scanner =
|
14
|
+
scanner = BuildLights::Hudson.new(URI, parser)
|
16
15
|
assert_equal(['job 1', 'job 2'], scanner.failed_jobs)
|
17
16
|
end
|
18
17
|
|
19
18
|
def test_mixed
|
20
19
|
parser = feed_parser_for(URI, "job 1 #1 (SUCCESS)", "job 2 #1 (FAILED)", "job 3 #1 (SUCCESS)")
|
21
|
-
scanner =
|
20
|
+
scanner = BuildLights::Hudson.new(URI, parser)
|
22
21
|
assert_equal(['job 2'], scanner.failed_jobs)
|
23
22
|
end
|
24
23
|
|
25
24
|
def test_mixed_with_lower_case
|
26
25
|
parser = feed_parser_for(URI, "job 1 #1 (success)", "job 2 #1 (failed)", "job 3 #1 (success)")
|
27
|
-
scanner =
|
26
|
+
scanner = BuildLights::Hudson.new(URI, parser)
|
28
27
|
assert_equal(['job 2'], scanner.failed_jobs)
|
29
28
|
end
|
30
29
|
|
data/test/lights_test.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'lights'
|
3
2
|
|
4
3
|
class LightsTest < Test::Unit::TestCase
|
5
4
|
def test_successful_builds
|
@@ -7,7 +6,7 @@ class LightsTest < Test::Unit::TestCase
|
|
7
6
|
impl.expects(:turn_on).with(1)
|
8
7
|
impl.expects(:turn_off).with(2)
|
9
8
|
|
10
|
-
Lights.new(impl).success
|
9
|
+
BuildLights::Lights.new(impl).success
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_failed_builds
|
@@ -15,6 +14,6 @@ class LightsTest < Test::Unit::TestCase
|
|
15
14
|
impl.expects(:turn_on).with(2)
|
16
15
|
impl.expects(:turn_off).with(1)
|
17
16
|
|
18
|
-
Lights.new(impl).failed
|
17
|
+
BuildLights::Lights.new(impl).failed
|
19
18
|
end
|
20
19
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
1
4
|
require 'rubygems'
|
2
5
|
require 'test/unit'
|
3
6
|
require 'mocha'
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
require 'buildlights'
|
7
8
|
|
8
9
|
class Test::Unit::TestCase
|
9
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darrinholst-build-lights
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darrin Holst
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-13 00:00:00 -07:00
|
13
13
|
default_executable: buildlights
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,17 +50,12 @@ files:
|
|
50
50
|
- VERSION
|
51
51
|
- bin/buildlights
|
52
52
|
- build-lights.gemspec
|
53
|
-
- lib/
|
54
|
-
- lib/
|
55
|
-
- lib/
|
56
|
-
- lib/config.rb
|
57
|
-
- lib/feed_parser.rb
|
58
|
-
- lib/hudson_feed_scanner.rb
|
53
|
+
- lib/buildlights.rb
|
54
|
+
- lib/ccnet.rb
|
55
|
+
- lib/hudson.rb
|
59
56
|
- lib/lights.rb
|
60
|
-
-
|
61
|
-
- test/
|
62
|
-
- test/config_test.rb
|
63
|
-
- test/hudson_feed_scanner_test.rb
|
57
|
+
- test/ccnet_test.rb
|
58
|
+
- test/hudson_test.rb
|
64
59
|
- test/lights_test.rb
|
65
60
|
- test/test_helper.rb
|
66
61
|
has_rdoc: false
|
@@ -91,8 +86,7 @@ signing_key:
|
|
91
86
|
specification_version: 3
|
92
87
|
summary: build monitor that will trigger lights via x10
|
93
88
|
test_files:
|
94
|
-
- test/
|
95
|
-
- test/
|
96
|
-
- test/hudson_feed_scanner_test.rb
|
89
|
+
- test/ccnet_test.rb
|
90
|
+
- test/hudson_test.rb
|
97
91
|
- test/lights_test.rb
|
98
92
|
- test/test_helper.rb
|
data/lib/bottle_rocket.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
class BuildLights::BottleRocket
|
2
|
-
def self.turn_on(unit, house='A')
|
3
|
-
send('on', unit, house)
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.turn_off(unit, house='A')
|
7
|
-
send('off', unit, house)
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def self.send(command, unit, house)
|
13
|
-
puts `br -v --house=#{house} --#{command}=#{unit}`
|
14
|
-
end
|
15
|
-
end
|
data/lib/build_lights.rb
DELETED
data/lib/ccnet_xml_scanner.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'xml_parser'
|
2
|
-
|
3
|
-
class BuildLights::CcNetXmlScanner
|
4
|
-
def initialize(uri, parser = BuildLights::XmlParser)
|
5
|
-
@doc = parser.parse(uri)
|
6
|
-
end
|
7
|
-
|
8
|
-
def failed_jobs
|
9
|
-
@doc.search(:Project).map do |project|
|
10
|
-
project[:name] if project[:lastBuildStatus] =~ /FAIL/i
|
11
|
-
end.compact
|
12
|
-
end
|
13
|
-
end
|
data/lib/config.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'build-lights'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
class BuildLights::Config
|
5
|
-
HOME_LOCATION = "#{ENV['HOME']}"
|
6
|
-
SYSTEM_LOCATION = "/etc"
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
[HOME_LOCATION, SYSTEM_LOCATION].each do |path|
|
10
|
-
config_file = File.join(path, ".buildlights")
|
11
|
-
puts config_file
|
12
|
-
if File.exists?(config_file) && File.file?(config_file)
|
13
|
-
config = YAML.load_file(config_file)
|
14
|
-
|
15
|
-
if(config)
|
16
|
-
config.each_pair do |key, value|
|
17
|
-
self.class.send(:attr_reader, key.to_sym)
|
18
|
-
instance_variable_set("@#{key}".to_sym, value)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
return
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
raise "No configuration file found"
|
27
|
-
end
|
28
|
-
|
29
|
-
def method_missing(*args)
|
30
|
-
end
|
31
|
-
end
|
data/lib/feed_parser.rb
DELETED
data/lib/hudson_feed_scanner.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'feed_parser'
|
2
|
-
|
3
|
-
class BuildLights::HudsonFeedScanner
|
4
|
-
def initialize(uri, parser = BuildLights::FeedParser)
|
5
|
-
@feed = parser.parse uri
|
6
|
-
end
|
7
|
-
|
8
|
-
def failed_jobs
|
9
|
-
@feed.entries.each.map do |entry|
|
10
|
-
match = /(.*) #\d+ (.*)/.match(entry.title)
|
11
|
-
raise "Invalid rss title #{entry.title}" unless match
|
12
|
-
match[1] if /FAIL/i.match(match[2])
|
13
|
-
end.compact
|
14
|
-
end
|
15
|
-
end
|
data/lib/xml_parser.rb
DELETED
data/test/config_test.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'config'
|
3
|
-
require 'tempfile'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
class BuildLights::Config
|
7
|
-
HOME_LOCATION = File.join(Dir.tmpdir, "buildlights_unittests", "home")
|
8
|
-
SYSTEM_LOCATION = File.join(Dir.tmpdir, "buildlights_unittests", "system")
|
9
|
-
end
|
10
|
-
|
11
|
-
class ConfigTest < Test::Unit::TestCase
|
12
|
-
def setup
|
13
|
-
FileUtils.rm_rf BuildLights::Config::HOME_LOCATION
|
14
|
-
FileUtils.rm_rf BuildLights::Config::SYSTEM_LOCATION
|
15
|
-
FileUtils.mkdir_p BuildLights::Config::HOME_LOCATION
|
16
|
-
FileUtils.mkdir_p BuildLights::Config::SYSTEM_LOCATION
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_no_config_found
|
20
|
-
assert_raise RuntimeError do
|
21
|
-
BuildLights::Config.new
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_config_found_in_home_dir
|
26
|
-
add_file_to_home
|
27
|
-
assert_home_file_used
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_config_found_in_home_dir_is_used_first
|
31
|
-
add_file_to_home
|
32
|
-
add_file_to_system
|
33
|
-
assert_home_file_used
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_config_found_in_system_dir
|
37
|
-
add_file_to_system
|
38
|
-
assert_system_file_used
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def add_file_to_home
|
44
|
-
File.open(File.join(BuildLights::Config::HOME_LOCATION, ".buildlights"), "w") do |f|
|
45
|
-
f.puts "ccnet_url: ccnet_url_from_home"
|
46
|
-
f.puts "hudson_url: hudson_url_from_home"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def add_file_to_system
|
51
|
-
File.open(File.join(BuildLights::Config::SYSTEM_LOCATION, ".buildlights"), "w") do |f|
|
52
|
-
f.puts "ccnet_url: ccnet_url_from_system"
|
53
|
-
f.puts "hudson_url: hudson_url_from_system"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def assert_home_file_used
|
58
|
-
assert_attributes(BuildLights::Config.new, "home")
|
59
|
-
end
|
60
|
-
|
61
|
-
def assert_system_file_used
|
62
|
-
assert_attributes(BuildLights::Config.new, "system")
|
63
|
-
end
|
64
|
-
|
65
|
-
def assert_attributes(config, home_or_system)
|
66
|
-
assert_equal("hudson_url_from_#{home_or_system}", config.hudson_url)
|
67
|
-
assert_equal("ccnet_url_from_#{home_or_system}", config.ccnet_url)
|
68
|
-
assert_equal(nil, config.foo_url)
|
69
|
-
end
|
70
|
-
end
|