ascii_binder_gabriel_rh 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/Dockerfile +19 -0
- data/Gemfile +3 -0
- data/Guardfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.adoc +21 -0
- data/README.md +1 -0
- data/Rakefile +1 -0
- data/ascii_binder_gabriel_rh.gemspec +41 -0
- data/bin/ascii_binder_gabriel_rh +1 -0
- data/bin/asciibinder_gabriel_rh +350 -0
- data/features/command_help.feature +8 -0
- data/features/command_version.feature +8 -0
- data/features/repo_build.feature +39 -0
- data/features/repo_clean.feature +20 -0
- data/features/repo_clone.feature +22 -0
- data/features/repo_create.feature +13 -0
- data/features/repo_package.feature +15 -0
- data/features/step_definitions/steps.rb +189 -0
- data/features/support/_clone_distro_map.yml +14 -0
- data/features/support/_invalid_alias_topic_map.yml +50 -0
- data/features/support/_invalid_distro_map.yml +14 -0
- data/features/support/env.rb +518 -0
- data/features/support/test_distro/.gitignore +9 -0
- data/features/support/test_distro/_distro_map.yml +29 -0
- data/features/support/test_distro/_images/asciibinder-logo-horizontal.png +0 -0
- data/features/support/test_distro/_images/asciibinder_web_logo.svg +125 -0
- data/features/support/test_distro/_images/book_pages_bg.jpg +0 -0
- data/features/support/test_distro/_images/favicon.ico +0 -0
- data/features/support/test_distro/_images/favicon32x32.png +0 -0
- data/features/support/test_distro/_javascripts/.gitkeep +0 -0
- data/features/support/test_distro/_stylesheets/asciibinder.css +568 -0
- data/features/support/test_distro/_templates/_css.html.erb +3 -0
- data/features/support/test_distro/_templates/_nav.html.erb +31 -0
- data/features/support/test_distro/_templates/page.html.erb +92 -0
- data/features/support/test_distro/_topic_map.yml +50 -0
- data/features/support/test_distro/index-main.html +10 -0
- data/features/support/test_distro/index-test.html +10 -0
- data/features/support/test_distro/main_only_topic_group/index.adoc +17 -0
- data/features/support/test_distro/test_only_topic_group/index.adoc +17 -0
- data/features/support/test_distro/welcome/aliased.adoc +9 -0
- data/features/support/test_distro/welcome/index.adoc +17 -0
- data/features/support/test_distro/welcome/subtopics/index.adoc +17 -0
- data/features/support/test_distro/welcome/subtopics/main_only_topic.adoc +17 -0
- data/features/support/test_distro/welcome/subtopics/test_only_topic.adoc +17 -0
- data/features/support/test_distro/welcome/subtopics/wildcard_all.adoc +17 -0
- data/lib/ascii_binder_gabriel_rh/distro.rb +111 -0
- data/lib/ascii_binder_gabriel_rh/distro_branch.rb +97 -0
- data/lib/ascii_binder_gabriel_rh/distro_map.rb +67 -0
- data/lib/ascii_binder_gabriel_rh/engine.rb +690 -0
- data/lib/ascii_binder_gabriel_rh/helpers.rb +172 -0
- data/lib/ascii_binder_gabriel_rh/site.rb +52 -0
- data/lib/ascii_binder_gabriel_rh/site_info.rb +22 -0
- data/lib/ascii_binder_gabriel_rh/site_map.rb +24 -0
- data/lib/ascii_binder_gabriel_rh/tasks/guards.rb +15 -0
- data/lib/ascii_binder_gabriel_rh/tasks/tasks.rb +41 -0
- data/lib/ascii_binder_gabriel_rh/template_renderer.rb +29 -0
- data/lib/ascii_binder_gabriel_rh/topic_entity.rb +324 -0
- data/lib/ascii_binder_gabriel_rh/topic_map.rb +112 -0
- data/lib/ascii_binder_gabriel_rh/version.rb +3 -0
- data/lib/ascii_binder_gabriel_rh.rb +5 -0
- data/templates/.gitignore +9 -0
- data/templates/LICENSE.txt +4 -0
- data/templates/README.adoc +11 -0
- data/templates/_distro_map.yml +11 -0
- data/templates/_images/asciibinder-logo-horizontal.png +0 -0
- data/templates/_images/asciibinder_web_logo.svg +125 -0
- data/templates/_images/book_pages_bg.jpg +0 -0
- data/templates/_images/favicon.ico +0 -0
- data/templates/_images/favicon32x32.png +0 -0
- data/templates/_javascripts/.gitkeep +0 -0
- data/templates/_javascripts/bootstrap-offcanvas.js +6 -0
- data/templates/_stylesheets/asciibinder.css +568 -0
- data/templates/_templates/_breadcrumb.html.erb +14 -0
- data/templates/_templates/_css.html.erb +3 -0
- data/templates/_templates/_nav.html.erb +14 -0
- data/templates/_templates/_title.html.erb +8 -0
- data/templates/_templates/page.html.erb +88 -0
- data/templates/_topic_map.yml +29 -0
- data/templates/index-main.html +89 -0
- data/templates/welcome/index.adoc +14 -0
- metadata +423 -0
@@ -0,0 +1,189 @@
|
|
1
|
+
require 'ascii_binder_gabriel_rh/version'
|
2
|
+
require 'cucumber'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'open3'
|
5
|
+
require 'diff_dirs'
|
6
|
+
|
7
|
+
Given(/^an existing repo directory$/) do
|
8
|
+
Dir.mkdir(working_dir)
|
9
|
+
end
|
10
|
+
|
11
|
+
Given(/^a nonexistent repo directory$/) do
|
12
|
+
working_dir
|
13
|
+
end
|
14
|
+
|
15
|
+
Given(/^a valid AsciiBinderGabrielRH docs repo(.*)$/) do |repo_condition|
|
16
|
+
multiple_distros = false
|
17
|
+
offset_docs_root = false
|
18
|
+
invalid_alias = false
|
19
|
+
if repo_condition == ' with multiple distros'
|
20
|
+
multiple_distros = true
|
21
|
+
elsif repo_condition == ' where the docs root is not at the repo root'
|
22
|
+
multiple_distros = true
|
23
|
+
offset_docs_root = true
|
24
|
+
elsif repo_condition == ' with an invalid alias'
|
25
|
+
multiple_distros = true
|
26
|
+
invalid_alias = true
|
27
|
+
end
|
28
|
+
initialize_test_repo(true,multiple_distros,offset_docs_root)
|
29
|
+
if invalid_alias
|
30
|
+
invalidate_topic_map
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Given(/^an invalid AsciiBinderGabrielRH docs repo(.*)$/) do |invalid_condition|
|
35
|
+
if invalid_condition == ' due to a malformed distro map'
|
36
|
+
initialize_test_repo(true,true)
|
37
|
+
invalidate_distro_map
|
38
|
+
else
|
39
|
+
initialize_test_repo(false)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Given(/^the docs repo contains generated content$/) do
|
44
|
+
output = run_command('package')
|
45
|
+
has_error = false
|
46
|
+
[preview_dir,package_dir].each do |subdir|
|
47
|
+
unless Dir.exist?(subdir)
|
48
|
+
puts "ERROR: expected directory '#{subdir}' was not created."
|
49
|
+
has_error = true
|
50
|
+
end
|
51
|
+
unless Dir.entries(subdir).select{ |item| not ['.','..'].include?(item) }.length > 0
|
52
|
+
puts "ERROR: directory '#{subdir}' is empty."
|
53
|
+
has_error = true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
if has_error
|
57
|
+
print_output(output)
|
58
|
+
exit 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Given(/^the docs repo contains no generated content$/) do
|
63
|
+
[preview_dir,package_dir].each do |subdir|
|
64
|
+
next unless Dir.exist?(subdir)
|
65
|
+
FileUtils.rm_rf(subdir)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
Given(/^a nonexistent remote repo$/) do
|
70
|
+
@remote_repo_url = 'http://example.com/repo.git'
|
71
|
+
end
|
72
|
+
|
73
|
+
Given(/^an existing remote repo$/) do
|
74
|
+
# We're going to set up a local repo as a remote.
|
75
|
+
@remote_repo_dir = initialize_remote_repo
|
76
|
+
@remote_repo_url = "file://#{@remote_repo_dir}"
|
77
|
+
end
|
78
|
+
|
79
|
+
When(/^the user runs `asciibinder (.+)` on that (.+) directory$/) do |command_string,target_dir|
|
80
|
+
@command_args = command_string.split(' ')
|
81
|
+
run_dir = target_dir == 'docs root' ? File.join(working_dir,'docs') : working_dir
|
82
|
+
command = @command_args.shift
|
83
|
+
if command == 'clone'
|
84
|
+
@step_output = run_command(command,["-d #{working_dir}"],@remote_repo_url)
|
85
|
+
else
|
86
|
+
@step_output = run_command(command,@command_args,run_dir)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
Then(/^the generated content is removed$/) do
|
91
|
+
has_error = false
|
92
|
+
[preview_dir,package_dir].each do |subdir|
|
93
|
+
unless Dir.exist?(subdir)
|
94
|
+
puts "ERROR: expected to find directory '#{subdir}' but didn't"
|
95
|
+
has_error = true
|
96
|
+
end
|
97
|
+
unless Dir.entries(subdir).select{ |item| not ['.','..'].include?(item) }.length == 0
|
98
|
+
puts "ERROR: expected directory '#{subdir}' to be empty"
|
99
|
+
has_error
|
100
|
+
end
|
101
|
+
end
|
102
|
+
if has_error
|
103
|
+
print_output(@step_output)
|
104
|
+
exit 1
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
Then(/^the program exits without errors$/) do
|
109
|
+
status_check(@step_output,'running `asciibinder clean`.')
|
110
|
+
end
|
111
|
+
|
112
|
+
Then(/^the program exits with a warning$/) do
|
113
|
+
if @step_output[:status].exitstatus == 0
|
114
|
+
puts "ERROR: testing `asciibinder clean`; expected an exit code other than 0."
|
115
|
+
print_output(@step_output)
|
116
|
+
exit 1
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
Then(/^the program clones the remote repo into the local directory$/) do
|
121
|
+
diffs = diff_dirs(@remote_repo_dir, working_dir)
|
122
|
+
non_git_diffs = diffs.select{ |entry| not entry[1].start_with?('.git') }
|
123
|
+
remote_branches = Git.open(@remote_repo_dir).branches.local.map{ |branch| branch.name }.sort
|
124
|
+
local_branches = Git.open(working_dir).branches.local.map{ |branch| branch.name }.sort
|
125
|
+
branch_matches = remote_branches & local_branches
|
126
|
+
unless branch_matches.length == local_branches.length and non_git_diffs.length == 0
|
127
|
+
puts "ERROR: cloned repo doesn't match remote repo."
|
128
|
+
exit 1
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
Then(/^the program generates a new base docs repo$/) do
|
133
|
+
diffs = diff_dirs(repo_template_dir, working_dir)
|
134
|
+
unless diffs.length == 1 and diffs[0][0] == :new and diffs[0][1] == '.git'
|
135
|
+
puts "ERROR: template repo copy produced differences - #{diffs.inspect}"
|
136
|
+
exit 1
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
Then(/^the program displays help information$/) do
|
141
|
+
status_check(@step_output,'`asciibinder help` command failed.')
|
142
|
+
unless @step_output[:stderr] == '' and @step_output[:stdout].start_with?('Usage:')
|
143
|
+
puts "ERROR: unexpected help output"
|
144
|
+
print_output(@step_output)
|
145
|
+
exit 1
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
Then(/^the program prints the current version of the utility$/) do
|
150
|
+
status_check(@step_output,'`asciibinder version` command failed.')
|
151
|
+
unless @step_output[:stderr] == '' and @step_output[:stdout].chomp == AsciiBinderGabrielRH::VERSION
|
152
|
+
puts "ERROR: unexpected help output"
|
153
|
+
print_output(@step_output)
|
154
|
+
exit 1
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
Then(/^the program generates preview content for (.+)$/) do |build_target|
|
159
|
+
status_check(@step_output,'`asciibinder build` command failed.')
|
160
|
+
case build_target
|
161
|
+
when 'all distros in the current branch'
|
162
|
+
build_check(:default)
|
163
|
+
when 'only the `distro_test` distro'
|
164
|
+
distro = @command_args.select{ |arg| arg.starts_with?('--distro=') }.map{ |arg| arg.split('=')[1] }[0]
|
165
|
+
build_check(:distro,distro)
|
166
|
+
when 'all relevant distro/branch combos'
|
167
|
+
build_check(:all_branches)
|
168
|
+
when 'the specified page in all distros'
|
169
|
+
page = @command_args.select{ |arg| arg.starts_with?('--page=') }.map{ |arg| arg.split('=')[1] }[0]
|
170
|
+
build_check(:page,page)
|
171
|
+
else
|
172
|
+
puts "ERROR: unrecognized test case '#{build_target}'"
|
173
|
+
exit 1
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
Then(/^the program generates a site directory for (.+) in the distro map$/) do |package_target|
|
178
|
+
status_check(@step_output,'`asciibinder package` command failed.')
|
179
|
+
case package_target
|
180
|
+
when 'each site'
|
181
|
+
package_check()
|
182
|
+
when 'only the `test` site'
|
183
|
+
site = @command_args.select{ |arg| arg.starts_with?('--site=') }.map{ |arg| arg.split('=')[1] }[0]
|
184
|
+
package_check(site)
|
185
|
+
else
|
186
|
+
puts "ERROR: unrecognized test case '#{build_target}'"
|
187
|
+
exit 1
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
ascii_binder_gabriel_rh:
|
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
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
Name: AsciiBinderGabrielRH Doc Project
|
3
|
+
Dir: welcome
|
4
|
+
Topics:
|
5
|
+
- Name: Welcome
|
6
|
+
File: index
|
7
|
+
- Name: Aliased Topic
|
8
|
+
File: aliased
|
9
|
+
- Name: Subtopics
|
10
|
+
Dir: subtopics
|
11
|
+
Topics:
|
12
|
+
- Name: All Distros
|
13
|
+
File: index
|
14
|
+
- Name: MAIN_ONLY_TOPIC
|
15
|
+
File: main_only_topic
|
16
|
+
Distros: distro_main
|
17
|
+
- Name: TEST_ONLY_TOPIC
|
18
|
+
File: test_only_topic
|
19
|
+
Distros: distro_test
|
20
|
+
- Name: Wilcard All
|
21
|
+
File: wildcard_all
|
22
|
+
Distros: distro_*
|
23
|
+
|
24
|
+
---
|
25
|
+
Name: MAIN_ONLY_TOPIC_GROUP
|
26
|
+
Dir: main_only_topic_group
|
27
|
+
Distros: distro_main
|
28
|
+
Topics:
|
29
|
+
- Name: MAIN_ONLY_WELCOME
|
30
|
+
File: index
|
31
|
+
|
32
|
+
---
|
33
|
+
Name: TEST_ONLY_TOPIC_GROUP
|
34
|
+
Dir: test_only_topic_group
|
35
|
+
Distros: distro_test
|
36
|
+
Topics:
|
37
|
+
- Name: TEST_ONLY_WELCOME
|
38
|
+
File: index
|
39
|
+
|
40
|
+
---
|
41
|
+
Name: ALIASES_GROUP
|
42
|
+
Dir: aliases
|
43
|
+
Topics:
|
44
|
+
- Name: Alias to Nonexistant
|
45
|
+
File: a_to_a
|
46
|
+
Alias: welcome/nonexistent
|
47
|
+
- Name: Alias to External
|
48
|
+
File: a_to_e
|
49
|
+
Alias: https://redhat.com/
|
50
|
+
|