BuildMaster 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README +26 -0
  2. data/lib/buildmaster.rb +2 -1
  3. data/lib/buildmaster/build_number_file.rb +27 -0
  4. data/lib/buildmaster/buildnumber +1 -0
  5. data/lib/buildmaster/file_processor.rb +114 -25
  6. data/lib/buildmaster/java_manifest.rb +4 -0
  7. data/lib/buildmaster/{site.rb → site/site.rb} +11 -46
  8. data/lib/buildmaster/site/template/buildmaster.css +340 -0
  9. data/lib/buildmaster/site/template/buildmaster_template.xml +130 -0
  10. data/lib/buildmaster/site/template_builder.rb +276 -0
  11. data/lib/buildmaster/site_server.rb +33 -0
  12. data/lib/buildmaster/site_spec.rb +74 -22
  13. data/lib/buildmaster/site_tester.rb +14 -2
  14. data/lib/buildmaster/source_content.rb +11 -0
  15. data/lib/buildmaster/source_file_handler.rb +7 -2
  16. data/lib/buildmaster/svn_driver.rb +23 -11
  17. data/lib/buildmaster/template_exception.rb +8 -0
  18. data/lib/buildmaster/template_runner.rb +19 -86
  19. data/lib/buildmaster/templatelets.rb +23 -0
  20. data/lib/buildmaster/templatelets/attribute.rb +16 -0
  21. data/lib/buildmaster/templatelets/each.rb +43 -0
  22. data/lib/buildmaster/templatelets/href.rb +39 -0
  23. data/lib/buildmaster/templatelets/include.rb +30 -0
  24. data/lib/buildmaster/templatelets/link.rb +41 -0
  25. data/lib/buildmaster/templatelets/text.rb +14 -0
  26. data/lib/buildmaster/templatelets/when.rb +24 -0
  27. data/lib/buildmaster/tree_to_object.rb +76 -0
  28. data/lib/buildmaster/xtemplate.rb +10 -11
  29. data/test/buildmaster/manifest.mf +1 -1
  30. data/test/buildmaster/{content → site/content}/index.html +0 -0
  31. data/test/buildmaster/site/content/markdown.markdown +0 -0
  32. data/test/buildmaster/site/content/textile.textile +0 -0
  33. data/test/buildmaster/{tc_site.rb → site/tc_site.rb} +1 -1
  34. data/test/buildmaster/site/tc_template_builder.rb +128 -0
  35. data/test/buildmaster/tc_build_number_file.rb +31 -0
  36. data/test/buildmaster/tc_file_processor.rb +81 -14
  37. data/test/buildmaster/tc_site_spec.rb +26 -42
  38. data/test/buildmaster/tc_source_file_handler.rb +55 -0
  39. data/test/buildmaster/tc_template_runner.rb +42 -1
  40. data/test/buildmaster/tc_tree_to_object.rb +120 -0
  41. data/test/buildmaster/tc_xtemplate.rb +13 -233
  42. data/test/buildmaster/templatelets/common_templatelet_test.rb +27 -0
  43. data/test/buildmaster/templatelets/tc_attribute.rb +57 -0
  44. data/test/buildmaster/templatelets/tc_each.rb +69 -0
  45. data/test/buildmaster/templatelets/tc_href.rb +48 -0
  46. data/test/buildmaster/templatelets/tc_include.rb +34 -0
  47. data/test/buildmaster/templatelets/tc_link.rb +70 -0
  48. data/test/buildmaster/templatelets/tc_text.rb +36 -0
  49. data/test/buildmaster/templatelets/tc_when.rb +59 -0
  50. data/test/buildmaster/ts_site.rb +4 -0
  51. data/test/buildmaster/ts_templatelets.rb +10 -0
  52. data/test/tmp/output/index.html +8 -0
  53. data/test/tmp/output/markdown.html +8 -0
  54. data/test/tmp/output/textile.html +8 -0
  55. data/test/ts_buildmaster.rb +15 -3
  56. metadata +102 -53
@@ -6,61 +6,45 @@ require 'buildmaster'
6
6
  module BuildMaster
7
7
 
8
8
  class SiteSpecTest < Test::Unit::TestCase
9
+
9
10
  def test_should_get_relative_path
10
- spec = SiteSpec.new
11
+ spec = SiteSpec.new()
11
12
  spec.content_dir = '/one/two/content'
12
13
  assert_equal('images/logo.gif', spec.relative_to_root('/one/two/content/images/logo.gif').to_s)
13
14
  end
14
15
 
15
16
  def test_should_support_windows_path
16
- spec = SiteSpec.new
17
+ spec = SiteSpec.new()
17
18
  spec.content_dir = "C:\\Work\\project\\content"
18
19
  assert_equal('images/logo.gif', spec.relative_to_root('C:\\Work\\project\\content\\images\\logo.gif').to_s)
19
20
  end
20
21
 
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)
22
+ def test_initialize_with_block
23
+ spec = SiteSpec.new(__FILE__) do |sitespec|
24
+ sitespec.content_dir = 'content'
25
+ sitespec.output_dir = 'output'
26
+ sitespec.page_layout = <<CONTENT
27
+ title_header: BuildMaster -
28
+ css_path: css.css
29
+ logo:
30
+ path: logo.gif
31
+ link: index.html
32
+ menu_groups:
33
+ - title: first menu group
34
+ menu_items:
35
+ - title: item one for g1
36
+ link: item_one.html
37
+ - title: item two for g2
38
+ link: item_two.html
39
+ - title: second menu group
40
+ CONTENT
43
41
  end
42
+ root = File.dirname(__FILE__)
43
+ assert_equal(File.join(root, 'content'), spec.content_dir)
44
+ assert_equal(File.join(root, 'output'), spec.output_dir)
45
+ assert_equal(true, spec.load_template_source.to_s.include?('first menu group'))
44
46
  end
45
47
 
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
48
  end
65
49
 
66
50
  end
@@ -0,0 +1,55 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
2
+
3
+ require 'test/unit'
4
+ require 'buildmaster'
5
+ require 'webrick'
6
+ require 'source_file_handler'
7
+
8
+ module BuildMaster
9
+
10
+ class SourceFileHandlerTest < Test::Unit::TestCase
11
+ attr_reader :path_info
12
+
13
+ def test_should_be_able_to_find_source
14
+ server = WEBrick::HTTPServer.new
15
+ dir = File.dirname(__FILE__)
16
+ spec = SiteSpec.new
17
+ spec.template =<<TEMPLATE
18
+ <html xmlns="http://www.w3.org/1999/xhtml"
19
+ xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
20
+ <head>
21
+ <title>Title</title>
22
+ </head>
23
+ <body>
24
+ </body>
25
+ </html>
26
+ TEMPLATE
27
+ spec.content_dir = File.join(dir, 'site', 'content')
28
+ spec.output_dir = File.join(dir, 'output')
29
+ file_handler = SourceFileHandler.new(server, spec)
30
+ @path_info = '/markdown.html'
31
+ file_handler.service(self, self)
32
+ document = REXML::Document.new(self['body'])
33
+ assert_equal('Title', REXML::XPath.first(document, '/html/head/title').text)
34
+ end
35
+
36
+ def []=(name, value)
37
+ logged_properties[name] = value
38
+ end
39
+
40
+ def [](name)
41
+ logged_properties[name]
42
+ end
43
+
44
+ def logged_properties
45
+ @logged_properties = Hash.new unless (@logged_properties)
46
+ return @logged_properties
47
+ end
48
+
49
+ def body=(value)
50
+ self['body']=value
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -3,7 +3,10 @@ $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
3
3
  require 'rexml/xpath'
4
4
  require 'rexml/document'
5
5
  require 'test/unit'
6
+ require 'pathname'
6
7
  require 'buildmaster/template_runner'
8
+ require 'buildmaster/source_content'
9
+ require 'buildmaster/templatelets'
7
10
 
8
11
  module BuildMaster
9
12
  class TemplateRunnerTest < Test::Unit::TestCase
@@ -32,9 +35,47 @@ END
32
35
  template_element = REXML::XPath.first(REXML::Document.new(template_content), "/html/p")
33
36
  source_xml = REXML::Document.new(source_content)
34
37
  source_element = REXML::XPath.first(source_xml, '/persons/person[@id="1"]')
35
- runner = TemplateRunner.new(target_element, template_element, source_element)
38
+ runner = TemplateRunner.new(target_element, template_element,
39
+ SourceContent.new(Pathname.new('content'), source_element))
40
+ runner.templatelets['include'] = Include.new(self)
36
41
  runner.process
37
42
  assert_equal('Name One', REXML::XPath.first(REXML::Document.new(target_xml.to_s), '/html/h1/text()').value.strip)
38
43
  end
44
+
45
+ def test_should_use_templatelet_based_on_name
46
+ output = REXML::Document.new
47
+ template_content = <<END
48
+ <html xmlns="http://www.w3.org/1999/xhtml"
49
+ xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
50
+ <p>
51
+ <template:name attribute="value" attribute2="value2"/>
52
+ </p>
53
+ </html>
54
+ END
55
+ template_document = REXML::Document.new(template_content)
56
+ runner = TemplateRunner.new(output, template_document,
57
+ SourceContent.new(Pathname.new('content/index.textile'), REXML::Document.new))
58
+ runner.templatelets['name'] = NameTemplatelet.new(self)
59
+ runner.process
60
+ assert_equal('p', @element_target.name)
61
+ assert_equal('name', @element_processed.name)
62
+ assert_equal('value', @element_processed.attributes['attribute'])
63
+ assert_equal('value2', @element_processed.attributes['attribute2'])
64
+ end
65
+
66
+ def processed(target, element)
67
+ @element_target = target
68
+ @element_processed = element
69
+ end
70
+ end
71
+
72
+ class NameTemplatelet
73
+ def initialize(logger)
74
+ @logger = logger
75
+ end
76
+
77
+ def process(target, element, current_path)
78
+ @logger.processed(target, element)
79
+ end
39
80
  end
40
81
  end
@@ -0,0 +1,120 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
+
3
+ require 'test/unit'
4
+
5
+ require 'buildmaster/tree_to_object'
6
+
7
+ module BuildMaster
8
+ class TreeToObjectTest < Test::Unit::TestCase
9
+ def test_should_populate_string_fields
10
+ content = <<CONTENT
11
+ field_one: value_one
12
+ field_two: value_two
13
+ CONTENT
14
+ tree = YAML.load(content)
15
+ object = SampleObject.new
16
+ TreeToObject.new(tree, object).convert
17
+ assert_equal('value_one', object.field_one)
18
+ assert_equal('value_two', object.field_two)
19
+ end
20
+
21
+ def test_should_populate_array_fields
22
+ content = <<CONTENT
23
+ array_field:
24
+ - field: valueone
25
+ index: 1
26
+ - field: valuetwo
27
+ index: 2
28
+ CONTENT
29
+ object = TreeToObject.from_yaml(content, SampleObject.new)
30
+ array = object.array_field
31
+ assert_equal(2, array.size)
32
+ assert_equal('valueone', array[0].field)
33
+ assert_equal('1', array[0].index.to_s)
34
+ assert_equal('valuetwo', array[1].field)
35
+ assert_equal('2', array[1].index.to_s)
36
+ end
37
+
38
+ def test_should_populate_instance_fields
39
+ content = <<CONTENT
40
+ object_two:
41
+ field: my_field
42
+ index: 5
43
+ CONTENT
44
+ object = TreeToObject.from_yaml(content, SampleObject.new)
45
+ actual = object.object_two
46
+ assert_equal('my_field', actual.field)
47
+ assert_equal('5', actual.index.to_s)
48
+ end
49
+
50
+ def test_should_raise_error_if_property_not_found
51
+ content = <<CONTENT
52
+ not_field: value
53
+ CONTENT
54
+ begin
55
+ object = TreeToObject.from_yaml(content, SampleObject.new)
56
+ fail('exception should have been thrown')
57
+ rescue PropertyMatchError => error
58
+ assert_equal(true, error.message.include?('not_field'))
59
+ assert_equal(true, error.message.include?('string'))
60
+ end
61
+ end
62
+
63
+ def test_should_raise_error_if_sub_property_not_found
64
+ content = <<CONTENT
65
+ not_sub_property:
66
+ field: value
67
+ CONTENT
68
+ begin
69
+ object = TreeToObject.from_yaml(content, SampleObject.new)
70
+ fail('exception should have been thrown')
71
+ rescue PropertyMatchError => error
72
+ assert_equal(true, error.message.include?('not_sub_property'))
73
+ assert_equal(true, error.message.include?('sub property'))
74
+ end
75
+ end
76
+
77
+ def test_should_raise_error_if_array_property_not_found
78
+ content = <<CONTENT
79
+ not_array_property:
80
+ - name: title
81
+ - name: title
82
+ CONTENT
83
+ begin
84
+ object = TreeToObject.from_yaml(content, SampleObject.new)
85
+ fail('exception should have been thrown')
86
+ rescue PropertyMatchError => error
87
+ assert_equal(true, error.message.include?('not_array_property'))
88
+ assert_equal(true, error.message.include?('array'))
89
+ end
90
+ end
91
+
92
+ def test_empty_content
93
+ object = TreeToObject.from_yaml('', SampleObject.new)
94
+ assert_equal(nil, object.field_one)
95
+ end
96
+
97
+ end
98
+
99
+
100
+ class SampleObject
101
+ attr_reader :field_one, :field_two, :object_two, :array_field
102
+ attr_writer :field_one, :field_two
103
+
104
+ def initialize
105
+ @object_two = SampleTwo.new
106
+ @array_field = Array.new
107
+ end
108
+
109
+ def add_to_array_field
110
+ item = SampleTwo.new
111
+ @array_field.push(item)
112
+ return item
113
+ end
114
+ end
115
+
116
+ class SampleTwo
117
+ attr_reader :field, :index
118
+ attr_writer :field, :index
119
+ end
120
+ end
@@ -3,6 +3,7 @@ $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
3
3
  require 'rexml/xpath'
4
4
  require 'test/unit'
5
5
  require 'buildmaster'
6
+ require 'buildmaster/source_content'
6
7
 
7
8
  module BuildMaster
8
9
  class XTemplateTest < Test::Unit::TestCase
@@ -13,7 +14,7 @@ module BuildMaster
13
14
 
14
15
  public
15
16
  def test_should_initialize_with_io
16
- template = BuildMaster::XTemplate.new(File.open(File.join(File.dirname(__FILE__), "template.xhtml")))
17
+ template = BuildMaster::XTemplate.new(File.open(File.join(File.dirname(__FILE__), "template.xhtml")), Hash.new)
17
18
  end
18
19
 
19
20
  def test_should_initialize_with_content
@@ -26,37 +27,12 @@ module BuildMaster
26
27
  <body>Body</body>
27
28
  </html>
28
29
  CONTENT
29
- template = XTemplate.new(template_content)
30
- xml_output = template.process('')
30
+ template = XTemplate.new(template_content, Hash.new)
31
+ xml_output = template.process(SourceContent.new(Pathname.new('content'), ''))
31
32
  assert_equal('Body', REXML::XPath.first(xml_output, '/html/body').text)
32
33
  end
33
34
 
34
- def test_should_process_include_with_elements_attribute
35
- template_content = <<INCLUDE_CONTENT
36
- <html xmlns="http://www.w3.org/1999/xhtml"
37
- xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
38
- <head>
39
- <title>BuildMaster - <template:include elements="/html/head/title/text()"/></title>
40
- </head>
41
- <body>
42
- </body>
43
- </html>
44
- INCLUDE_CONTENT
45
- source_content = <<INCLUDE_SOURCE
46
- <!DOCTYPE html
47
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
48
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
49
- <html xmlns="http://www.w3.org/1999/xhtml">
50
- <head><title>Page Title</title></head>
51
- <body></body>
52
- </html>
53
- INCLUDE_SOURCE
54
- template = XTemplate.new(template_content)
55
- xml_output = REXML::Document.new(template.process(source_content).to_s)
56
- assert_equal('BuildMaster - Page Title', REXML::XPath.first(xml_output, '/html/head/title').text)
57
- end
58
-
59
- def test_should_process_when_with_select_value_attribute
35
+ def test_should_hook_up_templatelets
60
36
  template_content = <<INCLUDE_CONTENT
61
37
  <html xmlns="http://www.w3.org/1999/xhtml"
62
38
  xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
@@ -81,219 +57,23 @@ INCLUDE_CONTENT
81
57
  <body></body>
82
58
  </html>
83
59
  INCLUDE_SOURCE
84
- template = XTemplate.new(template_content)
85
- xml_document = template.process(source_content) {|expression| return true}
60
+ template = XTemplate.new(template_content, load_templatelets)
61
+ xml_document = template.process(SourceContent.new(nil, source_content))
86
62
  xml_output = REXML::Document.new(xml_document.to_s())
87
63
  assert_equal('BuildMaster - Index', REXML::XPath.first(xml_output, '/html/head/title').text)
88
64
  assert_equal('one', REXML::XPath.first(xml_output, '/html/body/ul/li').text)
89
65
  end
90
66
 
91
- def test_should_not_process_when_if_select_false
92
- template_content = <<INCLUDE_CONTENT
93
- <html xmlns="http://www.w3.org/1999/xhtml"
94
- xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
95
- <head>
96
- <title>BuildMaster<template:when test="index_file?"> - Index</template:when></title>
97
- </head>
98
- <body>
99
- </body>
100
- </html>
101
- INCLUDE_CONTENT
102
- source_content = <<INCLUDE_SOURCE
103
- <!DOCTYPE html
104
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
105
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
106
- <html xmlns="http://www.w3.org/1999/xhtml">
107
- <head><title>Page Title</title></head>
108
- <body></body>
109
- </html>
110
- INCLUDE_SOURCE
111
- template = XTemplate.new(template_content)
112
- xml_document = template.process(source_content) {|expression| return false}
113
- xml_output = REXML::Document.new(xml_document.to_s())
114
- assert_equal('BuildMaster', REXML::XPath.first(xml_output, '/html/head/title').text)
67
+ def what?(path)
68
+ return true
115
69
  end
116
70
 
117
- def test_should_process_attr_with_eval_attribute
118
- template_content = <<INCLUDE_CONTENT
119
- <html xmlns="http://www.w3.org/1999/xhtml"
120
- xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
121
- <head>
122
- <title>BuildMaster</title>
123
- </head>
124
- <body>
125
- <a><template:attribute name="href" eval="document_link"/></a>
126
- </body>
127
- </html>
128
- INCLUDE_CONTENT
129
- source_content = <<INCLUDE_SOURCE
130
- <!DOCTYPE html
131
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
132
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
133
- <html xmlns="http://www.w3.org/1999/xhtml">
134
- <head><title>Page Title</title></head>
135
- <body></body>
136
- </html>
137
- INCLUDE_SOURCE
138
- template = XTemplate.new(template_content)
139
- xml_document = template.process(source_content) {|expression| return 'http://svn.buildmaster/'}
140
- xml_output = REXML::Document.new(xml_document.to_s())
141
- assert_equal('http://svn.buildmaster', REXML::XPath.first(xml_output, '/html/body/a/@href').text)
71
+ def index_file?(path)
72
+ return true
142
73
  end
143
74
 
144
- def test_should_process_text_with_eval_attribute
145
- template_content = <<INCLUDE_CONTENT
146
- <html xmlns="http://www.w3.org/1999/xhtml"
147
- xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
148
- <head>
149
- <title>BuildMaster</title>
150
- </head>
151
- <body>
152
- <h1><template:text eval="release_info"/></h1>
153
- </body>
154
- </html>
155
- INCLUDE_CONTENT
156
- source_content = <<INCLUDE_SOURCE
157
- <!DOCTYPE html
158
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
159
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
160
- <html xmlns="http://www.w3.org/1999/xhtml">
161
- <head><title>Page Title</title></head>
162
- <body></body>
163
- </html>
164
- INCLUDE_SOURCE
165
- template = XTemplate.new(template_content)
166
- xml_document = template.process(source_content) {|expression| return 'release 0.0.1 (build 235)'}
167
- xml_output = REXML::Document.new(xml_document.to_s())
168
- assert_equal('release 0.0.1 (build 235)', REXML::XPath.first(xml_output, '/html/body/h1').text)
75
+ def load_templatelets
76
+ return {'when' => When.new(self, self)}
169
77
  end
170
-
171
- def test_should_process_each_with_children
172
- template_content = <<INCLUDE_CONTENT
173
- <html xmlns="http://www.w3.org/1999/xhtml"
174
- xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
175
- <head>
176
- <title>BuildMaster</title>
177
- </head>
178
- <body>
179
- <div class="NewsGroup">
180
- <h1>Recent News</h1>
181
- <template:each source="rss" select="/rss/channel/item" count="3">
182
- <div class="NewsItem">
183
- <p class="NewsTitle"><template:include elements="./title/text()"/></p>
184
- <p class="NewsDate"><template:include elements="./pubDate/text()"/></p>
185
- <p class="NewsText"><template:include elements="./xhtml:div/node()"/></p>
186
- </div>
187
- </template:each>
188
- </div>
189
- </body>
190
- </html>
191
- INCLUDE_CONTENT
192
- source_content = <<INCLUDE_SOURCE
193
- <!DOCTYPE html
194
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
195
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
196
- <html xmlns="http://www.w3.org/1999/xhtml">
197
- <head><title>Page Title</title></head>
198
- <body></body>
199
- </html>
200
- INCLUDE_SOURCE
201
- template = XTemplate.new(template_content)
202
- xml_document = template.process(source_content) do |expression| <<NEWS
203
- <?xml version="1.0" encoding="UTF-8"?>
204
- <rss version="2.0">
205
- <channel>
206
- <title>BuildMaster News</title>
207
- <link>http://buildmaster.rubyforge.org/</link>
208
- <description>BuildMaster is a set of classes in Ruby to help easy the task of project building, releasing
209
- and website building</description>
210
- <language>en-us</language>
211
- <lastBuildDate>Tue, 09 May 2006 17:12:46 GMT</lastBuildDate>
212
- <image>
213
- <url>http://buildmaster.rubyforge.org/logo.gif</url>
214
- <title>BuildMaster</title>
215
- <link>http://buildmaster.rubyforge.org/</link>
216
- </image>
217
- <item>
218
- <title>BuildMaster website created</title>
219
- <link>http://buildmaster.rubyforge.org/</link>
220
- <description>BuildMaster website has been created by its own script</description>
221
- <category>Documentation</category>
222
- <pubDate>Sat, 27 May 2006 16:00:00 GMT</pubDate>
223
- </item>
224
- <item>
225
- <title>XTemplate script created</title>
226
- <link>http://buildmaster.rubyforge.org</link>
227
- <description>XTemplate script has been created, following the ones that is currently being used for jBehave and jMock</description>
228
- <category>Development</category>
229
- <pubDate>Wed, 05 Apr 2006 16:00:00 GMT</pubDate>
230
- </item>
231
- <item>
232
- <title>BuildMaster code structure created</title>
233
- <link>http://buildmaster.rubyforge.org</link>
234
- <description>BuildMaster project structure has been created with according files so that a gem can be created
235
- and released onto rubyforge</description>
236
- <category>Development</category>
237
- <pubDate>Sat, 08 Apr 2006 16:00:00 GMT</pubDate>
238
- </item>
239
- <item>
240
- <title>BuildMaster moved from RubyBuilder</title>
241
- <description>RubyBuilder project has been deleted and renamed to BuildMaster to easy any confusion</description>
242
- <category>Development</category>
243
- <pubDate>Sat, 01 Apr 2006 16:00:00 GMT</pubDate>
244
- </item>
245
- </channel>
246
- </rss>
247
- NEWS
248
- end
249
- xml_output = REXML::Document.new(xml_document.to_s())
250
- assert_equal(3, REXML::XPath.match(xml_output, '/html/body/div/div').size)
251
- assert_equal('BuildMaster website created',
252
- REXML::XPath.first(xml_output, '/html/body/div/div[1]/p').text())
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
-
298
78
  end
299
79
  end