BuildMaster 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/buildmaster.rb +4 -2
- data/lib/buildmaster/{ant_client.rb → ant_driver.rb} +9 -1
- data/lib/buildmaster/{cvs_client.rb → cvs_driver.rb} +3 -3
- data/lib/buildmaster/file_processor.rb +2 -16
- data/lib/buildmaster/java_manifest.rb +72 -0
- data/lib/buildmaster/run_ant.rb +2 -2
- data/lib/buildmaster/shell_command.rb +1 -0
- data/lib/buildmaster/site.rb +2 -46
- data/lib/buildmaster/site_spec.rb +84 -0
- data/lib/buildmaster/template_runner.rb +27 -9
- data/test/buildmaster/manifest.mf +5 -0
- data/test/buildmaster/{tc_ant_client.rb → tc_ant_driver.rb} +5 -1
- data/test/buildmaster/{tc_cvs_client.rb → tc_cvs_driver.rb} +4 -4
- data/test/buildmaster/tc_file_processor.rb +34 -0
- data/test/buildmaster/tc_java_manifest.rb +23 -0
- data/test/buildmaster/tc_release_control.rb +1 -1
- data/test/buildmaster/tc_site_spec.rb +66 -0
- data/test/buildmaster/tc_template_runner.rb +0 -8
- data/test/buildmaster/tc_xtemplate.rb +45 -2
- data/test/ts_buildmaster.rb +4 -2
- metadata +13 -17
data/lib/buildmaster.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__))
|
2
2
|
|
3
|
+
require 'buildmaster/java_manifest'
|
3
4
|
require 'buildmaster/shell_command'
|
4
5
|
require 'buildmaster/release_control'
|
5
|
-
require 'buildmaster/
|
6
|
-
require 'buildmaster/
|
6
|
+
require 'buildmaster/ant_driver'
|
7
|
+
require 'buildmaster/cvs_driver'
|
7
8
|
require 'buildmaster/svn_driver'
|
9
|
+
require 'buildmaster/site_spec'
|
8
10
|
require 'buildmaster/site'
|
9
11
|
require 'buildmaster/xtemplate'
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module BuildMaster
|
2
2
|
|
3
|
-
class
|
3
|
+
class AntDriver
|
4
4
|
include Shell
|
5
|
+
def AntDriver.from_file(ant_file)
|
6
|
+
return AntDriver.new(ant_file)
|
7
|
+
end
|
8
|
+
|
5
9
|
def initialize(ant_file = nil, &command_runner)
|
6
10
|
@ant_file = ant_file
|
7
11
|
@ant_home = check_directory(get_environment('ANT_HOME'))
|
@@ -58,6 +62,10 @@ class Ant
|
|
58
62
|
run_command(command_line)
|
59
63
|
end
|
60
64
|
|
65
|
+
def method_missing(method, *args)
|
66
|
+
target(method)
|
67
|
+
end
|
68
|
+
|
61
69
|
private :get_java_command
|
62
70
|
|
63
71
|
end
|
@@ -22,10 +22,10 @@ class CvsInfo
|
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
|
-
class
|
25
|
+
class CvsDriver
|
26
26
|
include Shell
|
27
|
-
def
|
28
|
-
return
|
27
|
+
def CvsDriver.from_path(working_directory)
|
28
|
+
return CvsDriver.new(CvsInfo.load("#{working_directory}/CVS"), working_directory)
|
29
29
|
end
|
30
30
|
|
31
31
|
def initialize(cvs_info, working_directory, &command_runner)
|
@@ -38,24 +38,10 @@ HTML
|
|
38
38
|
return process_html_content(File.open(@content_path))
|
39
39
|
end
|
40
40
|
|
41
|
-
private
|
42
41
|
def process_html_content(source)
|
43
|
-
document_with_skin = @template.process(source)
|
44
|
-
|
45
|
-
method = @evaluator.method(message)
|
46
|
-
if (method.arity == 0)
|
47
|
-
method.call
|
48
|
-
else
|
49
|
-
method.call(@content_path)
|
50
|
-
end
|
51
|
-
rescue NameError
|
52
|
-
raise TemplateException,
|
53
|
-
"unable to process message: #{message}: #{$!}" ,
|
54
|
-
caller
|
55
|
-
end
|
42
|
+
document_with_skin = @template.process(source) {|message| @evaluator.evaluate(message, @content_path)}
|
43
|
+
return document_with_skin
|
56
44
|
end
|
57
|
-
return document_with_skin
|
58
|
-
end
|
59
45
|
|
60
46
|
end
|
61
47
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module BuildMaster
|
2
|
+
class JavaManifest
|
3
|
+
def initialize(manifest_file)
|
4
|
+
@manifest_file = manifest_file
|
5
|
+
end
|
6
|
+
|
7
|
+
def version
|
8
|
+
number = nil
|
9
|
+
build = nil
|
10
|
+
IO.foreach(@manifest_file) do |line|
|
11
|
+
name_value = NameValue.parse(line)
|
12
|
+
if (name_value.name== "Implementation-Version")
|
13
|
+
number = name_value.value
|
14
|
+
elsif (name_value.name == "Implementation-Build")
|
15
|
+
build = name_value.value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
return Version.new(number, build.to_i)
|
19
|
+
end
|
20
|
+
|
21
|
+
def increase_build
|
22
|
+
content = ""
|
23
|
+
number = nil
|
24
|
+
build = nil
|
25
|
+
IO.foreach(@manifest_file) do |line|
|
26
|
+
name_value = NameValue.parse(line)
|
27
|
+
if (name_value.name== "Implementation-Version")
|
28
|
+
number = name_value.value
|
29
|
+
content = content + line
|
30
|
+
elsif (name_value.name == "Implementation-Build")
|
31
|
+
build = name_value.value.to_i + 1
|
32
|
+
content = content + "Implementation-Build: #{build}\n"
|
33
|
+
else
|
34
|
+
content = content + line
|
35
|
+
end
|
36
|
+
end
|
37
|
+
File.open(@manifest_file, "w") do |file|
|
38
|
+
file.printf(content)
|
39
|
+
end
|
40
|
+
return Version.new(number, build)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class NameValue
|
45
|
+
attr_reader :name, :value
|
46
|
+
|
47
|
+
def NameValue.parse(line)
|
48
|
+
name_value = NameValue.new(nil, nil)
|
49
|
+
index = line.index(':')
|
50
|
+
if (index)
|
51
|
+
name=line[0, index]
|
52
|
+
value=line[index+1, line.length].strip
|
53
|
+
name_value = NameValue.new(name, value)
|
54
|
+
end
|
55
|
+
return name_value
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize(name, value)
|
59
|
+
@name = name
|
60
|
+
@value = value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class Version
|
65
|
+
attr_reader :number, :build
|
66
|
+
|
67
|
+
def initialize(number, build)
|
68
|
+
@number = number
|
69
|
+
@build = build
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/buildmaster/run_ant.rb
CHANGED
data/lib/buildmaster/site.rb
CHANGED
@@ -4,6 +4,7 @@ require 'fileutils'
|
|
4
4
|
require 'redcloth'
|
5
5
|
require 'source_file_handler'
|
6
6
|
require 'file_processor'
|
7
|
+
require 'site_spec'
|
7
8
|
|
8
9
|
module BuildMaster
|
9
10
|
#todo match only beginning of the file
|
@@ -15,51 +16,6 @@ TEXTILE_REGX = /---(-)*\n(.*)\n(-)*---/
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
class SiteSpec
|
19
|
-
def self.get_instance
|
20
|
-
self.new()
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_accessor :output_dir, :content_dir, :template, :template_file
|
24
|
-
|
25
|
-
def validate_inputs
|
26
|
-
validate_dir(@content_dir, :content_dir)
|
27
|
-
end
|
28
|
-
|
29
|
-
def load_template
|
30
|
-
if (@template)
|
31
|
-
return XTemplate.new(@template)
|
32
|
-
else
|
33
|
-
return XTemplate.new(File.open(@template_file))
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
def validate_dir(directory, symbol)
|
39
|
-
if not directory
|
40
|
-
raise "Directory for #{symbol.id2name} not specified"
|
41
|
-
end
|
42
|
-
if not File.exists? directory
|
43
|
-
raise "Directory for #{symbol.id2name} -- <#{directory}#> does not exist"
|
44
|
-
end
|
45
|
-
if not File.directory? directory
|
46
|
-
raise "<#{directory}> should be a directory for #{symbol.id2name}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def validate_file(file, symbol)
|
51
|
-
if not file
|
52
|
-
raise "File for #{symbol.id2name} not specified"
|
53
|
-
end
|
54
|
-
if (not File.exists? file)
|
55
|
-
raise "File for #{symbol.id2name} -- <#{file}> does not exist"
|
56
|
-
end
|
57
|
-
if not File.file? file
|
58
|
-
raise "#<{file} should be a file for #{symbol.id2name}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
19
|
class Site
|
64
20
|
def initialize(spec)
|
65
21
|
@spec = spec
|
@@ -73,7 +29,7 @@ TEXTILE_REGX = /---(-)*\n(.*)\n(-)*---/
|
|
73
29
|
if arguments.size > 0
|
74
30
|
action = arguments[0]
|
75
31
|
end
|
76
|
-
|
32
|
+
send action
|
77
33
|
end
|
78
34
|
|
79
35
|
def build
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module BuildMaster
|
4
|
+
class SiteSpec
|
5
|
+
def self.get_instance
|
6
|
+
self.new()
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor :output_dir, :content_dir, :template, :template_file
|
10
|
+
|
11
|
+
def properties
|
12
|
+
@properties = Hash.new unless @properties
|
13
|
+
return @properties
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate_inputs
|
17
|
+
validate_dir(@content_dir, :content_dir)
|
18
|
+
end
|
19
|
+
|
20
|
+
def load_template
|
21
|
+
if (@template)
|
22
|
+
return XTemplate.new(@template)
|
23
|
+
else
|
24
|
+
return XTemplate.new(File.open(@template_file))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def relative_to_root(path)
|
29
|
+
to = path_name(path)
|
30
|
+
from = path_name(@content_dir)
|
31
|
+
return to.relative_path_from(from)
|
32
|
+
end
|
33
|
+
|
34
|
+
def evaluate(expression, path)
|
35
|
+
value_from_properties = properties()[expression]
|
36
|
+
if (value_from_properties)
|
37
|
+
return value_from_properties
|
38
|
+
end
|
39
|
+
if (!respond_to?(expression, true))
|
40
|
+
raise "Neither property nor method found with name '#{expression}'"
|
41
|
+
end
|
42
|
+
relative_path = relative_to_root(path)
|
43
|
+
if (expression == 'relative_to_root')
|
44
|
+
return relative_path
|
45
|
+
else
|
46
|
+
send(expression, relative_to_root(path).to_s)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_property(name, value)
|
51
|
+
properties()[name] = value
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def path_name(path)
|
56
|
+
return Pathname.new(path.gsub(/\\/, '/'))
|
57
|
+
end
|
58
|
+
|
59
|
+
def validate_dir(directory, symbol)
|
60
|
+
if not directory
|
61
|
+
raise "Directory for #{symbol.id2name} not specified"
|
62
|
+
end
|
63
|
+
if not File.exists? directory
|
64
|
+
raise "Directory for #{symbol.id2name} -- <#{directory}> does not exist"
|
65
|
+
end
|
66
|
+
if not File.directory? directory
|
67
|
+
raise "<#{directory}> should be a directory for #{symbol.id2name}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def validate_file(file, symbol)
|
72
|
+
if not file
|
73
|
+
raise "File for #{symbol.id2name} not specified"
|
74
|
+
end
|
75
|
+
if (not File.exists? file)
|
76
|
+
raise "File for #{symbol.id2name} -- <#{file}> does not exist"
|
77
|
+
end
|
78
|
+
if not File.file? file
|
79
|
+
raise "#<{file} should be a file for #{symbol.id2name}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module BuildMaster
|
2
2
|
class TemplateRunner
|
3
|
-
|
3
|
+
BuildMaster::NAMESPACE = "http://buildmaster.rubyforge.org/xtemplate/1.0"
|
4
4
|
|
5
5
|
def initialize(result, template, source, &evaluator)
|
6
6
|
@result = result
|
@@ -39,14 +39,9 @@ module BuildMaster
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def process_directive(target, template_element)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
rescue NameError
|
46
|
-
raise TemplateException,
|
47
|
-
"unable to process template:#{template_element.name}: #{$!}" ,
|
48
|
-
caller
|
49
|
-
end
|
42
|
+
message = "process_#{template_element.name}_directive"
|
43
|
+
raise TemplateException, "unable to process element template:#{template_element.name}" unless respond_to?(message, true)
|
44
|
+
send(message, target, template_element)
|
50
45
|
end
|
51
46
|
|
52
47
|
def clone_element( template_element )
|
@@ -103,6 +98,29 @@ module BuildMaster
|
|
103
98
|
end
|
104
99
|
end
|
105
100
|
|
101
|
+
def process_link_directive(target_element, template_element)
|
102
|
+
current_path = @evaluator.call('relative_to_root')
|
103
|
+
file_name = current_path.basename(current_path.extname).to_s + ".html"
|
104
|
+
current_html_path = current_path.parent().join(file_name)
|
105
|
+
href = Pathname.new(attribute!(template_element, 'href'))
|
106
|
+
if (href.absolute?)
|
107
|
+
href = href.relative_path_from(Pathname.new('/'))
|
108
|
+
end
|
109
|
+
anchor_or_div = nil
|
110
|
+
if (current_html_path == href)
|
111
|
+
anchor_or_div = REXML::Element.new('div')
|
112
|
+
anchor_or_div.attributes['class']='current'
|
113
|
+
else
|
114
|
+
anchor_or_div = REXML::Element.new('a')
|
115
|
+
anchor_or_div.attributes['href'] = href.relative_path_from(current_html_path.parent())
|
116
|
+
end
|
117
|
+
template_element.attributes.each do |name, value|
|
118
|
+
anchor_or_div.attributes[name] = value unless name == 'href'
|
119
|
+
end
|
120
|
+
process_children(anchor_or_div, template_element)
|
121
|
+
target_element.add(anchor_or_div)
|
122
|
+
end
|
123
|
+
|
106
124
|
def evaluate!(xml_element, attribute_name)
|
107
125
|
value = evaluate(xml_element, attribute_name)
|
108
126
|
message = xml_element.attributes[attribute_name]
|
@@ -10,7 +10,7 @@ class AntTest < Test::Unit::TestCase
|
|
10
10
|
def setup
|
11
11
|
super
|
12
12
|
build_file = File.join(File.dirname(__FILE__), "build.xml")
|
13
|
-
@ant =
|
13
|
+
@ant = AntDriver.from_file(build_file)
|
14
14
|
end
|
15
15
|
|
16
16
|
public
|
@@ -23,6 +23,10 @@ class AntTest < Test::Unit::TestCase
|
|
23
23
|
@ant.target('passing')
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_dynamic_method
|
27
|
+
@ant.passing
|
28
|
+
end
|
29
|
+
|
26
30
|
def test_fail
|
27
31
|
assert_raise(RuntimeError) {@ant.target('failing')}
|
28
32
|
end
|
@@ -5,7 +5,7 @@ require 'buildmaster'
|
|
5
5
|
|
6
6
|
module BuildMaster
|
7
7
|
|
8
|
-
class
|
8
|
+
class CvsDriverTest < Test::Unit::TestCase
|
9
9
|
protected
|
10
10
|
def setUp()
|
11
11
|
super
|
@@ -33,14 +33,14 @@ class CvsClientTest < Test::Unit::TestCase
|
|
33
33
|
|
34
34
|
def tes_checkout
|
35
35
|
log = ''
|
36
|
-
client =
|
36
|
+
client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
|
37
37
|
client.checkout
|
38
38
|
assert_equal('cvs -d root co -d working module', log)
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_update
|
42
42
|
log = ''
|
43
|
-
client =
|
43
|
+
client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
|
44
44
|
client.update
|
45
45
|
assert_equal('cvs -d root update working', log)
|
46
46
|
client.update('-PAd')
|
@@ -49,7 +49,7 @@ class CvsClientTest < Test::Unit::TestCase
|
|
49
49
|
|
50
50
|
def test_command
|
51
51
|
log = ''
|
52
|
-
client =
|
52
|
+
client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
|
53
53
|
client.command('command -option argument')
|
54
54
|
assert_equal('cvs -d root command -option argument working', log)
|
55
55
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rexml/document'
|
5
|
+
require 'buildmaster/file_processor'
|
6
|
+
require 'buildmaster/xtemplate'
|
7
|
+
|
8
|
+
module BuildMaster
|
9
|
+
class FileProcessorTest < Test::Unit::TestCase
|
10
|
+
def test_expression_evaluation
|
11
|
+
template = XTemplate.new(<<CONTENT
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
13
|
+
xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
|
14
|
+
<p>
|
15
|
+
<template:attribute name="class" eval="method_one"/>
|
16
|
+
</p>
|
17
|
+
</html>
|
18
|
+
CONTENT
|
19
|
+
)
|
20
|
+
processor = FileProcessor.new(template, "content_path", self)
|
21
|
+
document = processor.process_html_content("<html></html>")
|
22
|
+
assert_equal('method one result',
|
23
|
+
REXML::XPath.first(REXML::Document.new(document.to_s), '/html/p/@class').value.strip)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def evaluate(expression, path)
|
28
|
+
assert_equal('method_one', expression)
|
29
|
+
assert_equal('content_path', path)
|
30
|
+
return "method one result"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'buildmaster'
|
5
|
+
|
6
|
+
module BuildMaster
|
7
|
+
|
8
|
+
class JavaManifestTest < Test::Unit::TestCase
|
9
|
+
def test_loading_manifest
|
10
|
+
manifest = JavaManifest.new(File.join(File.dirname(__FILE__), "manifest.mf"))
|
11
|
+
version = manifest.version
|
12
|
+
assert_equal(version.number, "2.3.3")
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_increase_build
|
16
|
+
manifest = JavaManifest.new(File.join(File.dirname(__FILE__), "manifest.mf"))
|
17
|
+
build_number = manifest.version.build
|
18
|
+
version = manifest.increase_build
|
19
|
+
assert_equal(version.build, build_number + 1)
|
20
|
+
assert_equal(version.build, manifest.version.build)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'buildmaster'
|
5
|
+
|
6
|
+
module BuildMaster
|
7
|
+
|
8
|
+
class SiteSpecTest < Test::Unit::TestCase
|
9
|
+
def test_should_get_relative_path
|
10
|
+
spec = SiteSpec.new
|
11
|
+
spec.content_dir = '/one/two/content'
|
12
|
+
assert_equal('images/logo.gif', spec.relative_to_root('/one/two/content/images/logo.gif').to_s)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_should_support_windows_path
|
16
|
+
spec = SiteSpec.new
|
17
|
+
spec.content_dir = "C:\\Work\\project\\content"
|
18
|
+
assert_equal('images/logo.gif', spec.relative_to_root('C:\\Work\\project\\content\\images\\logo.gif').to_s)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_evaluate
|
22
|
+
spec = SampleSiteSpec.new
|
23
|
+
spec.content_dir = '/one/two/content'
|
24
|
+
result = spec.evaluate('expression', '/one/two/content/dir/file.txt')
|
25
|
+
assert_equal('dir/file.txt', result)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_should_check_for_property
|
29
|
+
spec = SiteSpec.new
|
30
|
+
spec.content_dir = "/one"
|
31
|
+
spec.add_property('release', '0.6')
|
32
|
+
assert_equal('0.6', spec.evaluate('release', '/one'))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_should_throw_error_with_proper_message_for_expression_problem
|
36
|
+
spec = SiteSpec.new
|
37
|
+
spec.content_dir = "/one"
|
38
|
+
begin
|
39
|
+
spec.evaluate('expression', '/one/two')
|
40
|
+
fail('exception should have been thrown')
|
41
|
+
rescue RuntimeError => boom
|
42
|
+
assert_equal("Neither property nor method found with name 'expression'", boom.message)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_relative_to_root_expression
|
47
|
+
spec = SiteSpec.new
|
48
|
+
spec.content_dir = '/one'
|
49
|
+
actual = spec.evaluate('relative_to_root', '/one/two')
|
50
|
+
assert_equal(Pathname.new('two'), actual)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
class SampleSiteSpec < SiteSpec
|
56
|
+
private
|
57
|
+
def expression(path)
|
58
|
+
return path
|
59
|
+
end
|
60
|
+
|
61
|
+
def expression2
|
62
|
+
return 'expected'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -32,14 +32,6 @@ END
|
|
32
32
|
template_element = REXML::XPath.first(REXML::Document.new(template_content), "/html/p")
|
33
33
|
source_xml = REXML::Document.new(source_content)
|
34
34
|
source_element = REXML::XPath.first(source_xml, '/persons/person[@id="1"]')
|
35
|
-
# puts "========= TARGET ========="
|
36
|
-
# puts target_element
|
37
|
-
# puts "========== TEMPLATE =========="
|
38
|
-
# puts template_element
|
39
|
-
# puts "========== SOURCE ==========="
|
40
|
-
# puts source_element
|
41
|
-
# puts '=========== Source Match ============'
|
42
|
-
# puts REXML::XPath.first(source_element, './name')
|
43
35
|
runner = TemplateRunner.new(target_element, template_element, source_element)
|
44
36
|
runner.process
|
45
37
|
assert_equal('Name One', REXML::XPath.first(REXML::Document.new(target_xml.to_s), '/html/h1/text()').value.strip)
|
@@ -167,7 +167,7 @@ INCLUDE_SOURCE
|
|
167
167
|
xml_output = REXML::Document.new(xml_document.to_s())
|
168
168
|
assert_equal('release 0.0.1 (build 235)', REXML::XPath.first(xml_output, '/html/body/h1').text)
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
def test_should_process_each_with_children
|
172
172
|
template_content = <<INCLUDE_CONTENT
|
173
173
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
@@ -247,10 +247,53 @@ INCLUDE_SOURCE
|
|
247
247
|
NEWS
|
248
248
|
end
|
249
249
|
xml_output = REXML::Document.new(xml_document.to_s())
|
250
|
-
# puts xml_output
|
251
250
|
assert_equal(3, REXML::XPath.match(xml_output, '/html/body/div/div').size)
|
252
251
|
assert_equal('BuildMaster website created',
|
253
252
|
REXML::XPath.first(xml_output, '/html/body/div/div[1]/p').text())
|
254
253
|
end
|
254
|
+
|
255
|
+
def test_should_process_link_element_to_anchor_with_relative_path_when_not_current_page
|
256
|
+
template_content = <<CONTENT
|
257
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
258
|
+
xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
|
259
|
+
<head>
|
260
|
+
<title>BuildMaster</title>
|
261
|
+
</head>
|
262
|
+
<body><template:link href="/dir/file" class="value">File</template:link></body>
|
263
|
+
</html>
|
264
|
+
CONTENT
|
265
|
+
template = XTemplate.new(template_content)
|
266
|
+
xml_output = template.process('') do |expression|
|
267
|
+
assert_equal('relative_to_root', expression)
|
268
|
+
Pathname.new('hello.textile')
|
269
|
+
end
|
270
|
+
actual_element = REXML::XPath.first(xml_output, '/html/body/a')
|
271
|
+
assert_equal('dir/file', actual_element.attributes['href'])
|
272
|
+
assert_equal('value', actual_element.attributes['class'])
|
273
|
+
assert_equal('File', actual_element.text)
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_should_process_link_element_to_div_when_on_current_page
|
277
|
+
template_content = <<CONTENT
|
278
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
279
|
+
xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
|
280
|
+
<head>
|
281
|
+
<title>BuildMaster</title>
|
282
|
+
</head>
|
283
|
+
<body><template:link href="/dir/file.html" class="value">File</template:link></body>
|
284
|
+
</html>
|
285
|
+
CONTENT
|
286
|
+
template = XTemplate.new(template_content)
|
287
|
+
xml_output = template.process('') do |expression|
|
288
|
+
assert_equal('relative_to_root', expression)
|
289
|
+
Pathname.new('dir/file.textile')
|
290
|
+
end
|
291
|
+
actual_element = REXML::XPath.first(xml_output, '/html/body/div')
|
292
|
+
assert_equal(nil, actual_element.attributes['href'])
|
293
|
+
assert_equal('value', actual_element.attributes['class'])
|
294
|
+
assert_equal('File', actual_element.text)
|
295
|
+
end
|
296
|
+
|
297
|
+
|
255
298
|
end
|
256
299
|
end
|
data/test/ts_buildmaster.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__))
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
|
-
require 'buildmaster/
|
5
|
-
require 'buildmaster/tc_cvs_client'
|
4
|
+
require 'buildmaster/tc_ant_driver'
|
6
5
|
require 'buildmaster/tc_release_control'
|
6
|
+
require 'buildmaster/tc_site_spec'
|
7
7
|
require 'buildmaster/tc_site'
|
8
|
+
require 'buildmaster/tc_cvs_driver'
|
8
9
|
require 'buildmaster/tc_svn_driver'
|
9
10
|
require 'buildmaster/tc_template_runner'
|
10
11
|
require 'buildmaster/tc_xtemplate'
|
12
|
+
require 'buildmaster/tc_file_processor'
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: BuildMaster
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.7.0
|
7
|
+
date: 2006-07-23
|
8
8
|
summary: "A project that hosts a series of scripts to be used in project building, project
|
9
9
|
releasing, and site building."
|
10
10
|
require_paths:
|
@@ -32,14 +32,16 @@ files:
|
|
32
32
|
- lib/buildmaster.rb
|
33
33
|
- lib/mock
|
34
34
|
- lib/mock.rb
|
35
|
-
- lib/buildmaster/
|
35
|
+
- lib/buildmaster/ant_driver.rb
|
36
36
|
- lib/buildmaster/build_file.rb
|
37
|
-
- lib/buildmaster/
|
37
|
+
- lib/buildmaster/cvs_driver.rb
|
38
38
|
- lib/buildmaster/file_processor.rb
|
39
|
+
- lib/buildmaster/java_manifest.rb
|
39
40
|
- lib/buildmaster/release_control.rb
|
40
41
|
- lib/buildmaster/run_ant.rb
|
41
42
|
- lib/buildmaster/shell_command.rb
|
42
43
|
- lib/buildmaster/site.rb
|
44
|
+
- lib/buildmaster/site_spec.rb
|
43
45
|
- lib/buildmaster/site_tester.rb
|
44
46
|
- lib/buildmaster/source_file_handler.rb
|
45
47
|
- lib/buildmaster/svn_driver.rb
|
@@ -51,10 +53,14 @@ files:
|
|
51
53
|
- test/ts_buildmaster.rb
|
52
54
|
- test/buildmaster/build.xml
|
53
55
|
- test/buildmaster/content
|
54
|
-
- test/buildmaster/
|
55
|
-
- test/buildmaster/
|
56
|
+
- test/buildmaster/manifest.mf
|
57
|
+
- test/buildmaster/tc_ant_driver.rb
|
58
|
+
- test/buildmaster/tc_cvs_driver.rb
|
59
|
+
- test/buildmaster/tc_file_processor.rb
|
60
|
+
- test/buildmaster/tc_java_manifest.rb
|
56
61
|
- test/buildmaster/tc_release_control.rb
|
57
62
|
- test/buildmaster/tc_site.rb
|
63
|
+
- test/buildmaster/tc_site_spec.rb
|
58
64
|
- test/buildmaster/tc_svn_driver.rb
|
59
65
|
- test/buildmaster/tc_template_runner.rb
|
60
66
|
- test/buildmaster/tc_xtemplate.rb
|
@@ -69,14 +75,4 @@ extra_rdoc_files:
|
|
69
75
|
executables: []
|
70
76
|
extensions: []
|
71
77
|
requirements: []
|
72
|
-
dependencies:
|
73
|
-
- !ruby/object:Gem::Dependency
|
74
|
-
name: RedCloth
|
75
|
-
version_requirement:
|
76
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
77
|
-
requirements:
|
78
|
-
-
|
79
|
-
- ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 3.0.4
|
82
|
-
version:
|
78
|
+
dependencies: []
|