ascii_binder 0.2.3 → 1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea737534633232eae04d4210d6898488aa16833da1b6e0300ee7bd5a343bcdad
4
- data.tar.gz: 6b14f4acc528b4bfb7d3170c0b80831ffb8475f7c8a7f5f41f9fb0aa78ef3ff1
3
+ metadata.gz: 26f9de41f109228dfa1478976e8d1b8f08a178300d092e3250dcca610e4e70b6
4
+ data.tar.gz: 4cf902ff6c38a7a9ce622cdfaef927ed3943c750bcf71051a0bf00d430fce603
5
5
  SHA512:
6
- metadata.gz: ff840bec755cf9124dfc6c16845b92ac2af3cb3bebd6fe812adae4b1888b2bb31af577d797f41f326c3511b79dd4f5f1f80e06b133e000167c8b50c137384573
7
- data.tar.gz: 74c3b5c8e7c03073473987bba0607974299fd3e243c292e7e6c4371a6c8e0d9c5c71664574ac820c63c51aeb6d9af8f1d95bfa46165cd755606b326542efd4d7
6
+ metadata.gz: d978b66122655791fcefc86a04741b94940fdfffab86e2ace9dd2454bef63849bda46b8776b90bad9bf7f9a87a7cce42ca4115bb2650fd0ee7836f23ed5ca7cb
7
+ data.tar.gz: e8b18ebdb1a1fbc8114645692e91342f6d48b8bb42b63f5c763a18550fbf45d7c3cac73c6ebd164910400448e3a0a2babcf0faa51a5cf06e98def1d66f9bae76
data/bin/asciibinder CHANGED
@@ -31,9 +31,9 @@ def repo_check(docs_basedir)
31
31
  end
32
32
  end
33
33
  # Either of these must be present
34
- unless File.exist?(File.join(docs_basedir, '_build_cfg.yml')) or File.exist?(File.join(docs_basedir, '_topic_map.yml'))
35
- missing_files = true
36
- end
34
+ # unless File.exist?(File.join("#{docs_basedir}/#{TOPIC_MAP_FOLDER}", '_topic_map.yml'))
35
+ # missing_files = true
36
+ # end
37
37
  if missing_files or not in_git_repo(docs_basedir)
38
38
  Trollop::die "The specified docs base directory '#{docs_basedir}' does not appear to be part of an AsciiBinder-compatible repo."
39
39
  end
@@ -78,18 +78,50 @@ module AsciiBinder
78
78
 
79
79
  # Protip: Don't cache these! The topic map needs to be reread every time we change branches.
80
80
  def topic_map_file
81
+
82
+ # new stuff 1/Nov/2021
83
+ # allow users to break up the topic map into multiple topic maps
84
+ # load topic maps from a single folder called _topic_maps.
85
+ # we assume that all files in this folder are correctly formatted topic maps. If not, you will get normal asciibinder errors
86
+ topic_map_folder = TOPIC_MAP_FOLDER
81
87
  topic_file = TOPIC_MAP_FILENAME
82
- unless File.exist?(File.join(docs_root_dir,topic_file))
83
- # The new filename '_topic_map.yml' couldn't be found;
84
- # switch to the old one and warn the user.
85
- topic_file = BUILD_FILENAME
86
- unless File.exist?(File.join(docs_root_dir,topic_file))
87
- # Critical error - no topic map file at all.
88
- Trollop::die "Could not find any topic map file ('#{TOPIC_MAP_FILENAME}' or '#{BUILD_FILENAME}') at #{docs_root_dir} in branch '#{git.branch}'"
88
+
89
+ if !Dir.exist?(File.join(docs_root_dir, topic_map_folder))
90
+ # if the _topic_maps directory doesn't exist or is empty, see if we can find the topic map in the root folder to maintain backward compatibility
91
+
92
+ if !File.exist?(File.join(docs_root_dir, topic_file))
93
+ # fall back to looking for a _topic_map in the root directory
94
+
95
+ topic_file = BUILD_FILENAME # old folders use build_config.yml
96
+
97
+ if !File.exist?(File.join(docs_root_dir, topic_file))
98
+ # Critical error - no topic map file at all.
99
+ Trollop::die "Could not find a valid topic map file. There is no #{TOPIC_MAP_FOLDER} folder and the fall back files #{TOPIC_MAP_FILENAME} or #{BUILD_FILENAME} in branch '#{git.branch}' were also not found."
100
+ else
101
+ t = File.join(docs_root_dir, topic_file) # found build_config
102
+ end
103
+ else
104
+ t = File.join(docs_root_dir, topic_file) # found topic_map in root
105
+ end
106
+
107
+ else
108
+
109
+ # topic map files are in the _topic_maps folder
110
+
111
+ # create a combined temp file with all topic maps
112
+ tf = Tempfile.new("#{TOPIC_MAP_FILENAME}")
113
+
114
+ Dir.glob("#{topic_map_folder}/*.yml").each do |filename|
115
+ lines = IO.read(filename)
116
+ tf << lines
89
117
  end
90
- log_warn("'#{BUILD_FILENAME}' is a deprecated filename. Rename this to '#{TOPIC_MAP_FILENAME}'.")
118
+
119
+ t = tf.path
91
120
  end
92
- topic_file
121
+
122
+ # returns the path to the final file
123
+ t
124
+
93
125
  end
94
126
 
95
127
  def topic_map
@@ -467,7 +499,7 @@ module AsciiBinder
467
499
 
468
500
  doc = without_warnings { Asciidoctor.load topic_file, :header_footer => false, :safe => :unsafe, :attributes => page_attrs, :base_dir => "." }
469
501
  article_title = doc.doctitle || topic.name
470
-
502
+
471
503
  topic_html = doc.render
472
504
 
473
505
  # This is logic bridges newer arbitrary-depth-tolerant code to
@@ -4,6 +4,7 @@ require 'stringio'
4
4
  module AsciiBinder
5
5
  module Helpers
6
6
  BUILD_FILENAME = '_build_cfg.yml'
7
+ TOPIC_MAP_FOLDER = '_topic_maps'
7
8
  TOPIC_MAP_FILENAME = '_topic_map.yml'
8
9
  DISTRO_MAP_FILENAME = '_distro_map.yml'
9
10
  PREVIEW_DIRNAME = '_preview'
@@ -10,12 +10,13 @@ module AsciiBinder
10
10
  attr_reader :list
11
11
 
12
12
  def initialize(topic_file,distro_keys)
13
- @topic_yaml = YAML.load_stream(open(File.join(docs_root_dir,topic_file)))
13
+ @topic_yaml = YAML.load_stream(open(topic_file))
14
14
  @distro_keys = distro_keys
15
15
  @list = []
16
16
  @topic_yaml.each do |topic_entity|
17
17
  @list << AsciiBinder::TopicEntity.new(topic_entity,distro_keys)
18
18
  end
19
+
19
20
  end
20
21
 
21
22
  def filepaths
@@ -1,3 +1,3 @@
1
1
  module AsciiBinder
2
- VERSION = "0.2.3"
2
+ VERSION = "1.0"
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.2.3
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - N. Harrison Ripps
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2021-07-27 00:00:00.000000000 Z
15
+ date: 2021-11-23 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler