asciidoctor-reducer 1.0.0 → 1.0.1

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: 28901fa8f69c6cffe25cac501f7242980cd50dce1ad0586ccff44ed66c4eee30
4
- data.tar.gz: a8c80c18c767ba36a0c3642b69e166532c191d0f5772e884fb86d3341dc1889b
3
+ metadata.gz: '042939f0b251163208b57a67bed8a7b16d15d0972a616e67c171b8462a5ae61b'
4
+ data.tar.gz: 9065fc1b7a742f057441f873956883e6c87ba88afb1984496c821f378e666e2b
5
5
  SHA512:
6
- metadata.gz: b00cbaa7e4d145ed571dfe282f4b440dd61472feabdd79338ca27e2ceaf795593e0efb7e3f86cb05d021176328d4a20a37adf4f6ffdefb3b30fad480672e2821
7
- data.tar.gz: a923404fe5ed452e3a4145ba15f8512a441c6d8b47986a22bc1485edc6c8672f28f31dba30ad2e224ae2a3f98d7b383b1d5cefa81ae70af7779205ea300d6d1a
6
+ metadata.gz: 53e3e2cd52cf60ff810b93c5409cf521c1e5509106c8cece15ac89262d5a7d0ac998b2369ebb1cd8854675de930ea3a2f10c762bf072f758db663f3b6e7aa0ed
7
+ data.tar.gz: 1785df7825bd0fb902dd619bf42b2de90360acdf975f3356ca5ad8ed7b65a32c71c8824b51b966aecce774078d14d5c6dcdf281d899eb6f54e61307dbec0b0ce
data/CHANGELOG.adoc CHANGED
@@ -4,6 +4,17 @@
4
4
  This document provides a curated view of the changes to Asciidoctor Reducer in each release.
5
5
  For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
6
6
 
7
+ == 1.0.1 (2022-05-08) - @mojavelinux
8
+
9
+ === Changed
10
+
11
+ * Use summary from gemspec in help text for `asciidoctor-reducer` command
12
+ * Consistently access `source_lines` from document; use `#replace` to update
13
+
14
+ === Details
15
+
16
+ {url-repo}/releases/tag/v1.0.1[git tag] | {url-repo}/compare/v1.0.0\...v1.0.1[full diff]
17
+
7
18
  == 1.0.0 (2022-04-22) - @mojavelinux
8
19
 
9
20
  _No changes since previous release._
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = {project-name}
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
3
- v1.0.0, 2022-04-22
3
+ v1.0.1, 2022-05-08
4
4
  :idprefix:
5
5
  :idseparator: -
6
6
  ifndef::env-github[:icons: font]
@@ -14,7 +14,7 @@ module Asciidoctor::Reducer
14
14
  opts.banner = <<~END
15
15
  Usage: #{opts.program_name} [OPTION]... FILE
16
16
 
17
- Reduces a composite AsciiDoc document containing includes and conditionals to a single AsciiDoc document.
17
+ #{::Gem.loaded_specs['asciidoctor-reducer'].summary}
18
18
 
19
19
  END
20
20
 
@@ -5,20 +5,20 @@ module Asciidoctor::Reducer
5
5
  def preprocess_conditional_directive keyword, target, delimiter, text
6
6
  skip_active = @skipping
7
7
  depth = @conditional_stack.size
8
- cond_lineno = @lineno
8
+ directive_lineno = @lineno
9
9
  result = super
10
10
  return result if @skipping && skip_active
11
11
  drop = @include_replacements.current[:drop] ||= []
12
12
  if (depth_change = @conditional_stack.size - depth) < 0
13
13
  if skip_active
14
- drop.push(*(drop.pop..cond_lineno))
14
+ drop.push(*(drop.pop..directive_lineno))
15
15
  else
16
- drop << cond_lineno
16
+ drop << directive_lineno
17
17
  end
18
- elsif depth_change > 0 || cond_lineno == @lineno
19
- drop << cond_lineno
18
+ elsif depth_change > 0 || directive_lineno == @lineno
19
+ drop << directive_lineno
20
20
  else
21
- drop << [cond_lineno, text]
21
+ drop << [directive_lineno, text]
22
22
  end
23
23
  result
24
24
  end
@@ -2,10 +2,8 @@
2
2
 
3
3
  module Asciidoctor::Reducer
4
4
  module IncludeDirectiveTracker
5
- attr_reader :include_replacements
6
- attr_writer :source_lines
7
-
8
5
  def self.extended instance
6
+ instance.singleton_class.send :attr_reader, :include_replacements
9
7
  instance.instance_variable_set :@include_replacements, ([{}].extend CurrentPosition)
10
8
  instance.instance_variable_set :@x_reducer, {}
11
9
  end
@@ -13,14 +11,14 @@ module Asciidoctor::Reducer
13
11
  def preprocess_include_directive target, attrlist
14
12
  @x_reducer[:include_directive_line] = %(include::#{target}[#{attrlist}])
15
13
  @x_reducer[:include_pushed] = false
16
- inc_lineno = @lineno # we're currently on the include line, which is 1-based
14
+ directive_lineno = @lineno # we're currently on the include line, which is 1-based
17
15
  result = super
18
16
  unless @x_reducer[:include_pushed]
19
17
  if ((ln = peek_line true)&.end_with? ']') && !(unresolved = ln.start_with? 'Unresolved directive in ') &&
20
- inc_lineno == @lineno && (unresolved = ln.start_with? 'link:')
18
+ directive_lineno == @lineno && (unresolved = ln.start_with? 'link:')
21
19
  ln = %(#{ln.slice 0, (ln.length - 1)}role=include])
22
20
  end
23
- push_include_replacement inc_lineno, (unresolved ? [ln] : []), unresolved
21
+ push_include_replacement directive_lineno, (unresolved ? [ln] : []), unresolved
24
22
  end
25
23
  @x_reducer.clear
26
24
  result
@@ -28,10 +26,10 @@ module Asciidoctor::Reducer
28
26
 
29
27
  def push_include data, file, path, lineno, attrs
30
28
  @x_reducer[:include_pushed] = true
31
- inc_lineno = @lineno - 1 # we're below the include line, which is 1-based
29
+ directive_lineno = @lineno - 1 # we're below the include line, which is 1-based
32
30
  prev_inc_depth = @include_stack.size
33
31
  result = super
34
- push_include_replacement inc_lineno, (@include_stack.size > prev_inc_depth ? lines : [])
32
+ push_include_replacement directive_lineno, (@include_stack.size > prev_inc_depth ? lines : [])
35
33
  result
36
34
  end
37
35
 
@@ -55,9 +53,8 @@ module Asciidoctor::Reducer
55
53
  end
56
54
 
57
55
  module CurrentPosition
58
- attr_reader :pointer
59
-
60
56
  def self.extended instance
57
+ instance.singleton_class.send :attr_reader, :pointer
61
58
  instance.to_end
62
59
  end
63
60
 
@@ -7,7 +7,8 @@ module Asciidoctor::Reducer
7
7
  class Preprocessor < ::Asciidoctor::Extensions::Preprocessor
8
8
  def process doc, reader
9
9
  doc.options[:preserve_conditionals] ?
10
- (reader.extend IncludeDirectiveTracker) : (reader.extend ConditionalDirectiveTracker, IncludeDirectiveTracker)
10
+ (reader.extend IncludeDirectiveTracker) :
11
+ (reader.extend ConditionalDirectiveTracker, IncludeDirectiveTracker)
11
12
  end
12
13
  end
13
14
  end
@@ -19,7 +19,7 @@ module Asciidoctor::Reducer
19
19
  end
20
20
  target_lines[idx] = lines if target_lines
21
21
  end
22
- source_lines = inc_replacements[0][:lines].flatten
22
+ reduced_source_lines = inc_replacements[0][:lines].flatten
23
23
  if doc.sourcemap
24
24
  logger = ::Asciidoctor::LoggerManager.logger
25
25
  opts = doc.options.merge logger: nil, parse: false, reduced: true
@@ -27,13 +27,13 @@ module Asciidoctor::Reducer
27
27
  opts[:extension_registry] = ::Asciidoctor::Extensions::Registry.new ext_reg.groups
28
28
  end
29
29
  includes = doc.catalog[:includes]
30
- doc = ::Asciidoctor.load source_lines, opts
30
+ doc = ::Asciidoctor.load reduced_source_lines, opts
31
31
  doc.catalog[:includes] = includes
32
32
  doc.parse
33
33
  ::Asciidoctor::LoggerManager.logger = logger
34
34
  else
35
- source_lines.pop while (source_lines[-1] || :eof).empty?
36
- doc.reader.source_lines = source_lines
35
+ reduced_source_lines.pop while reduced_source_lines[-1] == ''
36
+ doc.source_lines.replace reduced_source_lines
37
37
  end
38
38
  end
39
39
  doc
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Reducer
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-reducer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-22 00:00:00.000000000 Z
11
+ date: 2022-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor