giblish 0.2.12 → 0.3.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 +5 -5
- data/.ruby-version +1 -0
- data/Rakefile +2 -3
- data/giblish.gemspec +1 -0
- data/lib/giblish/application.rb +14 -5
- data/lib/giblish/buildgraph.rb +179 -0
- data/lib/giblish/buildindex.rb +361 -414
- data/lib/giblish/cmdline.rb +11 -7
- data/lib/giblish/core.rb +251 -400
- data/lib/giblish/docconverter.rb +231 -0
- data/lib/giblish/docid.rb +107 -58
- data/lib/giblish/docinfo.rb +85 -0
- data/lib/giblish/gititf.rb +1 -0
- data/lib/giblish/utils.rb +29 -5
- data/lib/giblish/version.rb +1 -1
- metadata +21 -3
@@ -0,0 +1,85 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
module Giblish
|
4
|
+
# Container class for bundling together the data we cache for
|
5
|
+
# each asciidoc file we come across
|
6
|
+
class DocInfo
|
7
|
+
# Cache git info
|
8
|
+
class DocHistory
|
9
|
+
attr_accessor :date
|
10
|
+
attr_accessor :author
|
11
|
+
attr_accessor :message
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :converted
|
15
|
+
attr_accessor :title
|
16
|
+
attr_accessor :doc_id
|
17
|
+
attr_accessor :purpose_str
|
18
|
+
attr_accessor :status
|
19
|
+
attr_accessor :history
|
20
|
+
attr_accessor :error_msg
|
21
|
+
attr_accessor :stderr
|
22
|
+
# these two members can have encoding issues when
|
23
|
+
# running in a mixed Windows/Linux setting.
|
24
|
+
# that is why the explicit utf-8 read methods are
|
25
|
+
# provided.
|
26
|
+
attr_accessor :rel_path
|
27
|
+
attr_accessor :src_file
|
28
|
+
|
29
|
+
def relPath_utf8
|
30
|
+
return nil if @rel_path.nil?
|
31
|
+
@rel_path.to_s.encode("utf-8")
|
32
|
+
end
|
33
|
+
|
34
|
+
def srcFile_utf8
|
35
|
+
return nil if @src_file.nil?
|
36
|
+
@src_file.to_s.encode("utf-8")
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(adoc: nil, dst_root_abs: nil, adoc_stderr: "")
|
40
|
+
@src_file = nil
|
41
|
+
@history = []
|
42
|
+
@converted = true
|
43
|
+
@stderr = adoc_stderr
|
44
|
+
return unless adoc
|
45
|
+
|
46
|
+
# Get the purpose info if it exists
|
47
|
+
@purpose_str = get_purpose_info adoc
|
48
|
+
|
49
|
+
# fill in doc meta data
|
50
|
+
d_attr = adoc.attributes
|
51
|
+
@doc_id = d_attr["docid"]
|
52
|
+
@src_file = d_attr["docfile"]
|
53
|
+
@title = adoc.doctitle
|
54
|
+
return if dst_root_abs.nil?
|
55
|
+
|
56
|
+
# Get the relative path beneath the root dir to the doc
|
57
|
+
@rel_path = Pathname.new(
|
58
|
+
"#{d_attr['outdir']}/#{d_attr['docname']}#{d_attr['docfilesuffix']}"
|
59
|
+
).relative_path_from(dst_root_abs)
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_s
|
63
|
+
"DocInfo: title: #{@title} src_file: #{@src_file}"
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def get_purpose_info(adoc)
|
69
|
+
# Get the 'Purpose' section if it exists
|
70
|
+
purpose_str = ""
|
71
|
+
adoc.blocks.each do |section|
|
72
|
+
next unless section.is_a?(Asciidoctor::Section) &&
|
73
|
+
(section.level == 1) &&
|
74
|
+
(section.name =~ /^Purpose$/)
|
75
|
+
|
76
|
+
# filter out 'odd' text, such as lists etc...
|
77
|
+
section.blocks.each do |bb|
|
78
|
+
next unless bb.is_a?(Asciidoctor::Block)
|
79
|
+
purpose_str << "#{bb.source}\n+\n"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
purpose_str
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/giblish/gititf.rb
CHANGED
data/lib/giblish/utils.rb
CHANGED
@@ -6,8 +6,8 @@ class Giblog
|
|
6
6
|
def self.setup
|
7
7
|
return if defined? @logger
|
8
8
|
@logger = Logger.new(STDOUT)
|
9
|
-
@logger.formatter = proc do |
|
10
|
-
"#{datetime.strftime('%H:%M:%S')} - #{msg}\n"
|
9
|
+
@logger.formatter = proc do |severity, datetime, _progname, msg|
|
10
|
+
"#{datetime.strftime('%H:%M:%S')} #{severity} - #{msg}\n"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -41,14 +41,16 @@ module Giblish
|
|
41
41
|
def initialize(src_root, dst_root, resource_dir = nil)
|
42
42
|
# Make sure that the source root exists in the file system
|
43
43
|
@src_root_abs = Pathname.new(src_root).realpath
|
44
|
+
self.dst_root_abs = dst_root
|
45
|
+
# Make sure that the resource dir exists if user gives a path to it
|
46
|
+
resource_dir && (@resource_dir_abs = Pathname.new(resource_dir).realpath)
|
47
|
+
end
|
44
48
|
|
49
|
+
def dst_root_abs=(dst_root)
|
45
50
|
# Make sure that the destination root exists and expand it to an
|
46
51
|
# absolute path
|
47
52
|
Pathname.new(dst_root).mkpath
|
48
53
|
@dst_root_abs = Pathname.new(dst_root).realpath
|
49
|
-
|
50
|
-
# Make sure that the resource dir exists if user gives a path to it
|
51
|
-
resource_dir && (@resource_dir_abs = Pathname.new(resource_dir).realpath)
|
52
54
|
end
|
53
55
|
|
54
56
|
# Public: Get the relative path from the source root dir to the
|
@@ -150,6 +152,8 @@ module Giblish
|
|
150
152
|
end
|
151
153
|
end
|
152
154
|
|
155
|
+
# runs the supplied block but redirect stderr to a string
|
156
|
+
# returns the string containing stderr contents
|
153
157
|
def with_captured_stderr
|
154
158
|
old_stderr = $stderr
|
155
159
|
$stderr = StringIO.new("", "w")
|
@@ -160,9 +164,29 @@ module Giblish
|
|
160
164
|
end
|
161
165
|
module_function :with_captured_stderr
|
162
166
|
|
167
|
+
# transforms strings to valid asciidoctor id strings
|
163
168
|
def to_valid_id(input_str)
|
164
169
|
id_str = "_#{input_str.downcase}"
|
165
170
|
id_str.gsub(%r{[^a-z0-9]+},"_")
|
166
171
|
end
|
167
172
|
module_function :to_valid_id
|
173
|
+
|
174
|
+
# See https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
|
175
|
+
# Cross-platform way of finding an executable in the $PATH.
|
176
|
+
#
|
177
|
+
# Ex
|
178
|
+
# which('ruby') #=> /usr/bin/ruby
|
179
|
+
def which(cmd)
|
180
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
181
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
182
|
+
exts.each { |ext|
|
183
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
184
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
185
|
+
}
|
186
|
+
end
|
187
|
+
return nil
|
188
|
+
end
|
189
|
+
module_function :which
|
190
|
+
|
191
|
+
|
168
192
|
end
|
data/lib/giblish/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giblish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anders Rillbert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09
|
11
|
+
date: 2018-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,20 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 1.5.7.1
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: asciidoctor-diagram
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.5'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.5'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: asciidoctor-pdf
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,6 +152,7 @@ extra_rdoc_files: []
|
|
138
152
|
files:
|
139
153
|
- ".gitignore"
|
140
154
|
- ".rubocop.yml"
|
155
|
+
- ".ruby-version"
|
141
156
|
- ".travis.yml"
|
142
157
|
- Gemfile
|
143
158
|
- LICENSE
|
@@ -156,10 +171,13 @@ files:
|
|
156
171
|
- giblish.gemspec
|
157
172
|
- lib/giblish.rb
|
158
173
|
- lib/giblish/application.rb
|
174
|
+
- lib/giblish/buildgraph.rb
|
159
175
|
- lib/giblish/buildindex.rb
|
160
176
|
- lib/giblish/cmdline.rb
|
161
177
|
- lib/giblish/core.rb
|
178
|
+
- lib/giblish/docconverter.rb
|
162
179
|
- lib/giblish/docid.rb
|
180
|
+
- lib/giblish/docinfo.rb
|
163
181
|
- lib/giblish/gititf.rb
|
164
182
|
- lib/giblish/pathtree.rb
|
165
183
|
- lib/giblish/utils.rb
|
@@ -193,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
211
|
version: '0'
|
194
212
|
requirements: []
|
195
213
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.
|
214
|
+
rubygems_version: 2.7.6
|
197
215
|
signing_key:
|
198
216
|
specification_version: 4
|
199
217
|
summary: A tool for publishing asciidoc docs stored in git repos
|