BuildMaster 0.9.1 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/svnfix.rb +3 -0
- data/lib/buildmaster/ci/server.rb +55 -0
- data/lib/buildmaster/common.rb +3 -0
- data/lib/buildmaster/common/properties.rb +28 -0
- data/lib/buildmaster/{tree_to_object.rb → common/tree_to_object.rb} +0 -0
- data/lib/buildmaster/cotta.rb +1 -1
- data/lib/buildmaster/cotta/command_error.rb +6 -1
- data/lib/buildmaster/cotta/command_interface.rb +44 -0
- data/lib/buildmaster/cotta/command_runner.rb +39 -0
- data/lib/buildmaster/cotta/cotta.rb +40 -3
- data/lib/buildmaster/cotta/cotta_dir.rb +28 -7
- data/lib/buildmaster/cotta/cotta_file.rb +14 -2
- data/lib/buildmaster/cotta/cotta_pathname.rb +9 -0
- data/lib/buildmaster/cotta/in_memory_system.rb +20 -9
- data/lib/buildmaster/cotta/physical_system.rb +4 -8
- data/lib/buildmaster/project.rb +10 -0
- data/lib/buildmaster/{ant_driver.rb → project/ant_driver.rb} +0 -0
- data/lib/buildmaster/project/build.rb +3 -0
- data/lib/buildmaster/{build_number_file.rb → project/build_number_file.rb} +4 -0
- data/lib/buildmaster/project/ci.rb +3 -0
- data/lib/buildmaster/{cvs_driver.rb → project/cvs_driver.rb} +0 -0
- data/lib/buildmaster/project/ftp_driver.rb +64 -0
- data/lib/buildmaster/{java_manifest.rb → project/java_manifest.rb} +0 -0
- data/lib/buildmaster/project/pscp_driver.rb +17 -0
- data/lib/buildmaster/project/release.rb +67 -0
- data/lib/buildmaster/project/ruby_forge_project.rb +26 -0
- data/lib/buildmaster/{run_ant.rb → project/run_ant.rb} +0 -0
- data/lib/buildmaster/project/server_manager.rb +64 -0
- data/lib/buildmaster/project/svn_admin_driver.rb +20 -0
- data/lib/buildmaster/project/svn_driver.rb +94 -0
- data/lib/buildmaster/project/svn_helper.rb +113 -0
- data/lib/buildmaster/project/svn_status_info.rb +54 -0
- data/lib/buildmaster/{try.rb → project/try.rb} +0 -0
- data/lib/buildmaster/project/version_number_file.rb +45 -0
- data/lib/buildmaster/{windows → project/windows}/iis_driver.rb +4 -4
- data/lib/buildmaster/{windows → project/windows}/sql_server_driver.rb +0 -0
- data/lib/buildmaster/site.rb +5 -0
- data/lib/buildmaster/site/about_handler.rb +43 -0
- data/lib/buildmaster/site/content_engine_repository.rb +83 -0
- data/lib/buildmaster/site/element_processor_by_name.rb +18 -0
- data/lib/buildmaster/site/file_processor.rb +59 -0
- data/lib/buildmaster/site/site.rb +29 -6
- data/lib/buildmaster/site/site_server.rb +56 -0
- data/lib/buildmaster/{site_spec.rb → site/site_spec.rb} +63 -38
- data/lib/buildmaster/{site_tester.rb → site/site_tester.rb} +0 -0
- data/lib/buildmaster/site/source_content.rb +12 -0
- data/lib/buildmaster/{source_file_handler.rb → site/source_file_handler.rb} +13 -27
- data/lib/buildmaster/site/template_builder.rb +4 -0
- data/lib/buildmaster/site/template_error.rb +18 -0
- data/lib/buildmaster/{template_runner.rb → site/template_runner.rb} +6 -16
- data/lib/buildmaster/{templatelets.rb → site/templatelets.rb} +3 -1
- data/lib/buildmaster/site/templatelets/attribute.rb +21 -0
- data/lib/buildmaster/site/templatelets/code.rb +82 -0
- data/lib/buildmaster/{templatelets → site/templatelets}/each.rb +7 -5
- data/lib/buildmaster/{templatelets → site/templatelets}/href.rb +1 -1
- data/lib/buildmaster/{templatelets → site/templatelets}/include.rb +0 -0
- data/lib/buildmaster/{templatelets → site/templatelets}/link.rb +2 -3
- data/lib/buildmaster/{templatelets → site/templatelets}/text.rb +1 -1
- data/lib/buildmaster/{templatelets → site/templatelets}/when.rb +4 -7
- data/lib/buildmaster/site/templates/buildmaster/content/border_bottom.gif +0 -0
- data/lib/buildmaster/site/templates/buildmaster/content/buildmaster.css +370 -0
- data/lib/buildmaster/site/templates/buildmaster/content/logo.gif +0 -0
- data/lib/buildmaster/site/templates/buildmaster/content/news-rss2.xml +4 -0
- data/lib/buildmaster/site/templates/buildmaster/content/print.css +65 -0
- data/lib/buildmaster/site/templates/buildmaster/content/ruby.css +14 -0
- data/lib/buildmaster/site/templates/buildmaster/template.html +121 -0
- data/lib/buildmaster/site/templates/cotta/content/border_bottom.gif +0 -0
- data/lib/buildmaster/site/templates/cotta/content/cotta.css +363 -0
- data/lib/buildmaster/site/templates/cotta/content/cotta.gif +0 -0
- data/lib/buildmaster/site/templates/cotta/content/news-rss2.xml +2 -0
- data/lib/buildmaster/site/templates/cotta/template.html +106 -0
- data/lib/buildmaster/site/xtemplate.rb +26 -0
- data/lib/buildmaster/version +1 -0
- data/test/buildmaster/common/tc_properties.rb +24 -0
- data/test/buildmaster/{tc_tree_to_object.rb → common/tc_tree_to_object.rb} +18 -18
- data/test/buildmaster/cotta/cotta_specifications.rb +88 -64
- data/test/buildmaster/cotta/physical_system_stub.rb +3 -3
- data/test/buildmaster/cotta/system_file_specifications.rb +38 -47
- data/test/buildmaster/cotta/tc_command_interface.rb +46 -0
- data/test/buildmaster/cotta/tc_command_runner.rb +28 -0
- data/test/buildmaster/cotta/tc_cotta.rb +35 -9
- data/test/buildmaster/cotta/tc_cotta_dir_in_memory.rb +10 -5
- data/test/buildmaster/cotta/tc_cotta_file_in_memory.rb +3 -3
- data/test/buildmaster/cotta/tc_in_memory_system.rb +7 -2
- data/test/buildmaster/cotta/tc_pathname.rb +22 -0
- data/test/buildmaster/cotta/tc_physical_system.rb +12 -2
- data/test/buildmaster/{build.xml → project/build.xml} +0 -0
- data/test/buildmaster/{manifest.mf → project/manifest.mf} +0 -0
- data/test/buildmaster/{tc_ant_driver.rb → project/tc_ant_driver.rb} +3 -3
- data/test/buildmaster/{tc_build_number_file.rb → project/tc_build_number_file.rb} +7 -7
- data/test/buildmaster/{tc_cvs_driver.rb → project/tc_cvs_driver.rb} +14 -14
- data/test/buildmaster/{tc_java_manifest.rb → project/tc_java_manifest.rb} +7 -7
- data/test/buildmaster/project/tc_release.rb +61 -0
- data/test/buildmaster/project/tc_server_manager.rb +70 -0
- data/test/buildmaster/project/tc_svn_driver.rb +104 -0
- data/test/buildmaster/project/tc_svn_status_info.rb +37 -0
- data/test/buildmaster/project/tc_version_number_file.rb +46 -0
- data/test/buildmaster/{windows → project/windows}/tc_iis_driver.rb +5 -4
- data/test/buildmaster/{windows → project/windows}/tc_sql_server_driver.rb +4 -4
- data/test/buildmaster/site/content/tc_content_engine_repository.rb +63 -0
- data/test/buildmaster/site/tc_element_processor_by_name.rb +29 -0
- data/test/buildmaster/site/tc_file_processor.rb +141 -0
- data/test/buildmaster/site/tc_site.rb +42 -11
- data/test/buildmaster/site/tc_site_server.rb +43 -0
- data/test/buildmaster/{tc_site_spec.rb → site/tc_site_spec.rb} +9 -9
- data/test/buildmaster/{tc_source_file_handler.rb → site/tc_source_file_handler.rb} +10 -9
- data/test/buildmaster/site/tc_template_builder.rb +23 -23
- data/test/buildmaster/site/tc_template_error.rb +15 -0
- data/test/buildmaster/{tc_template_runner.rb → site/tc_template_runner.rb} +22 -17
- data/test/buildmaster/site/tc_templatelets.rb +37 -0
- data/test/buildmaster/{tc_xtemplate.rb → site/tc_xtemplate.rb} +14 -15
- data/test/buildmaster/{template.xhtml → site/template.xhtml} +0 -0
- data/test/buildmaster/{templatelets → site/templatelets}/common_templatelet_test.rb +11 -7
- data/test/buildmaster/{templatelets → site/templatelets}/tc_attribute.rb +14 -10
- data/test/buildmaster/site/templatelets/tc_code.rb +132 -0
- data/test/buildmaster/{templatelets → site/templatelets}/tc_each.rb +25 -12
- data/test/buildmaster/{templatelets → site/templatelets}/tc_href.rb +6 -8
- data/test/buildmaster/{templatelets → site/templatelets}/tc_include.rb +3 -12
- data/test/buildmaster/{templatelets → site/templatelets}/tc_link.rb +11 -18
- data/test/buildmaster/{templatelets → site/templatelets}/tc_text.rb +2 -9
- data/test/buildmaster/{templatelets → site/templatelets}/tc_when.rb +8 -15
- data/test/manual/bms.rb +10 -0
- data/test/tmp/svn_test/repository/README.txt +5 -0
- data/test/tmp/svn_test/repository/conf/authz +21 -0
- data/test/tmp/svn_test/repository/conf/passwd +8 -0
- data/test/tmp/svn_test/repository/conf/svnserve.conf +30 -0
- data/test/tmp/svn_test/repository/db/current +1 -0
- data/test/tmp/svn_test/repository/db/format +1 -0
- data/test/tmp/svn_test/repository/db/fs-type +1 -0
- data/test/tmp/svn_test/repository/db/revprops/0 +5 -0
- data/test/tmp/svn_test/repository/db/revprops/1 +13 -0
- data/test/tmp/svn_test/repository/db/revprops/2 +13 -0
- data/test/tmp/svn_test/repository/db/revprops/3 +13 -0
- data/test/tmp/svn_test/repository/db/revprops/4 +13 -0
- data/test/tmp/svn_test/repository/db/revs/0 +11 -0
- data/test/tmp/svn_test/repository/db/revs/1 +25 -0
- data/test/tmp/svn_test/repository/db/revs/2 +29 -0
- data/test/tmp/svn_test/repository/db/revs/3 +33 -0
- data/test/tmp/svn_test/repository/db/revs/4 +0 -0
- data/test/tmp/svn_test/repository/db/uuid +1 -0
- data/test/tmp/svn_test/repository/db/write-lock +0 -0
- data/test/tmp/svn_test/repository/format +1 -0
- data/test/tmp/svn_test/repository/hooks/post-commit.tmpl +51 -0
- data/test/tmp/svn_test/repository/hooks/post-lock.tmpl +44 -0
- data/test/tmp/svn_test/repository/hooks/post-revprop-change.tmpl +56 -0
- data/test/tmp/svn_test/repository/hooks/post-unlock.tmpl +42 -0
- data/test/tmp/svn_test/repository/hooks/pre-commit.tmpl +70 -0
- data/test/tmp/svn_test/repository/hooks/pre-lock.tmpl +64 -0
- data/test/tmp/svn_test/repository/hooks/pre-revprop-change.tmpl +66 -0
- data/test/tmp/svn_test/repository/hooks/pre-unlock.tmpl +60 -0
- data/test/tmp/svn_test/repository/hooks/start-commit.tmpl +54 -0
- data/test/tmp/svn_test/repository/locks/db-logs.lock +3 -0
- data/test/tmp/svn_test/repository/locks/db.lock +3 -0
- data/test/tmp/svn_test/second/test.txt +1 -0
- data/test/tmp/svn_test/workdir/test.txt +1 -0
- data/test/ts_buildmaster.rb +0 -1
- metadata +168 -69
- data/lib/buildmaster.rb +0 -10
- data/lib/buildmaster/build_file.rb +0 -11
- data/lib/buildmaster/buildnumber +0 -1
- data/lib/buildmaster/file_processor.rb +0 -138
- data/lib/buildmaster/site_server.rb +0 -33
- data/lib/buildmaster/source_content.rb +0 -11
- data/lib/buildmaster/svn_driver.rb +0 -78
- data/lib/buildmaster/template_error.rb +0 -8
- data/lib/buildmaster/templatelets/attribute.rb +0 -16
- data/lib/buildmaster/xtemplate.rb +0 -27
- data/lib/mock.rb +0 -3
- data/lib/mock/mock_base.rb +0 -24
- data/test/buildmaster/tc_file_processor.rb +0 -125
- data/test/buildmaster/tc_svn_driver.rb +0 -81
- data/test/tmp/output/index.html +0 -8
- data/test/tmp/output/markdown.html +0 -8
- data/test/tmp/output/textile.html +0 -8
data/lib/buildmaster.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__))
|
2
|
-
|
3
|
-
require 'buildmaster/build_number_file'
|
4
|
-
require 'buildmaster/java_manifest'
|
5
|
-
require 'buildmaster/ant_driver'
|
6
|
-
require 'buildmaster/cvs_driver'
|
7
|
-
require 'buildmaster/svn_driver'
|
8
|
-
require 'buildmaster/site_spec'
|
9
|
-
require 'buildmaster/site/site'
|
10
|
-
require 'buildmaster/xtemplate'
|
data/lib/buildmaster/buildnumber
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
41
|
@@ -1,138 +0,0 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
2
|
-
|
3
|
-
require 'site_spec'
|
4
|
-
require 'source_content'
|
5
|
-
require 'pathname'
|
6
|
-
|
7
|
-
module BuildMaster
|
8
|
-
|
9
|
-
class FileProcessor
|
10
|
-
#todo match only beginning of the file
|
11
|
-
@@TEXTILE_REGX = /---(-)*\n(.*)\n(-)*---\n/
|
12
|
-
|
13
|
-
def FileProcessor::join(from, path)
|
14
|
-
result = from
|
15
|
-
path.each_filename do |name|
|
16
|
-
result = File.join(result, name)
|
17
|
-
end
|
18
|
-
return result
|
19
|
-
end
|
20
|
-
|
21
|
-
attr_reader :content_file, :target_file
|
22
|
-
|
23
|
-
def initialize(template, content_file, sitespec)
|
24
|
-
@template = template
|
25
|
-
@content_file = content_file
|
26
|
-
@sitespec = sitespec
|
27
|
-
extension = content_file.extname
|
28
|
-
if (extension == '.html')
|
29
|
-
@convert_method = 'process_html'
|
30
|
-
elsif (extension == '.textile')
|
31
|
-
@convert_method = 'process_textile'
|
32
|
-
elsif (extension == '.markdown')
|
33
|
-
@convert_method = 'process_markdown'
|
34
|
-
end
|
35
|
-
if @convert_method
|
36
|
-
basename = content_file.basename
|
37
|
-
@path = sitespec.relative_to_root(content_file).parent.join("#{basename}.html")
|
38
|
-
@target_file = sitespec.output_dir.file(@path)
|
39
|
-
else
|
40
|
-
@target_file = sitespec.output_dir.file(sitespec.relative_to_root(content_file))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def FileProcessor::for_request_path(request_path, site_spec)
|
45
|
-
template = site_spec.load_template
|
46
|
-
if (request_path[0,1] == '/')
|
47
|
-
request_path = request_path[1, request_path.length - 1]
|
48
|
-
end
|
49
|
-
file = site_spec.content_dir.file(request_path)
|
50
|
-
if (file.extname == '.html')
|
51
|
-
file = check_source(file)
|
52
|
-
end
|
53
|
-
return FileProcessor.new(template, file, site_spec)
|
54
|
-
end
|
55
|
-
|
56
|
-
def FileProcessor::check_source(file)
|
57
|
-
result = file
|
58
|
-
basename = file.basename
|
59
|
-
dir = file.parent
|
60
|
-
['textile', 'markdown', 'html'].find do |extension|
|
61
|
-
candidate = dir.file("#{basename}.#{extension}")
|
62
|
-
if (candidate.exists?)
|
63
|
-
result = candidate
|
64
|
-
true
|
65
|
-
else
|
66
|
-
false
|
67
|
-
end
|
68
|
-
end
|
69
|
-
return result
|
70
|
-
end
|
71
|
-
|
72
|
-
def is_html?
|
73
|
-
return target_file.extname == '.html'
|
74
|
-
end
|
75
|
-
|
76
|
-
def write_to_target
|
77
|
-
document = generate_document
|
78
|
-
if (document)
|
79
|
-
target_file.write do |file|
|
80
|
-
document.write(file, 0, false, true)
|
81
|
-
end
|
82
|
-
else
|
83
|
-
content_file.copy_to(target_file)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def generate_document
|
88
|
-
send(@convert_method, load_content()) if (@convert_method)
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
def load_content
|
93
|
-
return content_file.load
|
94
|
-
end
|
95
|
-
|
96
|
-
def process_textile(textile_content)
|
97
|
-
require 'redcloth'
|
98
|
-
return process_content_with_title(textile_content) {|content| RedCloth.new(content).to_html}
|
99
|
-
end
|
100
|
-
|
101
|
-
def process_markdown(markdown_content)
|
102
|
-
require 'bluecloth'
|
103
|
-
return process_content_with_title(markdown_content) {|content| BlueCloth.new(content).to_html}
|
104
|
-
end
|
105
|
-
|
106
|
-
def process_content_with_title(full_content)
|
107
|
-
match_result = @@TEXTILE_REGX.match(full_content)
|
108
|
-
title = ''
|
109
|
-
body_content = full_content
|
110
|
-
if match_result != nil
|
111
|
-
title = match_result[2]
|
112
|
-
body_content = match_result.post_match
|
113
|
-
end
|
114
|
-
html_body = yield body_content
|
115
|
-
html_content = <<HTML
|
116
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
117
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
118
|
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
119
|
-
<head>
|
120
|
-
<title>#{title}</title>
|
121
|
-
</head>
|
122
|
-
<body>
|
123
|
-
#{html_body}
|
124
|
-
</body>
|
125
|
-
</html>
|
126
|
-
HTML
|
127
|
-
return process_html(html_content)
|
128
|
-
end
|
129
|
-
|
130
|
-
def process_html(html_content)
|
131
|
-
source = SourceContent.new(@path, REXML::Document.new(html_content))
|
132
|
-
document_with_skin = @template.process(source)
|
133
|
-
return document_with_skin
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
2
|
-
|
3
|
-
require 'webrick'
|
4
|
-
require 'source_file_handler'
|
5
|
-
|
6
|
-
module BuildMaster
|
7
|
-
class SiteServer
|
8
|
-
def initialize(port_number=2000, log_file=$stdout, level=WEBrick::Log::INFO, access_log=nil)
|
9
|
-
mime_types = WEBrick::HTTPUtils::DefaultMimeTypes.update(
|
10
|
-
{"textile" => "text/plain"}
|
11
|
-
)
|
12
|
-
@server = WEBrick::HTTPServer.new(
|
13
|
-
:Port => port_number,
|
14
|
-
:Logger => WEBrick::Log.new(log_file, level),
|
15
|
-
:MimeTypes => mime_types,
|
16
|
-
:AccessLog => access_log
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
def start(spec)
|
21
|
-
@server.mount('/', SourceFileHandler, spec)
|
22
|
-
@server.mount('/source', WEBrick::HTTPServlet::FileHandler, spec.content_dir, true)
|
23
|
-
['INT', 'TERM'].each { |signal|
|
24
|
-
trap(signal){ stop}
|
25
|
-
}
|
26
|
-
@server.start
|
27
|
-
end
|
28
|
-
|
29
|
-
def stop
|
30
|
-
@server.shutdown
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
require 'rexml/document'
|
3
|
-
|
4
|
-
module BuildMaster
|
5
|
-
|
6
|
-
class SvnDriver
|
7
|
-
def SvnDriver::from_path(directory)
|
8
|
-
return SvnDriver.new(directory)
|
9
|
-
end
|
10
|
-
|
11
|
-
attr_reader :work_dir, :repository_url
|
12
|
-
|
13
|
-
def initialize(work_dir, repository_root = nil, repository_url = nil)
|
14
|
-
@system = work_dir.system
|
15
|
-
@work_dir = work_dir
|
16
|
-
@repository_root = repository_root
|
17
|
-
@repository_url = repository_url
|
18
|
-
end
|
19
|
-
|
20
|
-
def repository_root
|
21
|
-
load_svn_info unless @repository_root
|
22
|
-
return @repository_root
|
23
|
-
end
|
24
|
-
|
25
|
-
def repository_url
|
26
|
-
if (not @repository_url)
|
27
|
-
@repository_url = "#{repository_root}/trunk"
|
28
|
-
end
|
29
|
-
return @repository_url
|
30
|
-
end
|
31
|
-
|
32
|
-
def status
|
33
|
-
command_for_path('status')
|
34
|
-
end
|
35
|
-
|
36
|
-
def update
|
37
|
-
command_for_path('update')
|
38
|
-
end
|
39
|
-
|
40
|
-
def commit(comment)
|
41
|
-
command_for_path('commit', " -m \"#{comment}\"")
|
42
|
-
end
|
43
|
-
|
44
|
-
def tag(tag_name)
|
45
|
-
@system.shell("svn copy #{repository_url} #{repository_root}/tags/#{tag_name} -m \"ruby buildmaster\"")
|
46
|
-
end
|
47
|
-
|
48
|
-
def checkout(output)
|
49
|
-
@system.shell("svn checkout #{repository_root}/trunk #{output}")
|
50
|
-
end
|
51
|
-
|
52
|
-
def command(command)
|
53
|
-
command_for_path(command)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
def load_svn_info
|
58
|
-
info = @system.shell_output("svn info #{work_dir.path}")
|
59
|
-
StringIO.new(info).each_line do |line|
|
60
|
-
index = line.index(':')
|
61
|
-
if (index)
|
62
|
-
property = line[0, index].strip
|
63
|
-
value = line[index + 1, line.length - index - 1].strip
|
64
|
-
if (property == 'Repository Root')
|
65
|
-
@repository_root = value
|
66
|
-
elsif (property == 'URL')
|
67
|
-
@repository_url = value
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def command_for_path(svn_command, argument='')
|
74
|
-
@system.shell("svn #{svn_command} #{@work_dir.path}#{argument}")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module BuildMaster
|
2
|
-
class Attribute
|
3
|
-
def initialize(expression_evaluator)
|
4
|
-
@evaluator = expression_evaluator
|
5
|
-
end
|
6
|
-
|
7
|
-
def process(target, template, source)
|
8
|
-
name = template.attribute_value!('name')
|
9
|
-
eval = template.attribute_value!('eval')
|
10
|
-
if (not @evaluator.respond_to?(eval))
|
11
|
-
raise TemplateError, '#{@evaluator.class} cannot evaluate expression #{eval}'
|
12
|
-
end
|
13
|
-
target.attributes[name] = @evaluator.send(eval, source.path)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
2
|
-
|
3
|
-
require 'rexml/document'
|
4
|
-
require 'template_runner'
|
5
|
-
|
6
|
-
module BuildMaster
|
7
|
-
class XTemplate
|
8
|
-
def initialize(template_file, templatelets = Hash.new)
|
9
|
-
@template = REXML::Document.new(template_file)
|
10
|
-
@templatelets = templatelets
|
11
|
-
end
|
12
|
-
|
13
|
-
def process(source, &evaluator)
|
14
|
-
output_xml = process_xml(source, &evaluator)
|
15
|
-
return output_xml
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
def process_xml(source, &evaluator)
|
20
|
-
output_xml = REXML::Document.new
|
21
|
-
runner = TemplateRunner.new(output_xml, @template, source, &evaluator)
|
22
|
-
runner.templatelets = @templatelets
|
23
|
-
runner.process
|
24
|
-
return output_xml
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/mock.rb
DELETED
data/lib/mock/mock_base.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class Mock
|
5
|
-
def initialize(class_to_mock=nil)
|
6
|
-
@class_to_mock = class_to_mock
|
7
|
-
@expectations = Set.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def expects(message)
|
11
|
-
@expectations.add(message)
|
12
|
-
end
|
13
|
-
|
14
|
-
def verify
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def method_missing(method, *args)
|
19
|
-
if (not @expectations.include? method)
|
20
|
-
raise "Unexpected extra call to #{method}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
|
2
|
-
|
3
|
-
require 'spec'
|
4
|
-
require 'rexml/document'
|
5
|
-
require 'pathname'
|
6
|
-
require 'buildmaster/file_processor'
|
7
|
-
require 'buildmaster/xtemplate'
|
8
|
-
require 'buildmaster/cotta'
|
9
|
-
require 'buildmaster/cotta/in_memory_system'
|
10
|
-
|
11
|
-
|
12
|
-
module BuildMaster
|
13
|
-
|
14
|
-
context 'File Processor' do
|
15
|
-
setup do
|
16
|
-
@cotta = Cotta.new(InMemorySystem.new)
|
17
|
-
@cotta.file('content').save(<<CONTENT
|
18
|
-
line one
|
19
|
-
line two
|
20
|
-
line three
|
21
|
-
CONTENT
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
|
-
teardown do
|
26
|
-
@cotta = nil
|
27
|
-
end
|
28
|
-
|
29
|
-
specify 'should know content and target' do
|
30
|
-
template = XTemplate.new(<<CONTENT
|
31
|
-
<html xmlns="http://www.w3.org/1999/xhtml"
|
32
|
-
xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
|
33
|
-
</html>
|
34
|
-
CONTENT
|
35
|
-
)
|
36
|
-
site_spec = SiteSpec.new('file.txt', @cotta)
|
37
|
-
site_spec.content_dir = 'content'
|
38
|
-
site_spec.output_dir = 'output'
|
39
|
-
processor = FileProcessor.new(template, @cotta.file('content/index.html'), site_spec)
|
40
|
-
processor.content_file.path.should_equal(Pathname.new('content/index.html'))
|
41
|
-
processor.is_html?.should_equal(true)
|
42
|
-
end
|
43
|
-
|
44
|
-
specify 'should know HTML target file' do
|
45
|
-
template = XTemplate.new(<<CONTENT
|
46
|
-
<html xmlns="http://www.w3.org/1999/xhtml"
|
47
|
-
xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
|
48
|
-
</html>
|
49
|
-
CONTENT
|
50
|
-
)
|
51
|
-
site_spec = SiteSpec.new(nil, @cotta)
|
52
|
-
current_dir = @cotta.dir('root')
|
53
|
-
site_spec.content_dir = 'root/content'
|
54
|
-
site_spec.output_dir = 'root/output'
|
55
|
-
processor = FileProcessor.new(template, current_dir.dir('content').file('index.gif'), site_spec)
|
56
|
-
processor.content_file.path.should_equal current_dir.dir('content').file('index.gif').path
|
57
|
-
processor.is_html?.should_equal false
|
58
|
-
processor.generate_document.should_equal nil
|
59
|
-
end
|
60
|
-
|
61
|
-
specify 'should load from target file' do
|
62
|
-
template_content = <<CONTENT
|
63
|
-
<html xmlns="http://www.w3.org/1999/xhtml"
|
64
|
-
xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
|
65
|
-
</html>
|
66
|
-
CONTENT
|
67
|
-
site_spec = SiteSpec.new(__FILE__, @cotta)
|
68
|
-
current_dir = @cotta.dir(File.dirname(__FILE__))
|
69
|
-
current_dir.dir('site').dir('content').file('index.html').save
|
70
|
-
current_dir.dir('site').dir('content').file('index.gif').save
|
71
|
-
current_dir.dir('site').dir('content').file('textile.textile').save
|
72
|
-
current_dir.dir('site').dir('content').file('markdown.markdown').save
|
73
|
-
site_spec.template = template_content
|
74
|
-
site_spec.content_dir = 'site/content'
|
75
|
-
site_spec.output_dir = 'output'
|
76
|
-
processor = FileProcessor.for_request_path('/index.html', site_spec)
|
77
|
-
processor.content_file.should_equal site_spec.content_dir.file('index.html')
|
78
|
-
|
79
|
-
processor = FileProcessor.for_request_path('/index.gif', site_spec)
|
80
|
-
processor.content_file.should_equal site_spec.content_dir.file('index.gif')
|
81
|
-
|
82
|
-
processor = FileProcessor.for_request_path('/textile.html', site_spec)
|
83
|
-
processor.content_file.should_equal site_spec.content_dir.file('textile.textile')
|
84
|
-
|
85
|
-
processor = FileProcessor.for_request_path('/markdown.html', site_spec)
|
86
|
-
processor.content_file.should_equal site_spec.content_dir.file('markdown.markdown')
|
87
|
-
end
|
88
|
-
|
89
|
-
def output_dir
|
90
|
-
return @cotta.dir('tmp')
|
91
|
-
end
|
92
|
-
|
93
|
-
def relative_to_root(path)
|
94
|
-
return Pathname.new('tmp')
|
95
|
-
end
|
96
|
-
|
97
|
-
specify 'should have support for markdown content' do
|
98
|
-
template_content = <<CONTENT
|
99
|
-
<html xmlns="http://www.w3.org/1999/xhtml"
|
100
|
-
xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
|
101
|
-
<head><title><template:include elements="/html/head/title/text()"/></title></head>
|
102
|
-
<body>
|
103
|
-
<template:include elements="/html/body/*"/>
|
104
|
-
</body>
|
105
|
-
</html>
|
106
|
-
CONTENT
|
107
|
-
hash = {'include' => Include.new(self)}
|
108
|
-
template = XTemplate.new(template_content, hash)
|
109
|
-
|
110
|
-
processor = FileProcessor.new(template, @cotta.file('content_path'), self)
|
111
|
-
markdown_content = <<CONTENT
|
112
|
-
--------------------------------------------
|
113
|
-
Title Here
|
114
|
-
--------------------------------------------
|
115
|
-
Header
|
116
|
-
=====================
|
117
|
-
CONTENT
|
118
|
-
document = processor.process_markdown(markdown_content)
|
119
|
-
document = REXML::Document.new(document.to_s)
|
120
|
-
REXML::XPath.first(document, '/html/head/title').text.should_equal 'Title Here'
|
121
|
-
REXML::XPath.first(document, '/html/body/h1').text.should_equal 'Header'
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
end
|