BuildMaster 1.0.9 → 1.1.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.
Files changed (76) hide show
  1. data/lib/buildmaster/algorithms.rb +3 -0
  2. data/lib/buildmaster/algorithms/opn_compare.rb +108 -0
  3. data/lib/buildmaster/cotta/cotta_dir.rb +7 -4
  4. data/lib/buildmaster/cotta/cotta_file.rb +5 -2
  5. data/lib/buildmaster/cotta/in_memory_system.rb +28 -4
  6. data/lib/buildmaster/project/java.rb +4 -0
  7. data/lib/buildmaster/project/java/class_path.rb +0 -0
  8. data/lib/buildmaster/project/java/javac.rb +9 -0
  9. data/lib/buildmaster/project/mysql_served_driver.rb +15 -0
  10. data/lib/buildmaster/project/pscp_driver.rb +0 -1
  11. data/lib/buildmaster/project/svn_driver.rb +4 -4
  12. data/lib/buildmaster/project/svn_server_driver.rb +18 -0
  13. data/lib/buildmaster/project/svn_status_info.rb +45 -42
  14. data/lib/buildmaster/site/content_engine_repository.rb +9 -0
  15. data/lib/buildmaster/site/file_processor.rb +5 -1
  16. data/lib/buildmaster/site/site.rb +11 -4
  17. data/lib/buildmaster/site/site_server.rb +1 -1
  18. data/lib/buildmaster/site/templatelets/href.rb +1 -1
  19. data/lib/buildmaster/version +1 -1
  20. data/test/buildmaster/algorithms/tc_opn_compare.rb +44 -0
  21. data/test/buildmaster/common/tc_properties.rb +8 -8
  22. data/test/buildmaster/common/tc_tree_to_object.rb +8 -8
  23. data/test/buildmaster/cotta/cotta_dir_behaviors.rb +167 -0
  24. data/test/buildmaster/cotta/cotta_file_behaviors.rb +127 -0
  25. data/test/buildmaster/cotta/cotta_specifications.rb +20 -0
  26. data/test/buildmaster/cotta/file_system_behaviors.rb +167 -0
  27. data/test/buildmaster/cotta/tc_command_interface.rb +6 -6
  28. data/test/buildmaster/cotta/tc_command_runner.rb +5 -5
  29. data/test/buildmaster/cotta/tc_cotta.rb +12 -12
  30. data/test/buildmaster/cotta/tc_cotta_dir_in_memory.rb +17 -17
  31. data/test/buildmaster/cotta/tc_cotta_dir_physical.rb +5 -5
  32. data/test/buildmaster/cotta/tc_cotta_file_in_memory.rb +8 -9
  33. data/test/buildmaster/cotta/tc_cotta_file_physical.rb +11 -8
  34. data/test/buildmaster/cotta/tc_cotta_zip_support.rb +9 -9
  35. data/test/buildmaster/cotta/tc_in_memory_system.rb +7 -7
  36. data/test/buildmaster/cotta/tc_io_chain.rb +3 -3
  37. data/test/buildmaster/cotta/tc_pathname.rb +6 -6
  38. data/test/buildmaster/cotta/tc_physical_system.rb +7 -8
  39. data/test/buildmaster/project/tc_ant_driver.rb +8 -8
  40. data/test/buildmaster/project/tc_build_number_file.rb +5 -5
  41. data/test/buildmaster/project/tc_cvs_driver.rb +9 -9
  42. data/test/buildmaster/project/tc_java_manifest.rb +9 -11
  43. data/test/buildmaster/project/tc_release.rb +12 -12
  44. data/test/buildmaster/project/tc_server_manager.rb +8 -8
  45. data/test/buildmaster/project/tc_svn_driver.rb +18 -13
  46. data/test/buildmaster/project/tc_svn_status_info.rb +8 -8
  47. data/test/buildmaster/project/tc_version_number_file.rb +6 -6
  48. data/test/buildmaster/project/windows/tc_iis_driver.rb +4 -4
  49. data/test/buildmaster/project/windows/tc_sql_server_driver.rb +2 -2
  50. data/test/buildmaster/site/content/tc_content_engine_repository.rb +5 -5
  51. data/test/buildmaster/site/tc_element_processor_by_name.rb +4 -4
  52. data/test/buildmaster/site/tc_file_processor.rb +8 -9
  53. data/test/buildmaster/site/tc_site.rb +23 -7
  54. data/test/buildmaster/site/tc_site_server.rb +2 -2
  55. data/test/buildmaster/site/tc_site_spec.rb +5 -5
  56. data/test/buildmaster/site/tc_source_file_handler.rb +2 -2
  57. data/test/buildmaster/site/tc_template_builder.rb +22 -11
  58. data/test/buildmaster/site/tc_template_error.rb +2 -2
  59. data/test/buildmaster/site/tc_template_runner.rb +4 -4
  60. data/test/buildmaster/site/tc_templatelets.rb +4 -4
  61. data/test/buildmaster/site/tc_xtemplate.rb +5 -5
  62. data/test/buildmaster/site/templatelets/tc_attribute.rb +6 -6
  63. data/test/buildmaster/site/templatelets/tc_code.rb +10 -10
  64. data/test/buildmaster/site/templatelets/tc_each.rb +3 -3
  65. data/test/buildmaster/site/templatelets/tc_href.rb +7 -7
  66. data/test/buildmaster/site/templatelets/tc_include.rb +3 -3
  67. data/test/buildmaster/site/templatelets/tc_link.rb +6 -6
  68. data/test/buildmaster/site/templatelets/tc_text.rb +4 -4
  69. data/test/buildmaster/site/templatelets/tc_when.rb +4 -4
  70. data/test/tmp/svn_test/repository/db/revprops/0 +1 -1
  71. data/test/tmp/svn_test/repository/db/revprops/1 +1 -1
  72. data/test/tmp/svn_test/repository/db/revprops/2 +1 -1
  73. data/test/tmp/svn_test/repository/db/revprops/3 +1 -1
  74. data/test/tmp/svn_test/repository/db/revprops/4 +1 -1
  75. data/test/tmp/svn_test/repository/db/uuid +1 -1
  76. metadata +60 -46
@@ -9,6 +9,7 @@ class ContentEngineRepository
9
9
  @map['.markdown'] = MarkdownEngine.new
10
10
  @map['.html'] = HtmlEngine.new
11
11
  @map['.txt'] = TextileEngine.new
12
+ @map['.deplate'] = DeplateEngine.new
12
13
  end
13
14
 
14
15
  def supports?(extname)
@@ -80,4 +81,12 @@ class HtmlEngine
80
81
  return full_content
81
82
  end
82
83
  end
84
+
85
+ class DeplateEngine
86
+ include ContentEngine
87
+ def convert_to_html(full_content)
88
+ require 'deplate/deplate-string'
89
+ process_content_with_title(full_content) {|content| DeplateString.new(content).to_html}
90
+ end
91
+ end
83
92
  end
@@ -44,7 +44,11 @@ class FileProcessor
44
44
  html_content = @content_engine.convert_to_html(content_file.load)
45
45
  process_html(html_content)
46
46
  end
47
- end
47
+ end
48
+
49
+ def out_of_date?
50
+ (not @target_file.exists?) || @target_file.older_than?(@content_file)
51
+ end
48
52
 
49
53
  private
50
54
  def process_html(html_content)
@@ -91,15 +91,22 @@ require 'buildmaster/site_tester'
91
91
  build_directory(out_dir.dir(item.name), item, template)
92
92
  elsif (item.respond_to? 'read')
93
93
  @current_file_name = item
94
- process_file(item, out_dir, content_dir, item)
95
- @count = @count + 1
94
+ if(process_file(item, out_dir, content_dir, item))
95
+ @count = @count + 1
96
+ end
96
97
  end
97
98
  end
98
99
  end
99
100
 
100
101
  def process_file(content_file, out_dir, content_dir, item)
101
- print ">> #{content_file.path.to_s}\n"
102
- FileProcessor.new(@template, content_file, @spec).write_to_target
102
+ processor = FileProcessor.new(@template, content_file, @spec)
103
+ processed = nil
104
+ if (processor.out_of_date?)
105
+ print ">> #{content_file.path.to_s}\n"
106
+ processor.write_to_target
107
+ processed = true
108
+ end
109
+ processed
103
110
  end
104
111
 
105
112
  end
@@ -47,7 +47,7 @@ class SiteServer
47
47
  http.request(request)
48
48
  }
49
49
  puts "response: #{res}"
50
- rescue Errno::EBADF => e
50
+ rescue Errno::EBADF, Errno::ECONNREFUSED => e
51
51
  return false
52
52
  end
53
53
  return true
@@ -26,7 +26,7 @@ class Href
26
26
  if (not path.relative?)
27
27
  path = path.relative_path_from(Pathname.new('/'))
28
28
  end
29
- href = path.relative_path_from(current_path.parent)
29
+ href = path.relative_path_from(current_path.parent).to_s
30
30
  end
31
31
  return href
32
32
  end
@@ -1 +1 @@
1
- 1.0.9
1
+ 1.1.9
@@ -0,0 +1,44 @@
1
+ require 'spec'
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
4
+
5
+ require 'algorithms/opn_compare'
6
+
7
+ module BuildMaster
8
+ module Algorithms
9
+ describe NegativeIndexArray do
10
+ it 'index with negative number' do
11
+ array = NegativeIndexArray.new(5, 5) {|index| 'default'}
12
+ array[-5].should == 'default'
13
+ array[5].should == 'default'
14
+ array[5] = '+5'
15
+ array[-5] = '-5'
16
+ array[5].should == '+5'
17
+ array[-5].should == '-5'
18
+ (-4..4).each {|index| array[index].should == 'default'}
19
+ end
20
+
21
+ it 'default value' do
22
+ array = NegativeIndexArray.new(5, 5) {|index| index}
23
+ array[-1].should == -1
24
+ end
25
+ end
26
+
27
+ describe OpnCompare, 'O(pn) Compare Algorithm' do
28
+ it 'no diff' do
29
+ m = 'abcdefg'
30
+ n = 'abcdefg'
31
+ diff = OpnCompare.new(m, n).compare
32
+ # diff.should be_nil
33
+ end
34
+
35
+ it 'one character change' do
36
+ m = 'abfcde'
37
+ n = 'abcdef'
38
+ diff = OpnCompare.new(m, n).compare
39
+ # diff.should have(1).edits
40
+ # diff.edits[0].should == EditStep.new(EditAction.Add, 5)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -6,19 +6,19 @@ require 'common/properties'
6
6
 
7
7
  module BuildMaster::Common
8
8
 
9
- context 'Basic properties implementations' do
10
- specify 'parse io into hash' do
11
- content = <<CONTENT
9
+ describe Properties do
10
+ it 'parse io into hash' do
11
+ content = <<CONTENT
12
12
  one : 1
13
13
  two : 2
14
14
  three : 3
15
15
 
16
16
  CONTENT
17
- hash = Properties.parse_io(StringIO.new(content))
18
- hash.should_have_key('one')
19
- hash['one'].should == '1'
17
+ hash = Properties.parse_io(StringIO.new(content))
18
+ hash.should have_key('one')
19
+ hash['one'].should == '1'
20
+ end
21
+
20
22
  end
21
-
22
- end
23
23
 
24
24
  end
@@ -27,8 +27,8 @@ class SampleTwo
27
27
  attr_writer :field, :index
28
28
  end
29
29
 
30
- context 'TreeToObjectTest' do
31
- specify 'should_populate_string_fields' do
30
+ describe TreeToObject do
31
+ it 'should_populate_string_fields' do
32
32
  content = <<CONTENT
33
33
  field_one: value_one
34
34
  field_two: value_two
@@ -40,7 +40,7 @@ CONTENT
40
40
  object.field_two.should == 'value_two'
41
41
  end
42
42
 
43
- specify 'should_populate_array_fields' do
43
+ it 'should_populate_array_fields' do
44
44
  content = <<CONTENT
45
45
  array_field:
46
46
  - field: valueone
@@ -57,7 +57,7 @@ CONTENT
57
57
  array[1].index.to_s.should == '2'
58
58
  end
59
59
 
60
- specify 'should_populate_instance_fields' do
60
+ it 'should_populate_instance_fields' do
61
61
  content = <<CONTENT
62
62
  object_two:
63
63
  field: my_field
@@ -69,7 +69,7 @@ CONTENT
69
69
  actual.index.to_s.should == '5'
70
70
  end
71
71
 
72
- specify 'should_raise_error_if_property_not_found' do
72
+ it 'should_raise_error_if_property_not_found' do
73
73
  content = <<CONTENT
74
74
  not_field: value
75
75
  CONTENT
@@ -82,7 +82,7 @@ CONTENT
82
82
  end
83
83
  end
84
84
 
85
- specify 'should_raise_error_if_sub_property_not_found' do
85
+ it 'should_raise_error_if_sub_property_not_found' do
86
86
  content = <<CONTENT
87
87
  not_sub_property:
88
88
  field: value
@@ -96,7 +96,7 @@ CONTENT
96
96
  end
97
97
  end
98
98
 
99
- specify 'should_raise_error_if_array_property_not_found' do
99
+ it 'should_raise_error_if_array_property_not_found' do
100
100
  content = <<CONTENT
101
101
  not_array_property:
102
102
  - name: title
@@ -111,7 +111,7 @@ CONTENT
111
111
  end
112
112
  end
113
113
 
114
- specify 'empty_content' do
114
+ it 'empty_content' do
115
115
  object = TreeToObject.from_yaml('', SampleObject.new)
116
116
  object.field_one.should == nil
117
117
  end
@@ -0,0 +1,167 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
2
+
3
+ require 'cotta'
4
+ require 'cotta/cotta_file'
5
+ require 'cotta/cotta_dir'
6
+ require 'spec'
7
+ require 'pathname'
8
+
9
+ module BuildMaster
10
+ describe 'CottaDirBehaviors', :shared=>true do
11
+ before do
12
+ create_system
13
+ @dir = BuildMaster::CottaDir.new(@system, Pathname.new('dir'))
14
+ end
15
+
16
+ it 'load dir with basic information' do
17
+ @dir.name.should == 'dir'
18
+ end
19
+
20
+ it 'dir objects are value objects, equal on system and path' do
21
+ (BuildMaster::CottaDir.new(@system, Pathname.new('dir')) == @dir).should == true
22
+ end
23
+
24
+ it 'dir should not be equal if path different' do
25
+ (BuildMaster::CottaDir.new(@system, Pathname.new('/dir')) == @dir).should == false
26
+ end
27
+
28
+ it 'should support relative path' do
29
+ sub_dir = @dir.dir('one/two/three')
30
+ sub_dir.relative_path_from(@dir).to_s.should == 'one/two/three'
31
+ end
32
+
33
+ it 'dir should know its parent' do
34
+ @dir.parent.name.should == '.'
35
+ @dir.parent.parent.should be_nil
36
+ end
37
+
38
+ it 'should raise error if not exits stat' do
39
+ Proc.new {
40
+ @dir.stat
41
+ }.should raise_error(Errno::ENOENT)
42
+ end
43
+
44
+ it 'support stat' do
45
+ @dir.mkdirs
46
+ @dir.stat.should_not be_nil
47
+ end
48
+
49
+ it 'dir should handle root dir' do
50
+ dir = BuildMaster::CottaDir.new(@system, Pathname.new('/root'))
51
+ dir.parent.path.should == Pathname.new('/')
52
+ dir.parent.name.should == '/'
53
+ dir.parent.exists?.should == true
54
+ dir.parent.root?.should == true
55
+ dir.parent.parent.should be_nil
56
+ end
57
+
58
+ it 'dir should handle root dir for drive letters' do
59
+ dir = BuildMaster::CottaDir.new(@system, Pathname.new('C:/Windows'))
60
+ dir.name.should == 'Windows'
61
+ dir.parent.path.should == Pathname.new('C:/')
62
+ dir.parent.name.should == 'C:/'
63
+ end
64
+
65
+ it 'dir should return sub directory' do
66
+ @dir.dir('sub').path.should == Pathname.new('dir/sub')
67
+ @dir.dir('sub').parent.should == @dir
68
+ end
69
+
70
+ it 'dir should return a directory from a relative pathname' do
71
+ @dir.dir(Pathname.new('one/two/three')).should == @dir.dir('one').dir('two').dir('three')
72
+ end
73
+
74
+ it 'should get file in current directory' do
75
+ file = @dir.file('file.txt')
76
+ file.name.should == 'file.txt'
77
+ file.path.should == Pathname.new('dir/file.txt')
78
+ file.parent.should == @dir
79
+ end
80
+
81
+ it 'should create dir and its parent' do
82
+ dir = @dir.dir('one').dir('two')
83
+ dir.exists?.should == false
84
+ dir.parent.exists?.should == false
85
+ dir.mkdirs
86
+ dir.exists?.should == true
87
+ dir.parent.exists?.should == true
88
+ end
89
+
90
+ it 'should delete dir and its children' do
91
+ dir = @dir.dir('one').dir('two').dir('three')
92
+ dir.mkdirs
93
+ @dir.exists?.should == true
94
+ @dir.delete
95
+ dir.exists?.should == false
96
+ @dir.exists?.should == false
97
+ end
98
+
99
+ it 'should do nothing if dir already exists' do
100
+ dir = @dir.dir('one').dir('two')
101
+ dir.mkdirs
102
+ dir.mkdirs
103
+ end
104
+
105
+ it 'should list dirs' do
106
+ @dir.dir('one').mkdirs
107
+ @dir.file('one.txt').save
108
+ actual_dir_list = @dir.list
109
+ actual_dir_list.size.should == 2
110
+ actual_dir_list[0].name.should == 'one'
111
+ actual_dir_list[0].list.size.should == 0
112
+ actual_dir_list[1].name.should == 'one.txt'
113
+ actual_dir_list[1].save
114
+ end
115
+
116
+ it 'should move directory with its children' do
117
+ dir = BuildMaster::CottaDir.new(@system, Pathname.new('targetdir/child_dir'))
118
+ @dir.file('file.txt').save('file.txt')
119
+ @dir.dir('subdir').mkdirs
120
+ @dir.list.size.should == 2
121
+ @dir.move_to(dir)
122
+ @dir.exists?.should == false
123
+ dir.list.size.should == 2
124
+ dir.file('file.txt').load.should == 'file.txt'
125
+ dir.dir('subdir').exists?.should == true
126
+ end
127
+
128
+ it 'should copy directory with its children' do
129
+ dir = BuildMaster::CottaDir.new(@system, Pathname.new('targetdir/child_dir'))
130
+ @dir.file('file.txt').save('file.txt')
131
+ @dir.dir('subdir').mkdirs
132
+ @dir.list.size.should == 2
133
+ @dir.copy_to(dir)
134
+ @dir.exists?.should == true
135
+ dir.list.size.should == 2
136
+ dir.file('file.txt').load.should == 'file.txt'
137
+ dir.dir('subdir').exists?.should == true
138
+ end
139
+
140
+ it 'dir takes relative path' do
141
+ dir = BuildMaster::CottaDir.new(@system, Pathname.new('targetdir/dir'))
142
+ @dir.dir('one/two/three').mkdirs
143
+ @dir.dir('one').exists?.should == true
144
+ @dir.dir('one').dir('two').exists?.should == true
145
+ @dir.dir('one').dir('two').dir('three').exists?.should == true
146
+ end
147
+
148
+ it 'list on not existing directory' do
149
+ dir = BuildMaster::CottaDir.new(@system, Pathname.new('no/such/directory'))
150
+ Proc.new {
151
+ dir.list
152
+ }.should raise_error(Errno::ENOENT)
153
+ end
154
+
155
+ it 'allow filter for archive' do
156
+ @dir.file('in/in.txt').save('test')
157
+ @dir.file('out/out.txt').save('test')
158
+ result = @dir.archive {|entry|
159
+ entry.name != 'out'
160
+ }
161
+ target = result.extract(@dir.dir('extract'))
162
+ target.dir('out').should_not be_exist
163
+ target.dir('in').should be_exist
164
+ end
165
+
166
+ end
167
+ end
@@ -0,0 +1,127 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
2
+
3
+ require 'cotta'
4
+ require 'cotta/cotta_file'
5
+ require 'cotta/cotta_dir'
6
+ require 'cotta/in_memory_system'
7
+ require 'spec'
8
+ require 'pathname'
9
+
10
+ module BuildMaster
11
+ describe 'CottaFileBehaviors', :shared => true do
12
+ before do
13
+ create_system
14
+ @file = BuildMaster::CottaFile.new(@system, Pathname.new('dir/file.txt'))
15
+ end
16
+ it 'file can be created with system and pathname' do
17
+ @file.name.should == 'file.txt'
18
+ @file.path.should == Pathname.new('dir/file.txt')
19
+ @file.exists?.should == false
20
+ end
21
+
22
+ it 'file should know properties like parent, name, etc.' do
23
+ @file.parent.should == BuildMaster::CottaDir.new(@system, Pathname.new('dir'))
24
+ @file.name.should == 'file.txt'
25
+ @file.path.should == Pathname.new('dir/file.txt')
26
+ @file.extname.should == '.txt'
27
+ @file.basename.should == 'file'
28
+ end
29
+
30
+ it 'should support relative path' do
31
+ parent = @file.parent
32
+ file = parent.file('one/two/three.txt')
33
+ file.relative_path_from(parent).to_s.should == 'one/two/three.txt'
34
+ end
35
+
36
+ it 'file should support stat' do
37
+ @file.save('test')
38
+ @file.stat.should_not be_nil
39
+ @file.stat.size.should == 4
40
+ @file.stat.writable?.should == true
41
+ end
42
+
43
+ it 'should raise error if does not exist' do
44
+ Proc.new {
45
+ @file.stat
46
+ }.should raise_error(Errno::ENOENT)
47
+ end
48
+
49
+ it 'should load and save file content' do
50
+ @file.exists?.should == false
51
+ @file.parent.exists?.should == false
52
+ @file.save("content to save\nsecond line")
53
+ @file.exists?.should == true
54
+ @file.load.should ==("content to save\nsecond line")
55
+ end
56
+
57
+ it 'should open file to read' do
58
+ @file.save("one\ntwo")
59
+ @file.read do |file|
60
+ file.gets.should ==("one\n")
61
+ file.gets.should ==('two')
62
+ end
63
+ end
64
+
65
+ it 'should equal if same system and pathname' do
66
+ file2 = BuildMaster::CottaFile.new(@system, Pathname.new('dir/file.txt'))
67
+ file2.should == @file
68
+ end
69
+
70
+ it 'should copy to another file' do
71
+ file2 = BuildMaster::CottaFile.new(@system, Pathname.new('dir2/file.txt'))
72
+ file2.exists?.should == false
73
+ @file.save('my content')
74
+ @file.copy_to(file2)
75
+ file2.exists?.should == true
76
+ file2.load.should == 'my content'
77
+ end
78
+
79
+ it 'should move file' do
80
+ file2 = BuildMaster::CottaFile.new(@system, Pathname.new('dir2/file.txt'))
81
+ file2.exists?.should == false
82
+ @file.save('content')
83
+ @file.move_to(file2)
84
+ file2.exists?.should == true
85
+ file2.load.should == 'content'
86
+ @file.exists?.should == false
87
+ end
88
+
89
+ it 'should support foreach' do
90
+ @file.write do |file|
91
+ file.puts 'line one'
92
+ file.puts 'line two'
93
+ end
94
+ collected = Array.new
95
+ @file.foreach do |line|
96
+ collected.push line
97
+ end
98
+ collected.size.should == 2
99
+ collected[0].should == "line one\n"
100
+ collected[1].should == "line two\n"
101
+ end
102
+
103
+ it 'should delete file' do
104
+ @file.save
105
+ @file.exists?.should == true
106
+ @file.delete
107
+ @file.exists?.should == false
108
+ end
109
+
110
+ it 'should raise error if file to delete does not exist' do
111
+ lambda {
112
+ @file.delete
113
+ }.should raise_error(Errno::ENOENT)
114
+ end
115
+
116
+ it 'should check timestamp to see which one is older' do
117
+ @file.save
118
+ file2 = @file.parent.file('another.txt')
119
+ sleep 1
120
+ file2.save
121
+ file2.older_than?(@file).should == false
122
+ @file.older_than?(file2).should == true
123
+ end
124
+
125
+ end
126
+
127
+ end