ascii_binder 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcf4ffd260a5287efafd4fb3cc50fcf11d113a1a
4
- data.tar.gz: 4e60310acce7c1481c773831bb8c32c3d95e29ba
3
+ metadata.gz: 5e46fc5bec124115e6057d804df19fe32f791d85
4
+ data.tar.gz: 06512c6be9db989118b8af3dfd4b49f560082c56
5
5
  SHA512:
6
- metadata.gz: d9917eaeb2fb1630066889ea8d74fa55ea399ad54706da7ae1a7bbb6e00343628fd4b97bfc731e2f3aaca93e71eaa8b8bbd6a3016ca31057c715c7e2ec965087
7
- data.tar.gz: de6dde4b4042a3690a7ac2dd6440ae981cb031a2391fa262257150af1159e409e368fbd20aeb47c5128d6dcf9164d980a1d561a6b9cbe833901ec79f52fd2a2d
6
+ metadata.gz: fb26aab0abe17ed2fedba192f2b4722d9f0330096fc5e2116e7b19f00bc6820200b4dc262fb0446cd959126a0db0e8909ce0fbe83bc93a1eba3a0f4f3ddaa074
7
+ data.tar.gz: 86c0a7e51ab5f08975592b0edde1c0701bde3e76a6646d5f06bafe381a4816273136e4fa0b307f4022bb0e56ac4e3b5d0157d4cfeec9a4b79cdf08080c87796c
data/bin/ascii_binder ADDED
@@ -0,0 +1 @@
1
+ asciibinder
@@ -197,7 +197,9 @@ module AsciiBinder
197
197
  def find_topic_files
198
198
  file_list = []
199
199
  Find.find(source_dir).each do |path|
200
- next if path.nil? or not path =~ /.*\.adoc/ or path =~ /README/ or path =~ /\/old\//
200
+ # Only consider .adoc files and ignore README, and anything in
201
+ # directories whose names begin with 'old' or '_' (underscore)
202
+ next if path.nil? or not path =~ /.*\.adoc/ or path =~ /README/ or path =~ /\/old\// or path =~ /\/_/
201
203
  src_path = Pathname.new(path).sub(source_dir,'').to_s
202
204
  next if src_path.split('/').length < 3
203
205
  file_list << src_path
@@ -353,7 +355,10 @@ module AsciiBinder
353
355
  end
354
356
  # Check for right format of topic group values
355
357
  ['Name','Dir'].each do |group_key|
356
- if not group[group_key].is_a?(String)
358
+ if [true, false].include?(group[group_key])
359
+ raise "One of the topic groups in #{build_config_file} is using a reserved YAML keyword for the #{group_key} setting. In order to prevent your text from being turned into a true/false value, wrap it in quotes."
360
+ end
361
+ if not group[group_key].kind_of?(String)
357
362
  raise "One of the topic groups in #{build_config_file} is not using a string for the #{group_key} setting; current value is #{group[group_key].inspect}"
358
363
  end
359
364
  if group[group_key].empty? or group[group_key].match BLANK_STRING_RE
@@ -746,6 +751,24 @@ module AsciiBinder
746
751
  single_page = options[:single_page]
747
752
  site_name = options[:site_name]
748
753
 
754
+ # Distro Map settings can be overridden on a per-branch
755
+ # basis. This only works for top-level (string) values
756
+ # of the distro config and -not- the 'site' key.
757
+ branchwise_distro_config = {}
758
+ distro_config.each do |key,value|
759
+ next unless distro_config[key].kind_of?(String)
760
+ branchwise_distro_config[key] = value
761
+ end
762
+ if branch_config.has_key?('distro-overrides')
763
+ branch_config['distro-overrides'].each do |key,value|
764
+ if key == 'site'
765
+ puts "WARNING: The 'site' value of the distro config cannot be overriden on a branch-by-branch basis."
766
+ next
767
+ end
768
+ branchwise_distro_config[key] = value
769
+ end
770
+ end
771
+
749
772
  src_file_path = File.join(src_group_path,"#{topic['File']}.adoc")
750
773
  tgt_file_path = File.join(tgt_group_path,"#{topic['File']}.html")
751
774
  if single_page.nil?
@@ -755,9 +778,9 @@ module AsciiBinder
755
778
  page_attrs = asciidoctor_page_attrs([
756
779
  "imagesdir=#{src_group_path}/images",
757
780
  distro,
758
- "product-title=#{distro_config["name"]}",
781
+ "product-title=#{branchwise_distro_config["name"]}",
759
782
  "product-version=#{branch_config["name"]}",
760
- "product-author=#{distro_config["author"]}"
783
+ "product-author=#{branchwise_distro_config["author"]}"
761
784
  ])
762
785
 
763
786
  doc = Asciidoctor.load topic_adoc, :header_footer => false, :safe => :unsafe, :attributes => page_attrs
@@ -773,9 +796,9 @@ module AsciiBinder
773
796
  end
774
797
  page_args = {
775
798
  :distro_key => distro,
776
- :distro => distro_config["name"],
799
+ :distro => branchwise_distro_config["name"],
777
800
  :site_name => site_name,
778
- :site_url => distro_config["site_url"],
801
+ :site_url => branchwise_distro_config["site_url"],
779
802
  :topic_url => "#{branch_config['dir']}/#{topic_path}.html",
780
803
  :version => branch_config["name"],
781
804
  :group_title => topic_group['Name'],
@@ -835,8 +858,12 @@ module AsciiBinder
835
858
 
836
859
  # Now build a sitemap
837
860
  site_dir_path = Pathname.new(site_dir)
838
- SitemapGenerator::Sitemap.default_host = site_config[:url]
839
- SitemapGenerator::Sitemap.create( :compress => false, :filename => File.join(site_dir,'sitemap') ) do
861
+ SitemapGenerator::Sitemap.create(
862
+ :default_host => site_config[:url],
863
+ :public_path => site_dir_path,
864
+ :compress => false,
865
+ :filename => File.join(site_dir,'sitemap')
866
+ ) do
840
867
  file_list = Find.find(site_dir).select{ |path| not path.nil? and path =~ /.*\.html$/ }.map{ |path| '/' + Pathname.new(path).relative_path_from(site_dir_path).to_s }
841
868
  file_list.each do |file|
842
869
  add(file, :changefreq => 'daily')
@@ -1,3 +1,3 @@
1
1
  module AsciiBinder
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ascii_binder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - N. Harrison Ripps
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-16 00:00:00.000000000 Z
12
+ date: 2016-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
285
  version: '0'
286
286
  requirements: []
287
287
  rubyforge_project:
288
- rubygems_version: 2.4.8
288
+ rubygems_version: 2.5.1
289
289
  signing_key:
290
290
  specification_version: 4
291
291
  summary: AsciiBinder is an AsciiDoc-based system for authoring and publishing closely
data/bin/ascii_binder DELETED
@@ -1,312 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'ascii_binder/helpers'
4
- require 'ascii_binder/version'
5
- require 'pathname'
6
- require 'trollop'
7
-
8
- include AsciiBinder::Helpers
9
-
10
- def call_generate(branch_group, distro, page)
11
- if page == ''
12
- page = nil
13
- end
14
- begin
15
- generate_docs(branch_group, distro, page)
16
- rescue => e
17
- message = "#{e.class.name}: #{e.message} at\n #{e.backtrace.join("\n ")}"
18
- Trollop::die "Could not generate docs:\n#{message}"
19
- end
20
- end
21
-
22
- def repo_check(repo_dir)
23
- missing_files = false
24
- # These must all be present
25
- ['.git','_distro_map.yml','_templates'].each do |file|
26
- unless File.exist?(File.join(repo_dir, file))
27
- missing_files = true
28
- end
29
- end
30
- # Either of these must be present
31
- unless File.exist?(File.join(repo_dir, '_build_cfg.yml')) or File.exist?(File.join(repo_dir, '_topic_map.yml'))
32
- missing_files = true
33
- end
34
- if missing_files
35
- Trollop::die "The specified repo directory '#{repo_dir}' does not appear to be an AsciiBinder repo."
36
- end
37
- end
38
-
39
- SUB_COMMANDS = %w{help version build watch package clean create clone}
40
- Trollop::options do
41
- version AsciiBinder::VERSION
42
- banner <<-EOF
43
- Usage:
44
- #$0 <command> <repo_dir>
45
-
46
- Commands:
47
- build (default action)
48
- Builds the HTML docs in the indicated repo dir
49
- create
50
- Generates a new AsciiBinder repo at the indicated dir
51
- clone
52
- Clones an existing AsciiBinder repo to the local filesystem
53
- watch
54
- Starts Guard, which automatically regenerates changed HTML
55
- files on the working branch in the repo dir
56
- package
57
- Builds and packages the static HTML for all of the sites
58
- defined in the _distro_config.yml file
59
- clean
60
- Remove _preview, _publish and _package dirs created by
61
- other AsciiBinder operations.
62
-
63
- Options:
64
- EOF
65
- stop_on SUB_COMMANDS
66
- end
67
-
68
- cmd = ARGV.shift
69
- repo_dir = nil
70
-
71
- if cmd.nil?
72
- cmd = "build"
73
- elsif !SUB_COMMANDS.include?(cmd)
74
- if ARGV.empty?
75
- repo_dir = Pathname.new(cmd)
76
- cmd = "build"
77
- else
78
- Trollop::die "'#{cmd}' is not a valid asciibinder subcommand. Legal values are '#{SUB_COMMANDS.join('\', \'')}'."
79
- end
80
- end
81
-
82
- cmd_opts = case cmd
83
- when "build"
84
- Trollop::options do
85
- banner <<-EOF
86
- Usage:
87
- #$0 build <options> <repo_dir>
88
-
89
- Description:
90
- This is the default behavior for the asciibinder utility. When run,
91
- AsciiBinder reads the _distro_config.yml file out of the working
92
- branch of the indicated repo directory and based on that, proceeds to
93
- build the working branch version of the documentation for each distro.
94
-
95
- If you use the --all_branches flag, AsciiBinder behaves as described
96
- above, and then once the working branch version is built, AsciiBinder
97
- cycles through the other branches named in the _distro_config.yml file
98
- until all of the permutations have been built.
99
-
100
- If you want to limit the scope of the build work for faster builds,
101
- you have two targeted options:
102
-
103
- --distro=<distro_key> - Only builds the specified distro and branches
104
- associated with this distro.
105
-
106
- --page=<page_path> - Only builds the specified page for all distros.
107
-
108
- Note that the format for the "--page" option is:
109
-
110
- <topic_group>:<topic_file>
111
-
112
- or for subtopics:
113
-
114
- <topic_group>/<subtopic_group>:<topic_file>
115
-
116
- However, if you want to use the --page option extensively, then be
117
- aware of the `asciibinder watch` function, which does this for you
118
- automatically as you change any .adoc files in your working branch.
119
-
120
- Options:
121
- EOF
122
- opt :all_branches, "Instead of building only the current working branch, build all branches", :default => false
123
- opt :distro, "Instead of building all distros, build branches only for the specified distro.", :default => ''
124
- opt :page, "Build only the specified page for all distros and only the current working branch.", :default => ''
125
- conflicts :distro, :page
126
- end
127
- when "create"
128
- Trollop::options do
129
- banner <<-EOF
130
- Usage:
131
- #$0 create <new_repo_dir>
132
-
133
- Description:
134
- Creates a new, bare AsciiBinder repo in the specified directory.
135
- EOF
136
- end
137
- when "clone"
138
- Trollop::options do
139
- banner <<-EOF
140
- Usage:
141
- #$0 clone <options> <git_repo_url>
142
-
143
- Description:
144
- Clones an existing AsciiBinder repo to the current directory.
145
- Under the default behavior, AsciiBinder will attempt to set up
146
- tracking branches based on the contents of _distro_map.yml,
147
- but this can be suppressed (see Options).
148
-
149
- Options:
150
- EOF
151
- opt :branches, "Create tracking branches after cloning.", :default => true
152
- opt :dir, "Specify the pathname of the local directory for cloning.", :default => ''
153
- end
154
- when "watch"
155
- Trollop::options do
156
- banner <<-EOF
157
- Usage:
158
- #$0 watch <repo_dir>
159
-
160
- Description:
161
- In watch mode, AsciiBinder starts a Guard process in the foreground.
162
- This process watches the repo_dir for changes to the AsciiDoc (.adoc)
163
- files. When a change occurs, AsciiBinder regenerates the specific
164
- HTML output of the file that was changed, for the working branch only.
165
-
166
- This is the equivalent of running:
167
-
168
- $ asciibinder build --page='<topic_group>:<affected_file>'
169
-
170
- ...except that the Guardfile automatically detects and runs this as
171
- you work.
172
-
173
- This is meant to be used in conjunction with a web browser that is
174
- running a LiveReload plugin. If you are viewing the output HTML page
175
- in a browser where LiveReload is active, then every time you save a
176
- new version of the .adoc file, the new HTML is automatically
177
- regenerated and your page view is automatically refreshed.
178
- EOF
179
- end
180
- when "package"
181
- Trollop::options do
182
- banner <<-EOF
183
- Usage:
184
- #$0 package <options> <repo_dir>
185
-
186
- Description:
187
- Publish mode is similar to 'build' mode, but once all of the branches' of
188
- HTML are generated, 'publish' goes on to organize the branch / distro
189
- combinations that are described in _distro_config.yml into their "site"
190
- layouts. As a final step, the site layouts are tarred and gzipped for
191
- easy placement onto a production web server.
192
-
193
- Options:
194
- EOF
195
- opt :site, "Instead of packaging every docs site, package the specified site only.", :default => ''
196
- end
197
- when "help"
198
- Trollop::educate
199
- when "version"
200
- puts AsciiBinder::VERSION
201
- exit 0
202
- end
203
-
204
- if (not repo_dir.nil? and not ARGV.empty?) or (repo_dir.nil? and ARGV.length > 1)
205
- Trollop::die "Too many arguments provided to ascii_binder: '#{ARGV.join(' ')}'. Exiting."
206
- elsif repo_dir.nil?
207
- if ARGV.length == 1
208
- if cmd == 'clone'
209
- cmd_opts[:giturl] = ARGV.shift
210
- if cmd_opts[:dir] != ''
211
- repo_dir = Pathname.new(cmd_opts[:dir])
212
- else
213
- repo_dir = Pathname.new(File.join(Pathname.pwd, cmd_opts[:giturl].split('/')[-1].split('.')[0]))
214
- end
215
- else
216
- repo_dir = Pathname.new(ARGV.shift)
217
- end
218
- else
219
- if cmd != 'create'
220
- if cmd == 'clone'
221
- Trollop::die "Provide a git URL to clone from."
222
- else
223
- repo_dir = Pathname.pwd
224
- end
225
- else
226
- Trollop::die "Specify a name for the new repo directory."
227
- end
228
- end
229
- end
230
-
231
- # Validate the repo_dir path
232
- if cmd == 'create' or cmd == 'clone'
233
- if repo_dir.exist?
234
- Trollop::die "The specified new repo directory '#{repo_dir}' already exists."
235
- end
236
- else
237
- if !repo_dir.exist?
238
- Trollop::die "The specified repo directory '#{repo_dir}' does not exist."
239
- elsif !repo_dir.directory?
240
- Trollop::die "The specified repo directory path '#{repo_dir}' is not a directory."
241
- elsif !repo_dir.readable?
242
- Trollop::die "The specified repo directory '#{repo_dir}' is not readable."
243
- elsif !repo_dir.writable?
244
- Trollop::die "The specified repo directory '#{repo_dir}' cannot be written to."
245
- else
246
- repo_check(repo_dir)
247
- end
248
- end
249
-
250
- # Set the repo root
251
- set_source_dir(File.expand_path(repo_dir))
252
-
253
- # Cloning? Time to try it.
254
- if cmd == 'clone'
255
- puts "Cloning #{cmd_opts[:giturl]} to #{repo_dir}"
256
- system("git clone #{cmd_opts[:giturl]} #{repo_dir}")
257
- Trollop::die "The git URL could not be cloned: #{err}" if $?.exitstatus != 0
258
-
259
- # Make sure this cloned repo is legit.
260
- repo_check(repo_dir)
261
-
262
- if cmd_opts[:branches]
263
- Dir.chdir(repo_dir)
264
- puts "Tracking branch setup:"
265
- distro_branches.each do |doc_branch|
266
- next if doc_branch == 'master'
267
- puts "- #{doc_branch}"
268
- system("git branch #{doc_branch} origin/#{doc_branch}")
269
- end
270
- else
271
- puts "- Skipping tracking branch setup"
272
- end
273
-
274
- # Done and done.
275
- puts "Cloning complete."
276
- exit
277
- end
278
-
279
- # Change to the repo dir. This is necessary in order for
280
- # AsciiDoctor to work properly.
281
- if cmd != 'create'
282
- Dir.chdir source_dir
283
- end
284
-
285
- # Do the things with the stuff
286
- case cmd
287
- when "build"
288
- branch_group = cmd_opts[:all_branches] ? :all : :working_only
289
- build_distro = cmd_opts[:distro] || ''
290
- refresh_page = cmd_opts[:page] || nil
291
- call_generate(branch_group,build_distro,refresh_page)
292
- when "package"
293
- clean_up
294
- call_generate(:publish,'',nil)
295
- package_site = cmd_opts[:site] || ''
296
- package_docs(package_site)
297
- when "watch"
298
- if !dir_empty?(preview_dir)
299
- guardfile_path = File.join(Gem::Specification.find_by_name("ascii_binder").full_gem_path, 'Guardfile')
300
- exec("guard -G #{guardfile_path}")
301
- else
302
- Trollop::die "Run 'asciibinder build' at least once before running 'asciibinder watch'."
303
- end
304
- when "clean"
305
- clean_up
306
- puts "Cleaned up #{repo_dir}."
307
- when "create"
308
- create_new_repo
309
- puts "Created new repo in #{repo_dir}."
310
- end
311
-
312
- exit