BuildMaster 1.0.6 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/buildmaster/cotta/cotta.rb +5 -0
- data/lib/buildmaster/cotta/cotta_dir.rb +66 -21
- data/lib/buildmaster/cotta/cotta_file.rb +130 -23
- data/lib/buildmaster/cotta/in_memory_system.rb +47 -1
- data/lib/buildmaster/cotta/io_chain.rb +11 -0
- data/lib/buildmaster/cotta/physical_system.rb +9 -0
- data/lib/buildmaster/site/templatelets/code.rb +4 -2
- data/lib/buildmaster/version +1 -1
- data/test/buildmaster/cotta/cotta_specifications.rb +34 -0
- data/test/buildmaster/cotta/logo.gif +0 -0
- data/test/buildmaster/cotta/physical_system_stub.rb +8 -0
- data/test/buildmaster/cotta/tar_test.tar +0 -0
- data/test/buildmaster/cotta/tc_cotta_file_physical.rb +28 -1
- data/test/buildmaster/cotta/tc_cotta_zip_support.rb +57 -0
- data/test/buildmaster/cotta/tc_io_chain.rb +33 -0
- data/test/buildmaster/cotta/ts_cotta.rb +4 -0
- data/test/buildmaster/site/templatelets/tc_code.rb +27 -1
- data/test/tmp/svn_test/repository/db/revprops/0 +1 -1
- data/test/tmp/svn_test/repository/db/revprops/1 +1 -1
- data/test/tmp/svn_test/repository/db/revprops/2 +1 -1
- data/test/tmp/svn_test/repository/db/revprops/3 +1 -1
- data/test/tmp/svn_test/repository/db/revprops/4 +1 -1
- data/test/tmp/svn_test/repository/db/uuid +1 -1
- metadata +11 -6
- data/lib/buildmaster/project/build.rb +0 -3
@@ -48,9 +48,14 @@ class Cotta
|
|
48
48
|
return Cotta.new.file(File.expand_path(path))
|
49
49
|
end
|
50
50
|
|
51
|
+
# DEPRECATED! Use +parent_dir+ instead.
|
51
52
|
def Cotta::parent_of(path)
|
52
53
|
return Cotta.file(path).parent
|
53
54
|
end
|
55
|
+
|
56
|
+
def Cotta::parent_dir(path)
|
57
|
+
return Cotta.file(path).parent
|
58
|
+
end
|
54
59
|
|
55
60
|
def entry(path)
|
56
61
|
entry = file(path)
|
@@ -1,9 +1,13 @@
|
|
1
|
+
require 'rubygems/package'
|
2
|
+
|
1
3
|
$:.unshift File.dirname(__FILE__)
|
2
4
|
|
3
5
|
require 'cotta_file'
|
6
|
+
require 'io_chain'
|
4
7
|
|
5
8
|
module BuildMaster
|
6
9
|
class CottaDir
|
10
|
+
include IoChain
|
7
11
|
attr_reader :path, :system
|
8
12
|
|
9
13
|
def initialize(system, path)
|
@@ -11,11 +15,11 @@ class CottaDir
|
|
11
15
|
@system = system
|
12
16
|
@name = @path.basename.to_s
|
13
17
|
end
|
14
|
-
|
18
|
+
|
15
19
|
def cotta
|
16
|
-
|
20
|
+
Cotta.new(@system)
|
17
21
|
end
|
18
|
-
|
22
|
+
|
19
23
|
def name
|
20
24
|
name = nil
|
21
25
|
if root?
|
@@ -25,59 +29,100 @@ class CottaDir
|
|
25
29
|
end
|
26
30
|
return name
|
27
31
|
end
|
28
|
-
|
32
|
+
|
29
33
|
def root?
|
30
34
|
parent.nil?
|
31
35
|
end
|
32
|
-
|
36
|
+
|
33
37
|
def exists?
|
34
38
|
return @system.dir_exists?(@path)
|
35
39
|
end
|
36
|
-
|
40
|
+
|
41
|
+
def stat
|
42
|
+
@system.dir_stat(@path)
|
43
|
+
end
|
44
|
+
|
37
45
|
def parent
|
38
46
|
parent_path = @path.cotta_parent
|
39
47
|
return nil unless parent_path
|
40
48
|
return CottaDir.new(@system, parent_path)
|
41
49
|
end
|
42
|
-
|
50
|
+
|
51
|
+
def relative_path_from(entry)
|
52
|
+
@path.relative_path_from(entry.path)
|
53
|
+
end
|
54
|
+
|
43
55
|
def dir(name)
|
44
56
|
return CottaDir.new(@system, @path.join(name))
|
45
57
|
end
|
46
|
-
|
58
|
+
|
47
59
|
def file(name)
|
48
60
|
return CottaFile.new(@system, @path.join(name))
|
49
61
|
end
|
50
|
-
|
62
|
+
|
51
63
|
def mkdirs
|
52
64
|
if (not exists?)
|
53
65
|
parent.mkdirs
|
54
66
|
@system.mkdir @path
|
55
67
|
end
|
56
68
|
end
|
57
|
-
|
69
|
+
|
58
70
|
def delete
|
59
|
-
list.each {|children|
|
71
|
+
list.each {|children|
|
72
|
+
children.delete
|
73
|
+
}
|
60
74
|
@system.delete_dir(@path)
|
61
75
|
end
|
62
|
-
|
76
|
+
|
63
77
|
def move_to(target)
|
64
78
|
target.parent.mkdirs
|
65
79
|
@system.move_dir(@path, target.path)
|
66
80
|
end
|
67
|
-
|
81
|
+
|
68
82
|
def move_to_path(target_path)
|
69
83
|
move_to(cotta.dir(target_path))
|
70
84
|
end
|
71
|
-
|
85
|
+
|
72
86
|
def copy_to(target)
|
73
87
|
target.parent.mkdirs
|
74
88
|
@system.copy_dir(@path, target.path)
|
75
89
|
end
|
76
|
-
|
90
|
+
|
91
|
+
def archive(target = nil)
|
92
|
+
unless target
|
93
|
+
target = parent.file("#{name}.tar")
|
94
|
+
end
|
95
|
+
target.write_binary do |io|
|
96
|
+
writer = Gem::Package::TarWriter.new(io) do |tar_io|
|
97
|
+
archive_dir(tar_io, self)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
target
|
101
|
+
end
|
102
|
+
|
103
|
+
def archive_dir(tar_io, dir)
|
104
|
+
dir.list.each do |child|
|
105
|
+
stat = child.stat
|
106
|
+
entry_name = child.relative_path_from(self).to_s
|
107
|
+
mode = stat.mode
|
108
|
+
if (stat.file?)
|
109
|
+
tar_io.add_file(entry_name, mode) do |entry_output|
|
110
|
+
child.read_binary do |input|
|
111
|
+
copy_io(input, entry_output)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
elsif (stat.directory?)
|
115
|
+
tar_io.mkdir(entry_name, mode)
|
116
|
+
archive_dir(tar_io, child)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
private :archive_dir
|
121
|
+
|
77
122
|
def copy_to_path(target_path)
|
78
123
|
copy_to(cotta.dir(target_path))
|
79
124
|
end
|
80
|
-
|
125
|
+
|
81
126
|
def list
|
82
127
|
@system.list(@path).collect do |item|
|
83
128
|
candidate = dir(item)
|
@@ -87,18 +132,18 @@ class CottaDir
|
|
87
132
|
candidate
|
88
133
|
end
|
89
134
|
end
|
90
|
-
|
135
|
+
|
91
136
|
def ==(other)
|
92
137
|
return @path == other.path && @system == other.system
|
93
138
|
end
|
94
|
-
|
139
|
+
|
95
140
|
def inspect
|
96
|
-
return "#{self.class}:#{self.object_id}
|
141
|
+
return "#{self.class}:#{self.object_id}-#@path"
|
97
142
|
end
|
98
|
-
|
143
|
+
|
99
144
|
def to_s
|
100
145
|
@path
|
101
146
|
end
|
102
|
-
|
147
|
+
|
103
148
|
end
|
104
149
|
end
|
@@ -1,26 +1,27 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'rubygems/package'
|
3
|
+
|
4
|
+
$:.unshift File.dirname(__FILE__)
|
5
|
+
require 'io_chain'
|
2
6
|
|
3
7
|
module BuildMaster
|
4
8
|
class CottaFile
|
9
|
+
include IoChain
|
5
10
|
attr_reader :system, :path
|
6
11
|
|
7
12
|
def initialize(system, path)
|
8
13
|
@path = path
|
9
14
|
@system = system
|
10
15
|
end
|
11
|
-
|
16
|
+
|
12
17
|
def cotta
|
13
|
-
|
18
|
+
Cotta.new(@system)
|
14
19
|
end
|
15
|
-
|
20
|
+
|
16
21
|
def name
|
17
22
|
return @path.basename.to_s
|
18
23
|
end
|
19
24
|
|
20
|
-
def parent
|
21
|
-
return CottaDir.new(@system, @path.parent)
|
22
|
-
end
|
23
|
-
|
24
25
|
def extname
|
25
26
|
return @path.extname
|
26
27
|
end
|
@@ -29,13 +30,26 @@ class CottaFile
|
|
29
30
|
return @path.basename(extname).to_s
|
30
31
|
end
|
31
32
|
|
33
|
+
def stat
|
34
|
+
@system.file_stat(@path)
|
35
|
+
end
|
36
|
+
|
32
37
|
def exists?
|
33
38
|
return @system.file_exists?(@path)
|
34
39
|
end
|
40
|
+
|
41
|
+
def relative_path_from(file_or_dir)
|
42
|
+
path.relative_path_from(file_or_dir.path)
|
43
|
+
end
|
44
|
+
|
45
|
+
def parent
|
46
|
+
return CottaDir.new(@system, @path.parent)
|
47
|
+
end
|
35
48
|
|
36
49
|
def copy_to(target_file)
|
37
50
|
target_file.parent.mkdirs
|
38
51
|
@system.copy_file(path, target_file.path)
|
52
|
+
target_file
|
39
53
|
end
|
40
54
|
|
41
55
|
def copy_to_path(target_path)
|
@@ -55,20 +69,69 @@ class CottaFile
|
|
55
69
|
write {|file| file.printf content.to_s}
|
56
70
|
end
|
57
71
|
|
72
|
+
# Calls open with 'w' argument and makes sure that the
|
73
|
+
# parent directory of the file exists
|
58
74
|
def write(&block)
|
59
75
|
parent.mkdirs
|
60
76
|
open('w', &block)
|
61
77
|
end
|
62
|
-
|
78
|
+
|
79
|
+
# Calls open with 'a' argument and make sure that the
|
80
|
+
# parent directory of the file exists
|
81
|
+
def append(&block)
|
82
|
+
parent.mkdirs
|
83
|
+
open('a', &block)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Calls open with 'wb' argument, sets the io to binmode
|
87
|
+
# and make sure that the parent directory of the file exists
|
88
|
+
def write_binary(&block)
|
89
|
+
parent.mkdirs
|
90
|
+
if (block_given?)
|
91
|
+
open('wb') do |io|
|
92
|
+
io.binmode
|
93
|
+
yield io
|
94
|
+
end
|
95
|
+
else
|
96
|
+
io = open('wb')
|
97
|
+
io.binmode
|
98
|
+
io
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
=begin rdoc
|
103
|
+
Loading the file full total. This is used generally for loading
|
104
|
+
an ascii file content. It does not work with binary file on
|
105
|
+
windows system because it does no put the system on binary mode
|
106
|
+
=end
|
63
107
|
def load
|
64
108
|
content = nil
|
65
|
-
|
109
|
+
size = stat.size
|
110
|
+
read do |io|
|
111
|
+
content = io.read
|
112
|
+
end
|
66
113
|
return content
|
67
114
|
end
|
68
115
|
|
116
|
+
# calls open with 'r' as argument.
|
69
117
|
def read(&block)
|
70
118
|
open('r', &block)
|
71
119
|
end
|
120
|
+
|
121
|
+
# Calls open with 'r' as argument and sets the io to binary mode
|
122
|
+
def read_binary
|
123
|
+
if block_given?
|
124
|
+
open('r') do |io|
|
125
|
+
io.binmode
|
126
|
+
yield io
|
127
|
+
end
|
128
|
+
else
|
129
|
+
io = open('r')
|
130
|
+
io.binmode
|
131
|
+
io
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
72
135
|
|
73
136
|
def foreach()
|
74
137
|
open('r') do |file|
|
@@ -76,10 +139,68 @@ class CottaFile
|
|
76
139
|
end
|
77
140
|
end
|
78
141
|
|
142
|
+
def open(*args)
|
143
|
+
result = f = @system.io(@path, *args)
|
144
|
+
if block_given?
|
145
|
+
begin
|
146
|
+
result = yield f
|
147
|
+
ensure
|
148
|
+
f.close unless f.closed?
|
149
|
+
end
|
150
|
+
end
|
151
|
+
result
|
152
|
+
end
|
153
|
+
|
79
154
|
def delete
|
80
155
|
@system.delete_file(@path)
|
81
156
|
end
|
82
157
|
|
158
|
+
def extract(directory = nil)
|
159
|
+
directory = parent.dir(basename) unless directory
|
160
|
+
read_binary do |io|
|
161
|
+
reader = Gem::Package::TarReader.new(io)
|
162
|
+
reader.each do |entry|
|
163
|
+
full_name = entry.full_name
|
164
|
+
if (entry.is_file?)
|
165
|
+
directory.file(full_name).write_binary do |output|
|
166
|
+
copy_io(entry, output)
|
167
|
+
end
|
168
|
+
elsif (entry.is_directory?)
|
169
|
+
directory.dir(full_name).mkdirs
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
directory
|
174
|
+
end
|
175
|
+
|
176
|
+
def zip(target = nil)
|
177
|
+
target = parent.file("#{name}.zip") unless target
|
178
|
+
read_binary do |read_io|
|
179
|
+
target.write_binary do |write_io|
|
180
|
+
gz = Zlib::GzipWriter.new(write_io)
|
181
|
+
copy_io(read_io, gz)
|
182
|
+
gz.close
|
183
|
+
end
|
184
|
+
end
|
185
|
+
target
|
186
|
+
end
|
187
|
+
|
188
|
+
def unzip
|
189
|
+
name = basename
|
190
|
+
if (extname.length == 0)
|
191
|
+
name = "#{name}.unzip"
|
192
|
+
end
|
193
|
+
target = parent.file(name)
|
194
|
+
read_binary do |read_io|
|
195
|
+
target.write_binary do |write_io|
|
196
|
+
gz = Zlib::GzipReader.new(read_io)
|
197
|
+
copy_io(gz, write_io)
|
198
|
+
gz.close
|
199
|
+
end
|
200
|
+
end
|
201
|
+
target
|
202
|
+
end
|
203
|
+
|
83
204
|
def ==(other)
|
84
205
|
return false unless other.kind_of? CottaFile
|
85
206
|
return @system == other.system && @path == other.path
|
@@ -93,19 +214,5 @@ class CottaFile
|
|
93
214
|
return "#{self.class}:#{self.object_id}-#{@system.inspect}-#@path"
|
94
215
|
end
|
95
216
|
|
96
|
-
private
|
97
|
-
|
98
|
-
def open(*args)
|
99
|
-
result = f = @system.io(@path, *args)
|
100
|
-
if block_given?
|
101
|
-
begin
|
102
|
-
result = yield f
|
103
|
-
ensure
|
104
|
-
f.close
|
105
|
-
end
|
106
|
-
end
|
107
|
-
return result
|
108
|
-
end
|
109
|
-
|
110
217
|
end
|
111
218
|
end
|
@@ -43,10 +43,29 @@ class InMemorySystem
|
|
43
43
|
return !content.nil? && content.file?
|
44
44
|
end
|
45
45
|
|
46
|
+
def dir_stat(pathname)
|
47
|
+
check_dir_exists(pathname)
|
48
|
+
ContentStat.new(path_content(pathname))
|
49
|
+
end
|
50
|
+
|
51
|
+
def file_stat(pathname)
|
52
|
+
check_file_exists(pathname)
|
53
|
+
ContentStat.new(path_content(pathname))
|
54
|
+
end
|
55
|
+
|
46
56
|
def list(pathname)
|
57
|
+
check_dir_exists(pathname)
|
47
58
|
content = path_content(pathname)
|
48
59
|
return content.children.collect {|item| item.name}
|
49
60
|
end
|
61
|
+
|
62
|
+
def check_dir_exists(pathname)
|
63
|
+
raise Errno::ENOENT, pathname unless dir_exists? pathname
|
64
|
+
end
|
65
|
+
|
66
|
+
def check_file_exists(pathname)
|
67
|
+
raise Errno::ENOENT, pathname unless file_exists? pathname
|
68
|
+
end
|
50
69
|
|
51
70
|
def mkdir(pathname)
|
52
71
|
path_content!(pathname.cotta_parent).add(create_dir(pathname))
|
@@ -76,6 +95,7 @@ class InMemorySystem
|
|
76
95
|
end
|
77
96
|
|
78
97
|
def copy_dir(source, target)
|
98
|
+
check_dir_exists(source)
|
79
99
|
mkdir(target)
|
80
100
|
path_content(source).children.each do |item|
|
81
101
|
item.copy_to_dir(self, source, target)
|
@@ -205,10 +225,36 @@ class FileContent
|
|
205
225
|
return false
|
206
226
|
end
|
207
227
|
|
228
|
+
def size
|
229
|
+
content.size
|
230
|
+
end
|
231
|
+
|
208
232
|
def copy_to_dir(system, parent_dir, target_dir)
|
209
233
|
target_path = target_dir.join(name)
|
210
234
|
source_path = parent_dir.join(name)
|
211
235
|
system.copy_file(source_path, target_path)
|
212
236
|
end
|
213
|
-
end
|
237
|
+
end
|
238
|
+
|
239
|
+
class ContentStat
|
240
|
+
def initialize(content)
|
241
|
+
@content = content
|
242
|
+
end
|
243
|
+
|
244
|
+
def mode
|
245
|
+
'10777'
|
246
|
+
end
|
247
|
+
|
248
|
+
def size
|
249
|
+
@content.size
|
250
|
+
end
|
251
|
+
|
252
|
+
def file?
|
253
|
+
@content.file?
|
254
|
+
end
|
255
|
+
|
256
|
+
def directory?
|
257
|
+
@content.directory?
|
258
|
+
end
|
259
|
+
end
|
214
260
|
end
|
@@ -35,6 +35,14 @@ class PhysicalSystem
|
|
35
35
|
return FileTest.file?(file_path)
|
36
36
|
end
|
37
37
|
|
38
|
+
def dir_stat(path)
|
39
|
+
File.stat(path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def file_stat(path)
|
43
|
+
File.stat(path)
|
44
|
+
end
|
45
|
+
|
38
46
|
def list(dir_path)
|
39
47
|
Dir.entries(dir_path).find_all {|item| item != '.' && item != '..'}
|
40
48
|
end
|
@@ -70,5 +78,6 @@ class PhysicalSystem
|
|
70
78
|
def move_dir(source, target)
|
71
79
|
FileUtils.mv(source, target)
|
72
80
|
end
|
81
|
+
|
73
82
|
end
|
74
83
|
end
|
@@ -48,10 +48,12 @@ require 'syntax/convertors/html'
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
raise TemplateError, "START #{tag} and END #{tag} not found" if lines.length == 0
|
51
|
-
|
51
|
+
line_with_minimum_indent = lines.select{|line| line.indentation}.min
|
52
|
+
minimum_indent = 0
|
53
|
+
minimum_indent = line_with_minimum_indent.indentation if line_with_minimum_indent
|
52
54
|
text = ''
|
53
55
|
lines.each do |line|
|
54
|
-
text << line.indent(
|
56
|
+
text << line.indent(minimum_indent)
|
55
57
|
end
|
56
58
|
return text
|
57
59
|
end
|
data/lib/buildmaster/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.9
|
@@ -27,6 +27,21 @@ def register_cotta_file_specifications
|
|
27
27
|
@file.extname.should == '.txt'
|
28
28
|
@file.basename.should == 'file'
|
29
29
|
end
|
30
|
+
|
31
|
+
specify 'should support relative path' do
|
32
|
+
parent = @file.parent
|
33
|
+
file = parent.file('one/two/three.txt')
|
34
|
+
file.relative_path_from(parent).to_s.should == 'one/two/three.txt'
|
35
|
+
end
|
36
|
+
|
37
|
+
specify 'file should support stat' do
|
38
|
+
@file.save('test')
|
39
|
+
@file.stat.should_not_be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
specify 'should raise error if does not exist' do
|
43
|
+
Proc.new {@file.stat}.should_raise Errno::ENOENT
|
44
|
+
end
|
30
45
|
|
31
46
|
specify 'should load and save file content' do
|
32
47
|
@file.exists?.should == false
|
@@ -111,12 +126,26 @@ def register_cotta_dir_specifications
|
|
111
126
|
specify 'dir should not be equal if path different' do
|
112
127
|
(BuildMaster::CottaDir.new(@system, Pathname.new('/dir')) == @dir).should == false
|
113
128
|
end
|
129
|
+
|
130
|
+
specify 'should support relative path' do
|
131
|
+
sub_dir = @dir.dir('one/two/three')
|
132
|
+
sub_dir.relative_path_from(@dir).to_s.should == 'one/two/three'
|
133
|
+
end
|
114
134
|
|
115
135
|
specify 'dir should know its parent' do
|
116
136
|
@dir.parent.name.should == '.'
|
117
137
|
@dir.parent.parent.should_be nil
|
118
138
|
end
|
119
139
|
|
140
|
+
specify 'should raise error if not exits stat' do
|
141
|
+
Proc.new {@dir.stat}.should_raise Errno::ENOENT
|
142
|
+
end
|
143
|
+
|
144
|
+
specify 'support stat' do
|
145
|
+
@dir.mkdirs
|
146
|
+
@dir.stat.should_not_be_nil
|
147
|
+
end
|
148
|
+
|
120
149
|
specify 'dir should handle root dir' do
|
121
150
|
dir = BuildMaster::CottaDir.new(@system, Pathname.new('/root'))
|
122
151
|
dir.parent.path.should == Pathname.new('/')
|
@@ -216,6 +245,11 @@ def register_cotta_dir_specifications
|
|
216
245
|
@dir.dir('one').dir('two').dir('three').exists?.should == true
|
217
246
|
end
|
218
247
|
|
248
|
+
specify 'list on not existing directory' do
|
249
|
+
dir = BuildMaster::CottaDir.new(@system, Pathname.new('no/such/directory'))
|
250
|
+
Proc.new {dir.list}.should_raise Errno::ENOENT
|
251
|
+
end
|
252
|
+
|
219
253
|
end
|
220
254
|
|
221
255
|
end
|
Binary file
|
@@ -27,6 +27,14 @@ class PhysicalSystemStub
|
|
27
27
|
@system.file_exists?(relative_from_tmp(pathname))
|
28
28
|
end
|
29
29
|
|
30
|
+
def dir_stat(pathname)
|
31
|
+
@system.dir_stat(relative_from_tmp(pathname))
|
32
|
+
end
|
33
|
+
|
34
|
+
def file_stat(pathname)
|
35
|
+
@system.file_stat(relative_from_tmp(pathname))
|
36
|
+
end
|
37
|
+
|
30
38
|
def list(pathname)
|
31
39
|
@system.list(relative_from_tmp(pathname))
|
32
40
|
end
|
Binary file
|
@@ -5,7 +5,7 @@ require 'cotta_specifications'
|
|
5
5
|
require 'physical_system_stub'
|
6
6
|
|
7
7
|
module BuildMaster
|
8
|
-
context 'Cotta file' do
|
8
|
+
context 'Cotta file with physical systeme' do
|
9
9
|
extend CottaSpecifications
|
10
10
|
setup do
|
11
11
|
@system = PhysicalSystemStub.new
|
@@ -13,5 +13,32 @@ context 'Cotta file' do
|
|
13
13
|
|
14
14
|
register_cotta_file_specifications
|
15
15
|
|
16
|
+
specify 'copying binary files properly' do
|
17
|
+
logo_gif = Cotta.parent_of(__FILE__).file('logo.gif')
|
18
|
+
content = logo_gif.read_binary {|io| io.read}
|
19
|
+
target = CottaFile.new(@system, Pathname.new('dir/logo.gif'))
|
20
|
+
target.parent.mkdirs
|
21
|
+
target.write_binary do |io|
|
22
|
+
io.write content
|
23
|
+
end
|
24
|
+
expected_stat = logo_gif.stat
|
25
|
+
actual_stat = target.stat
|
26
|
+
actual_stat.size.should == expected_stat.size
|
27
|
+
end
|
28
|
+
|
29
|
+
specify 'zip and unzip' do
|
30
|
+
logo_gif = Cotta.parent_of(__FILE__).file('logo.gif')
|
31
|
+
content = logo_gif.read_binary {|io| io.read}
|
32
|
+
dir = CottaDir.new(@system, Pathname.new('dir'))
|
33
|
+
target_dir = dir.dir('target')
|
34
|
+
target_dir.file(logo_gif.name).write_binary {|io| io.write content}
|
35
|
+
zip_file = target_dir.archive.zip
|
36
|
+
extract_dir = dir.dir('extract')
|
37
|
+
file_to_unzip = zip_file.copy_to(extract_dir.file(zip_file.name))
|
38
|
+
extracted_dir = file_to_unzip.unzip.extract
|
39
|
+
|
40
|
+
extracted_dir.file('logo.gif').stat.size.should == logo_gif.stat.size
|
41
|
+
end
|
42
|
+
|
16
43
|
end
|
17
44
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec'
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
|
4
|
+
|
5
|
+
require 'cotta'
|
6
|
+
require 'cotta/in_memory_system'
|
7
|
+
|
8
|
+
module BuildMaster
|
9
|
+
context 'zip support in cotta' do
|
10
|
+
setup do
|
11
|
+
@cotta = Cotta.new(InMemorySystem.new)
|
12
|
+
end
|
13
|
+
|
14
|
+
specify 'extract from a tar file' do
|
15
|
+
tar_file = Cotta.parent_of(__FILE__).file('tar_test.tar')
|
16
|
+
dir = @cotta.dir('dir/extract')
|
17
|
+
tar_file.extract(dir)
|
18
|
+
dir.list.size.should == 3
|
19
|
+
dir.file('one.txt').load.should == 'one'
|
20
|
+
dir.file('two.txt').load.should == 'two'
|
21
|
+
dir.file('three.txt').load.should == 'three'
|
22
|
+
end
|
23
|
+
|
24
|
+
specify 'archive files in the directory to a file' do
|
25
|
+
source = @cotta.dir('dir/source')
|
26
|
+
source.file('one.txt').save('one')
|
27
|
+
source.file('two.txt').save('two')
|
28
|
+
source.file('three.txt').save('three')
|
29
|
+
tar_file = @cotta.file('target.tar')
|
30
|
+
source.archive(tar_file)
|
31
|
+
|
32
|
+
target_dir = @cotta.dir('target')
|
33
|
+
tar_file.extract(target_dir)
|
34
|
+
target_dir.should_have(3).list
|
35
|
+
target_dir.file('one.txt').load.should == 'one'
|
36
|
+
target_dir.file('two.txt').load.should == 'two'
|
37
|
+
target_dir.file('three.txt').load.should == 'three'
|
38
|
+
end
|
39
|
+
|
40
|
+
specify 'archive subdirectories' do
|
41
|
+
source = @cotta.dir('dir/source')
|
42
|
+
sub = source.dir('sub')
|
43
|
+
sub.file('one.txt').save('one')
|
44
|
+
sub.file('two.txt').save('two')
|
45
|
+
tar_file = @cotta.file('target.tar')
|
46
|
+
source.archive(tar_file)
|
47
|
+
|
48
|
+
target_dir = @cotta.dir('target')
|
49
|
+
tar_file.extract(target_dir)
|
50
|
+
target_dir.should_have(1).list
|
51
|
+
target_dir.dir('sub').should_exists
|
52
|
+
target_dir.dir('sub').should_have(2).list
|
53
|
+
target_dir.file('sub/one.txt').load.should == 'one'
|
54
|
+
target_dir.file('sub/two.txt').load.should == 'two'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec'
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
|
4
|
+
|
5
|
+
require 'cotta/io_chain'
|
6
|
+
require 'cotta'
|
7
|
+
|
8
|
+
$:.unshift File.dirname(__FILE__)
|
9
|
+
require 'physical_system_stub'
|
10
|
+
|
11
|
+
module BuildMaster
|
12
|
+
module IoChain
|
13
|
+
context 'io chain' do
|
14
|
+
include IoChain
|
15
|
+
setup do
|
16
|
+
@cotta = Cotta.new(PhysicalSystemStub.new)
|
17
|
+
end
|
18
|
+
|
19
|
+
specify 'copy binary io' do
|
20
|
+
file = Cotta.parent_of(__FILE__).file('logo.gif')
|
21
|
+
target = @cotta.file('target.gif')
|
22
|
+
file.read_binary do |input|
|
23
|
+
target.write_binary do |output|
|
24
|
+
copy_io(input, output)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
expect_stat = file.stat
|
28
|
+
actual_stat = target.stat
|
29
|
+
actual_stat.size.should == expect_stat.size
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -42,7 +42,33 @@ root = cotta.file(__FILE__).parent
|
|
42
42
|
# BuildMaster can look into svn files to figure out the svn information
|
43
43
|
CONTENT
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
|
+
specify 'handle the case of only blank lines' do
|
47
|
+
template_content = <<CONTENT
|
48
|
+
<html>
|
49
|
+
<code source="samples/sample.rb" tag="sample"/>
|
50
|
+
</html>
|
51
|
+
CONTENT
|
52
|
+
content_path = 'doc/doc.html'
|
53
|
+
@cotta.file(content_path).parent.file('samples/sample.rb').save <<CONTENT
|
54
|
+
#START sample
|
55
|
+
|
56
|
+
|
57
|
+
#END sample
|
58
|
+
CONTENT
|
59
|
+
target = create_element('test')
|
60
|
+
template = create_template_element(template_content, '/html/code')
|
61
|
+
site_spec = SiteSpec.new('/root', @cotta);
|
62
|
+
code_processor = Code.new(site_spec)
|
63
|
+
code_processor.process(target, template, SourceContent.new('doc/doc.html', nil, @cotta.file(content_path)))
|
64
|
+
REXML::XPath.first(target, 'pre').attributes['class'].should == 'code'
|
65
|
+
REXML::XPath.first(target, 'pre').text.should == <<CONTENT
|
66
|
+
|
67
|
+
|
68
|
+
CONTENT
|
69
|
+
end
|
70
|
+
|
71
|
+
|
46
72
|
specify 'generate error if none found' do
|
47
73
|
template_content = <<CONTENT
|
48
74
|
<html>
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
a576fdff-2425-4247-8608-1a231a07b88f
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
2
|
+
rubygems_version: 0.9.0.9
|
3
3
|
specification_version: 1
|
4
4
|
name: BuildMaster
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date:
|
8
|
-
summary: A project that hosts a series of scripts to be used
|
6
|
+
version: 1.0.9
|
7
|
+
date: 2007-01-15 00:00:00 -08:00
|
8
|
+
summary: A project that hosts a series of scripts to be used for project release and depolyment, static website building, and file operations.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: buildmaster@googlegroups.com
|
12
12
|
homepage: http://buildmaster.rubyforge.org/
|
13
13
|
rubyforge_project: buildmaster
|
14
14
|
description:
|
15
|
-
autorequire: buildmaster
|
15
|
+
autorequire: buildmaster/cotta
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
18
|
has_rdoc: true
|
@@ -55,9 +55,9 @@ files:
|
|
55
55
|
- lib/buildmaster/cotta/cotta_pathname.rb
|
56
56
|
- lib/buildmaster/cotta/file_not_found_error.rb
|
57
57
|
- lib/buildmaster/cotta/in_memory_system.rb
|
58
|
+
- lib/buildmaster/cotta/io_chain.rb
|
58
59
|
- lib/buildmaster/cotta/physical_system.rb
|
59
60
|
- lib/buildmaster/project/ant_driver.rb
|
60
|
-
- lib/buildmaster/project/build.rb
|
61
61
|
- lib/buildmaster/project/build_number_file.rb
|
62
62
|
- lib/buildmaster/project/ci.rb
|
63
63
|
- lib/buildmaster/project/cvs_driver.rb
|
@@ -134,8 +134,10 @@ files:
|
|
134
134
|
- test/buildmaster/common/tc_tree_to_object.rb
|
135
135
|
- test/buildmaster/cotta/content.txt
|
136
136
|
- test/buildmaster/cotta/cotta_specifications.rb
|
137
|
+
- test/buildmaster/cotta/logo.gif
|
137
138
|
- test/buildmaster/cotta/physical_system_stub.rb
|
138
139
|
- test/buildmaster/cotta/system_file_specifications.rb
|
140
|
+
- test/buildmaster/cotta/tar_test.tar
|
139
141
|
- test/buildmaster/cotta/tc_command_interface.rb
|
140
142
|
- test/buildmaster/cotta/tc_command_runner.rb
|
141
143
|
- test/buildmaster/cotta/tc_cotta.rb
|
@@ -143,9 +145,12 @@ files:
|
|
143
145
|
- test/buildmaster/cotta/tc_cotta_dir_physical.rb
|
144
146
|
- test/buildmaster/cotta/tc_cotta_file_in_memory.rb
|
145
147
|
- test/buildmaster/cotta/tc_cotta_file_physical.rb
|
148
|
+
- test/buildmaster/cotta/tc_cotta_zip_support.rb
|
146
149
|
- test/buildmaster/cotta/tc_in_memory_system.rb
|
150
|
+
- test/buildmaster/cotta/tc_io_chain.rb
|
147
151
|
- test/buildmaster/cotta/tc_pathname.rb
|
148
152
|
- test/buildmaster/cotta/tc_physical_system.rb
|
153
|
+
- test/buildmaster/cotta/ts_cotta.rb
|
149
154
|
- test/buildmaster/project/build.xml
|
150
155
|
- test/buildmaster/project/manifest.mf
|
151
156
|
- test/buildmaster/project/tc_ant_driver.rb
|