ascii_binder_gabriel_rh 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +56 -0
  3. data/Dockerfile +19 -0
  4. data/Gemfile +3 -0
  5. data/Guardfile +3 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.adoc +21 -0
  8. data/README.md +1 -0
  9. data/Rakefile +1 -0
  10. data/ascii_binder_gabriel_rh.gemspec +41 -0
  11. data/bin/ascii_binder_gabriel_rh +1 -0
  12. data/bin/asciibinder_gabriel_rh +350 -0
  13. data/features/command_help.feature +8 -0
  14. data/features/command_version.feature +8 -0
  15. data/features/repo_build.feature +39 -0
  16. data/features/repo_clean.feature +20 -0
  17. data/features/repo_clone.feature +22 -0
  18. data/features/repo_create.feature +13 -0
  19. data/features/repo_package.feature +15 -0
  20. data/features/step_definitions/steps.rb +189 -0
  21. data/features/support/_clone_distro_map.yml +14 -0
  22. data/features/support/_invalid_alias_topic_map.yml +50 -0
  23. data/features/support/_invalid_distro_map.yml +14 -0
  24. data/features/support/env.rb +518 -0
  25. data/features/support/test_distro/.gitignore +9 -0
  26. data/features/support/test_distro/_distro_map.yml +29 -0
  27. data/features/support/test_distro/_images/asciibinder-logo-horizontal.png +0 -0
  28. data/features/support/test_distro/_images/asciibinder_web_logo.svg +125 -0
  29. data/features/support/test_distro/_images/book_pages_bg.jpg +0 -0
  30. data/features/support/test_distro/_images/favicon.ico +0 -0
  31. data/features/support/test_distro/_images/favicon32x32.png +0 -0
  32. data/features/support/test_distro/_javascripts/.gitkeep +0 -0
  33. data/features/support/test_distro/_stylesheets/asciibinder.css +568 -0
  34. data/features/support/test_distro/_templates/_css.html.erb +3 -0
  35. data/features/support/test_distro/_templates/_nav.html.erb +31 -0
  36. data/features/support/test_distro/_templates/page.html.erb +92 -0
  37. data/features/support/test_distro/_topic_map.yml +50 -0
  38. data/features/support/test_distro/index-main.html +10 -0
  39. data/features/support/test_distro/index-test.html +10 -0
  40. data/features/support/test_distro/main_only_topic_group/index.adoc +17 -0
  41. data/features/support/test_distro/test_only_topic_group/index.adoc +17 -0
  42. data/features/support/test_distro/welcome/aliased.adoc +9 -0
  43. data/features/support/test_distro/welcome/index.adoc +17 -0
  44. data/features/support/test_distro/welcome/subtopics/index.adoc +17 -0
  45. data/features/support/test_distro/welcome/subtopics/main_only_topic.adoc +17 -0
  46. data/features/support/test_distro/welcome/subtopics/test_only_topic.adoc +17 -0
  47. data/features/support/test_distro/welcome/subtopics/wildcard_all.adoc +17 -0
  48. data/lib/ascii_binder_gabriel_rh/distro.rb +111 -0
  49. data/lib/ascii_binder_gabriel_rh/distro_branch.rb +97 -0
  50. data/lib/ascii_binder_gabriel_rh/distro_map.rb +67 -0
  51. data/lib/ascii_binder_gabriel_rh/engine.rb +690 -0
  52. data/lib/ascii_binder_gabriel_rh/helpers.rb +172 -0
  53. data/lib/ascii_binder_gabriel_rh/site.rb +52 -0
  54. data/lib/ascii_binder_gabriel_rh/site_info.rb +22 -0
  55. data/lib/ascii_binder_gabriel_rh/site_map.rb +24 -0
  56. data/lib/ascii_binder_gabriel_rh/tasks/guards.rb +15 -0
  57. data/lib/ascii_binder_gabriel_rh/tasks/tasks.rb +41 -0
  58. data/lib/ascii_binder_gabriel_rh/template_renderer.rb +29 -0
  59. data/lib/ascii_binder_gabriel_rh/topic_entity.rb +324 -0
  60. data/lib/ascii_binder_gabriel_rh/topic_map.rb +112 -0
  61. data/lib/ascii_binder_gabriel_rh/version.rb +3 -0
  62. data/lib/ascii_binder_gabriel_rh.rb +5 -0
  63. data/templates/.gitignore +9 -0
  64. data/templates/LICENSE.txt +4 -0
  65. data/templates/README.adoc +11 -0
  66. data/templates/_distro_map.yml +11 -0
  67. data/templates/_images/asciibinder-logo-horizontal.png +0 -0
  68. data/templates/_images/asciibinder_web_logo.svg +125 -0
  69. data/templates/_images/book_pages_bg.jpg +0 -0
  70. data/templates/_images/favicon.ico +0 -0
  71. data/templates/_images/favicon32x32.png +0 -0
  72. data/templates/_javascripts/.gitkeep +0 -0
  73. data/templates/_javascripts/bootstrap-offcanvas.js +6 -0
  74. data/templates/_stylesheets/asciibinder.css +568 -0
  75. data/templates/_templates/_breadcrumb.html.erb +14 -0
  76. data/templates/_templates/_css.html.erb +3 -0
  77. data/templates/_templates/_nav.html.erb +14 -0
  78. data/templates/_templates/_title.html.erb +8 -0
  79. data/templates/_templates/page.html.erb +88 -0
  80. data/templates/_topic_map.yml +29 -0
  81. data/templates/index-main.html +89 -0
  82. data/templates/welcome/index.adoc +14 -0
  83. metadata +423 -0
@@ -0,0 +1,518 @@
1
+ require 'fileutils'
2
+ require 'git'
3
+ require 'open3'
4
+ require 'tmpdir'
5
+ require 'yaml'
6
+
7
+ module Helpers
8
+ def gem_root
9
+ File.expand_path '../../..', __FILE__
10
+ end
11
+
12
+ def run_command(command,args=[],repo_dir=nil)
13
+ if repo_dir.nil?
14
+ repo_dir = working_dir
15
+ end
16
+ instructions = [File.join(gem_root,'bin','asciibinder'),command]
17
+ instructions.concat(args)
18
+ instructions << repo_dir
19
+ stdout_str, stderr_str, status = Open3.capture3(instructions.join(' '))
20
+ return { :stdout => stdout_str, :stderr => stderr_str, :status => status }
21
+ end
22
+
23
+ def print_output(command_output)
24
+ puts "STDOUT:\n#{command_output[:stdout]}\n\n"
25
+ puts "STDERR:\n#{command_output[:stderr]}\n\n"
26
+ puts "EXIT CODE: #{command_output[:status].exitstatus}\n\n"
27
+ end
28
+
29
+ def working_dir
30
+ @working_dir ||= begin
31
+ working_dir = Dir.mktmpdir('ascii_binder_gabriel_rh-cucumber')
32
+ track_tmp_dir(working_dir)
33
+ FileUtils.rm_rf(working_dir)
34
+ working_dir
35
+ end
36
+ end
37
+
38
+ def distro_map
39
+ @distro_map ||= YAML.load_file(File.join(docs_root,'_distro_map.yml'))
40
+ end
41
+
42
+ def topic_map
43
+ # Normally we want to read the topic map from each branch. In our test setup,
44
+ # each branch has an identical topic map, so we can get away with this for now.
45
+ @topic_map ||= YAML.load_stream(open(File.join(docs_root,'_topic_map.yml')))
46
+ end
47
+
48
+ def alias_files
49
+ @alias_files ||= ['aliases/a_to_a.html','aliases/a_to_e.html']
50
+ end
51
+
52
+ def preview_dir
53
+ @preview_dir ||= File.join(docs_root,'_preview')
54
+ end
55
+
56
+ def package_dir
57
+ @package_dir ||= File.join(docs_root,'_package')
58
+ end
59
+
60
+ def repo_template_dir
61
+ @repo_template_dir ||= File.join(gem_root,'templates')
62
+ end
63
+
64
+ def test_distro_dir
65
+ @test_distro_dir ||= File.join(gem_root,'features','support','test_distro')
66
+ end
67
+
68
+ def track_tmp_dir(tmp_dir)
69
+ if @tracked_tmp_dirs.nil?
70
+ @tracked_tmp_dirs = []
71
+ end
72
+ @tracked_tmp_dirs << tmp_dir unless @tracked_tmp_dirs.include?(tmp_dir)
73
+ end
74
+
75
+ def clean_tracked_dirs
76
+ @tracked_tmp_dirs.each do |dir|
77
+ FileUtils.rm_rf(dir)
78
+ end
79
+ end
80
+
81
+ def find_html_files(dir)
82
+ `cd #{dir} && find .`.split("\n").select{ |item| item.end_with?('.html') }.map{ |item| item[2..-1] }
83
+ end
84
+
85
+ def files_diff_explanation(gen_paths,cfg_paths)
86
+ gen_extras = (gen_paths-cfg_paths)
87
+ cfg_extras = (cfg_paths-gen_paths)
88
+ explanation = ''
89
+ if gen_extras.length > 0
90
+ explanation = "Unexpected extra files were generated:\n\t* " + gen_extras.join("\n\t* ")
91
+ end
92
+ if cfg_extras.length > 0
93
+ if explanation.length > 0
94
+ explanation = explanation + "\n"
95
+ end
96
+ explanation = explanation + "Expected files were not generated:\n\t* " + cfg_extras.join("\n\t* ")
97
+ end
98
+ return explanation
99
+ end
100
+
101
+ def actual_preview_info
102
+ all_preview_paths = find_html_files(preview_dir)
103
+
104
+ map = {}
105
+ dirmatch = {}
106
+ distro_map.each do |distro,distro_info|
107
+ map[distro] = {}
108
+ distro_info['branches'].each do |branch,branch_info|
109
+ map[distro][branch] = []
110
+ dirmatch["#{distro}/#{branch_info['dir']}"] = { :distro => distro, :branch => branch }
111
+ end
112
+ end
113
+
114
+ populated_distros = []
115
+ populated_branches = []
116
+ populated_pages = []
117
+ all_preview_paths.each do |preview_path|
118
+ found_dirmatch = false
119
+ dirmatch.each do |branch_path,db_keys|
120
+ next unless preview_path.start_with?(branch_path)
121
+ found_dirmatch = true
122
+ map[db_keys[:distro]][db_keys[:branch]] << preview_path
123
+ populated_distros << db_keys[:distro]
124
+ populated_branches << db_keys[:branch]
125
+ populated_pages << preview_path.split('/')[2..-1].join('/')
126
+ break
127
+ end
128
+ unless found_dirmatch
129
+ puts "ERROR: unexpected output file '#{preview_path}'"
130
+ exit 1
131
+ end
132
+ end
133
+
134
+ map.keys.each do |distro|
135
+ map[distro].keys.each do |branch|
136
+ map[distro][branch].sort!
137
+ end
138
+ end
139
+
140
+ return {
141
+ :map => map,
142
+ :distros => populated_distros.uniq,
143
+ :branches => populated_branches.uniq,
144
+ :pages => populated_pages.uniq,
145
+ }
146
+ end
147
+
148
+ def actual_site_map
149
+ all_site_paths = find_html_files(package_dir)
150
+
151
+ map = {}
152
+ dirmatch = {}
153
+ distro_map.each do |distro,distro_info|
154
+ site = distro_info['site']
155
+ unless map.has_key?(site)
156
+ map[site] = {}
157
+ end
158
+ map[site][distro] = {}
159
+ distro_info['branches'].each do |branch,branch_info|
160
+ map[site][distro][branch] = []
161
+ dirmatch["#{distro_info['site']}/#{branch_info['dir']}"] = {
162
+ :distro => distro,
163
+ :branch => branch,
164
+ :site => site,
165
+ }
166
+ end
167
+ end
168
+
169
+ all_site_paths.each do |site_path|
170
+ # skip the top-level index.html file in each site.
171
+ path_parts = site_path.split('/')
172
+ next if path_parts.length == 2 and path_parts[1] == 'index.html'
173
+
174
+ found_dirmatch = false
175
+ dirmatch.each do |branch_path,db_keys|
176
+ next unless site_path.start_with?(branch_path)
177
+ found_dirmatch = true
178
+ map[db_keys[:site]][db_keys[:distro]][db_keys[:branch]] << site_path
179
+ break
180
+ end
181
+ unless found_dirmatch
182
+ puts "ERROR: unexpected output file '#{site_path}'"
183
+ exit 1
184
+ end
185
+ end
186
+
187
+ map.keys.each do |site|
188
+ map[site].keys.each do |distro|
189
+ map[site][distro].keys.each do |branch|
190
+ map[site][distro][branch].sort!
191
+ end
192
+ end
193
+ end
194
+
195
+ return map
196
+ end
197
+
198
+ def distro_preview_path_map
199
+ map = {}
200
+ distro_map.each do |distro,distro_info|
201
+ map[distro] = {}
202
+ distro_info['branches'].each do |branch,branch_info|
203
+ map[distro][branch] = []
204
+ topic_map.each do |topic_node|
205
+ map[distro][branch].concat(topic_paths(distro,topic_node).map{ |subpath| "#{distro}/#{branch_info['dir']}/#{subpath}" })
206
+ end
207
+ map[distro][branch].sort!
208
+ end
209
+ end
210
+ return map
211
+ end
212
+
213
+ def distro_site_path_map
214
+ map = {}
215
+ distro_map.each do |distro,distro_info|
216
+ site = distro_info['site']
217
+ unless map.has_key?(site)
218
+ map[site] = {}
219
+ end
220
+ map[site][distro] = {}
221
+ distro_info['branches'].each do |branch,branch_info|
222
+ map[site][distro][branch] = []
223
+ topic_map.each do |topic_node|
224
+ map[site][distro][branch].concat(topic_paths(distro,topic_node).map{ |subpath| "#{site}/#{branch_info['dir']}/#{subpath}" })
225
+ end
226
+ map[site][distro][branch].sort!
227
+ end
228
+ end
229
+ return map
230
+ end
231
+
232
+ def topic_paths(distro,topic_node)
233
+ # First, determine if this topic node should be included for this distro.
234
+ if topic_node.has_key?('Distros')
235
+ found_distro = false
236
+ included_distros = topic_node['Distros'].split(',')
237
+ included_distros.each do |check_distro|
238
+ if check_distro.include?('*') and File.fnmatch(check_distro,distro)
239
+ found_distro = true
240
+ break
241
+ elsif check_distro == distro
242
+ found_distro = true
243
+ break
244
+ end
245
+ end
246
+ unless found_distro
247
+ return []
248
+ end
249
+ end
250
+
251
+ if topic_node.has_key?('File')
252
+ # This topic node is a topic "leaf"; return it with '.html' as the extension.
253
+ filename = topic_node['File'].split('.')[0]
254
+ return ["#{filename}.html"]
255
+ elsif topic_node.has_key?('Dir')
256
+ dirpath = topic_node['Dir']
257
+ subtopics = []
258
+ topic_node['Topics'].each do |subtopic_node|
259
+ subtopics.concat(topic_paths(distro,subtopic_node))
260
+ end
261
+ return subtopics.map{ |subpath| "#{dirpath}/#{subpath}" }
262
+ else
263
+ puts "ERROR: Malformed topic node. #{topic_node.inspect}"
264
+ exit 1
265
+ end
266
+ end
267
+
268
+ def set_initial_working_branch(branch)
269
+ @initial_working_branch = branch
270
+ end
271
+
272
+ def initial_working_branch
273
+ @initial_working_branch ||= nil
274
+ end
275
+
276
+ def using_offset_docs_root?
277
+ @using_offset_docs_root
278
+ end
279
+
280
+ def docs_root
281
+ using_offset_docs_root? ? File.join(working_dir,'docs') : working_dir
282
+ end
283
+
284
+ def initialize_test_repo(valid,multiple_distros=false,offset_docs_root=false)
285
+ unless valid
286
+ FileUtils.mkdir(working_dir)
287
+ else
288
+ status_check(run_command('create'),'Could not initialize test repo.')
289
+ if multiple_distros
290
+ FileUtils.cp_r(File.join(test_distro_dir,'.'),working_dir)
291
+ end
292
+ if offset_docs_root
293
+ @using_offset_docs_root = true
294
+ entries = Dir.entries(working_dir).select{ |item| not item.start_with?('.') }
295
+ system("cd #{working_dir} && mkdir docs")
296
+ entries.each do |entry|
297
+ system("cd #{working_dir} && mv #{entry} docs")
298
+ end
299
+ end
300
+ system("cd #{working_dir} && git add . > /dev/null && git commit -am 'test commit' > /dev/null")
301
+ if multiple_distros
302
+ system("cd #{working_dir} && git checkout -b branch1 > /dev/null 2>&1 && git checkout -b branch2 > /dev/null 2>&1 && git checkout main > /dev/null 2>&1")
303
+ end
304
+ set_initial_working_branch('main')
305
+ end
306
+ working_dir
307
+ end
308
+
309
+ def invalidate_distro_map
310
+ invalid_map = File.join(gem_root,'features','support','_invalid_distro_map.yml')
311
+ FileUtils.cp(invalid_map,File.join(docs_root,'_distro_map.yml'))
312
+ system("cd #{working_dir} && git add . > /dev/null && git commit -am 'Commit invalid distro map' > /dev/null")
313
+ end
314
+
315
+ def invalidate_topic_map
316
+ invalid_map = File.join(gem_root,'features','support','_invalid_alias_topic_map.yml')
317
+ FileUtils.cp(invalid_map,File.join(docs_root,'_topic_map.yml'))
318
+ system("cd #{working_dir} && git add . > /dev/null && git commit -am 'Commit invalid alias topic map' > /dev/null")
319
+ end
320
+
321
+ def initialize_remote_repo
322
+ remote_dir = Dir.mktmpdir('ascii_binder_gabriel_rh-cucumber-remote')
323
+ FileUtils.rm_rf(remote_dir)
324
+ track_tmp_dir(remote_dir)
325
+ if run_command('create',[],remote_dir)[:status].exitstatus == 0
326
+ clone_map = File.join(gem_root,'features','support','_clone_distro_map.yml')
327
+ FileUtils.cp(clone_map,File.join(remote_dir,'_distro_map.yml'))
328
+ system("cd #{remote_dir} && git add . > /dev/null && git commit -am 'remote commit' > /dev/null && git checkout -b branch1 > /dev/null 2>&1 && git checkout main > /dev/null 2>&1")
329
+ else
330
+ puts "ERROR: Could not initialize remote repo"
331
+ exit 1
332
+ end
333
+ remote_dir
334
+ end
335
+
336
+ def status_check(step_output,error_message)
337
+ unless step_output[:status].exitstatus == 0
338
+ puts "ERROR: #{error_message}"
339
+ print_output(step_output)
340
+ exit 1
341
+ end
342
+ end
343
+
344
+ def build_check(scope,target='')
345
+ # Initial state of check_map matches ':default' scope
346
+ check_map = {
347
+ :current_branch_only => true,
348
+ :specified_distro_only => false,
349
+ :specified_page_only => false,
350
+ }
351
+ case scope
352
+ when :default
353
+ # Change nothing
354
+ when :distro
355
+ check_map[:specified_distro_only] = true
356
+ when :all_branches
357
+ check_map[:current_branch_only] = false
358
+ when :page
359
+ check_map[:specified_page_only] = true
360
+ else
361
+ puts "ERROR: Build scope '#{scope}' not recognized."
362
+ exit 1
363
+ end
364
+
365
+ # Make sure the build finished on the same branch where it started.
366
+ git = Git.open(working_dir)
367
+ current_working_branch = git.branch.name
368
+ unless current_working_branch == initial_working_branch
369
+ puts "ERROR: Build operation started on branch '#{initial_working_branch}' but ended on branch '#{current_working_branch}'"
370
+ exit 1
371
+ end
372
+
373
+ # generate the expected preview paths for each full distro + branch combo
374
+ all_paths_map = distro_preview_path_map
375
+
376
+ # get all of the paths in the actual preview directory
377
+ real_preview_info = actual_preview_info
378
+
379
+ gen_paths_map = real_preview_info[:map]
380
+ branch_count = real_preview_info[:branches].length
381
+ distro_count = real_preview_info[:distros].length
382
+ page_count = real_preview_info[:pages].length
383
+ target_distro = real_preview_info[:distros][0]
384
+ target_page = real_preview_info[:pages][0].split('/').join(':').split('.')[0]
385
+
386
+ if distro_count == 0 or branch_count == 0
387
+ puts "ERROR: A build operation should produce at least one distro / branch preview."
388
+ exit 1
389
+ end
390
+
391
+ # Compare branches by count
392
+ if branch_count > 1 and check_map[:current_branch_only]
393
+ puts "ERROR: Expected behavior for '#{scope}' scope is to build current working branch only."
394
+ exit 1
395
+ elsif branch_count == 1 and not check_map[:current_branch_only]
396
+ puts "ERROR: Expected behavior for '#{scope}' scope is to build all local branches."
397
+ exit 1
398
+ end
399
+
400
+ # Compare distros by count
401
+ if distro_count > 1 and check_map[:specified_distro_only]
402
+ puts "ERROR: Expected behavior for '#{scope}' scope is to build specified branch ('#{target}') only."
403
+ exit 1
404
+ elsif distro_count == 1
405
+ if not check_map[:specified_distro_only]
406
+ puts "ERROR: Expected behavior for '#{scope}' scope is to build all distros."
407
+ exit 1
408
+ elsif not target_distro == target
409
+ puts "ERROR: The build did not run for the expected target distro '#{target}' but instead for '#{target_distro}'"
410
+ exit 1
411
+ end
412
+ end
413
+
414
+ # Compare pages by count
415
+ if page_count > 1 and check_map[:specified_page_only]
416
+ puts "ERROR: Expected behavior for '#{scope}' is to build the specified page ('#{target}') only."
417
+ exit 1
418
+ elsif page_count == 1
419
+ if not check_map[:specified_page_only]
420
+ puts "ERROR: Expected behavior for '#{scope}' scope is to build all pages."
421
+ exit 1
422
+ elsif not target_page == target
423
+ puts "ERROR: The build did not run for the expected target page '#{target}' but instead for '#{target_page}'"
424
+ end
425
+ end
426
+
427
+ # Generated files vs expected files.
428
+ if not check_map[:specified_page_only]
429
+ all_paths_map.keys.each do |distro|
430
+ next if check_map[:specified_distro_only] and not distro == target
431
+ if not gen_paths_map.has_key?(distro)
432
+ puts "ERROR: Expected distro '#{distro}' was not generated for preview."
433
+ exit 1
434
+ end
435
+ all_paths_map[distro].keys.each do |branch|
436
+ next if check_map[:current_branch_only] and not branch == current_working_branch
437
+ if not gen_paths_map[distro].has_key?(branch)
438
+ puts "ERROR: Expected distro / branch combo '#{distro}' / '#{branch}' was not generated for preview."
439
+ exit 1
440
+ end
441
+ # Alias check
442
+ alias_files.each do |afile|
443
+ genmatches = gen_paths_map[distro][branch].select{ |i| i.end_with?(afile) }
444
+ if genmatches.length == 0
445
+ puts "ERROR: Alias file '#{afile}' was not generated for distro / branch combo '#{distro}' / '#{branch}'."
446
+ exit 1
447
+ elsif genmatches.length > 1
448
+ puts "ERROR: Alias file '#{afile}' found more than once in generated output: #{genmatches.inspect}"
449
+ exit 1
450
+ end
451
+ end
452
+ if not gen_paths_map[distro][branch] == all_paths_map[distro][branch]
453
+ explanation = files_diff_explanation(gen_paths_map[distro][branch],all_paths_map[distro][branch])
454
+ puts "ERROR: Mismatch between expected and actual preview file paths for distro / branch combo '#{distro}' / '#{branch}'.\n#{explanation}"
455
+ exit 1
456
+ end
457
+ end
458
+ end
459
+ end
460
+ end
461
+
462
+ def package_check(target_site='')
463
+ all_paths_map = distro_site_path_map
464
+ real_site_map = actual_site_map
465
+
466
+ real_site_map.keys.each do |site|
467
+ real_site_map[site].keys.each do |distro|
468
+ real_site_map[site][distro].keys.each do |branch|
469
+ # If a target site was specified and any content was generated for a different site, raise an error.
470
+ if not target_site == '' and not site == target_site and real_site_map[site][distro][branch].length > 0
471
+ puts "ERROR: Content was generated for site '#{site}' even though it was only expected for site '#{target_site}'"
472
+ exit 1
473
+ end
474
+ # Alias check
475
+ if real_site_map[site][distro][branch].length > 0 and all_paths_map[site][distro][branch].length > 0
476
+ alias_files.each do |afile|
477
+ genmatches = real_site_map[site][distro][branch].select{ |i| i.end_with?(afile) }
478
+ if genmatches.length == 0
479
+ puts "ERROR: Alias file '#{afile}' was not generated for site / distro / branch combo '#{site}' / '#{distro}' / '#{branch}'."
480
+ exit 1
481
+ elsif genmatches.length > 1
482
+ puts "ERROR: Alias file '#{afile}' found more than once in generated site output: #{genmatches.inspect}"
483
+ exit 1
484
+ end
485
+ end
486
+ end
487
+ # Confirm that what was generated matches what was expected.
488
+ if (target_site == '' or site == target_site) and not real_site_map[site][distro][branch] == all_paths_map[site][distro][branch]
489
+ explanation = files_diff_explanation(real_site_map[site][distro][branch],all_paths_map[site][distro][branch])
490
+ puts "ERROR: Mismatch between expected and actual site file paths for site / distro / branch combo '#{site}' / '#{distro}' / '#{branch}'.\n#{explanation}"
491
+ exit 1
492
+ end
493
+ end
494
+ end
495
+
496
+ # Skip the next check for sites that aren't being packaged.
497
+ next unless target_site == '' or site == target_site
498
+
499
+ # Finally, confirm that the expected site index page was copied to the site home directory.
500
+ source_page = File.join(docs_root,"index-#{site}.html")
501
+ target_page = File.join(package_dir,site,'index.html')
502
+ unless FileUtils.compare_file(source_page,target_page)
503
+ puts "ERROR: Incorrect site index file contents at '#{target_page}'; expected contents of '#{source_page}'."
504
+ exit 1
505
+ end
506
+ end
507
+ end
508
+ end
509
+
510
+ World(Helpers)
511
+
512
+ Before do
513
+ working_dir
514
+ end
515
+
516
+ After do
517
+ clean_tracked_dirs
518
+ end
@@ -0,0 +1,9 @@
1
+ ## AsciiBinderGabrielRH-specific ignores
2
+ _preview
3
+ _package
4
+ *.swp
5
+ diag-*.png
6
+ diag-*.png.cache
7
+
8
+ ## Project-specific ignores
9
+
@@ -0,0 +1,29 @@
1
+ ---
2
+ distro_main:
3
+ name: AsciiBinderGabrielRH Doc Project
4
+ author: AsciiBinderGabrielRH Team <team@asciibinder.org>
5
+ site: main
6
+ site_name: Home
7
+ site_url: http://asciibinder.org/
8
+ branches:
9
+ master:
10
+ name: Latest
11
+ dir: latest
12
+ branch1:
13
+ name: Branch 1
14
+ dir: branch1
15
+ distro_test:
16
+ name: TEST_NAME
17
+ author: Test <test@example.com>
18
+ site: test
19
+ site_name: TEST_SITE
20
+ site_url: http://docs.test.example.com/
21
+ branches:
22
+ master:
23
+ name: TEST_BRANCH_LATEST
24
+ dir: test_latest
25
+ distro-overrides:
26
+ name: TEST_BRANCH_NICEST
27
+ branch2:
28
+ name: TEST_BRANCH_2
29
+ dir: 'test_branch/2'