asciidoctor-diagram 1.1.6 → 1.2.0.preview.1

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: 0098efdea85dc852061d2d62e6372757ce5dd564
4
- data.tar.gz: 419ac386041d57d824dcf202c18a64929fb6fc85
3
+ metadata.gz: b9105f3a758a381ee41273031fcdabb5c6e6c7c7
4
+ data.tar.gz: 9b8a9602d6832d46bb9d8e6b483a390b1d491c34
5
5
  SHA512:
6
- metadata.gz: 8e115238d21a4f3600f3671b9b614181ef37c609a07e3d880bbe30383355d315094a0d0f0ce8da364d24aa7b2a4a3ce85529bcd364c60afea7cc4fc410d81fd1
7
- data.tar.gz: 2af83d989277ca19f966ce79df019c6c9e94689c5a88397638579397525ca7bcd6d3489ef3a51118a344c733f9e74809202d8ed803d35d9c283dab1a0bcf2717
6
+ metadata.gz: f6d2ef13b181388d1737a021e163ba3376da41ac68bfde8974a3ff2e4ba4ad4ccc8ee142b12a0bf0ee9bc2317d59ebe043d8f49d3971d5a9a0b0e55ca78c62c6
7
+ data.tar.gz: 6fea7bf3a26ed2a07c5548ca90dc93fcbdaa175815bbf32f6bcb85eacb7d864ec692b25035f87c61d043692fe37647267af02b85eb1f566abf543c362dfc4b8b
data/CHANGELOG.adoc CHANGED
@@ -1,47 +1,10 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
- == 1.1.6
3
+ == 1.2.0
4
4
 
5
5
  Enhancements::
6
6
 
7
- * Updated PlantUML to revision 8002 (23/07U/2014)
8
- * Add support for Shaape diagrams (requires Shaape to be installed separately)
9
- * Add support for Blockdiag diagrams (requires Blockdiag to be installed separately)
10
- * Add support for Actdiag diagrams (requires Actdiag to be installed separately)
11
- * Add support for Seqdiag diagrams (requires Seqdiag to be installed separately)
12
- * Add support for Nwdiag diagrams (requires Nwdiag to be installed separately)
13
-
14
- Bug Fixes::
15
- * Issue #38: Resolved Graphviz syntax errors with certain diagrams
16
-
17
- == 1.1.5
18
-
19
- Enhancements::
20
-
21
- * Use the output directory (outdir attribute) as base directory if it's specified.
22
- * Do not auto-generate width/height attributes when outputting to a non-HTML backend. This resolves issues with
23
- oversized images in docbook output.
24
-
25
- == 1.1.4
26
-
27
- Bug Fixes::
28
-
29
- * Under CRuby in combination with certain Java versions a FileNotFoundException could be triggered due to incorrect
30
- method selection by RJB
31
-
32
- == 1.1.3
33
-
34
- Bug Fixes::
35
-
36
- * Image regeneration logic did not always correctly detect cases where images did not need to be updated
37
-
38
- == 1.1.2
39
-
40
- Bug Fixes::
41
-
42
- * Fix corrupt PNG images on Windows
43
- * Fix NoSuchMethodError in block macro processing when target image file already existed
44
- * Respect target attribute in block macros
7
+ * Updated to Asciidoctor 1.5.0
45
8
 
46
9
  == 1.1.1
47
10
 
data/examples/README.adoc CHANGED
@@ -1,6 +1,18 @@
1
1
  = Asciidoctor-diagram Examples
2
2
 
3
3
  This directory contains a number of example files that illustrate how to use the asciidoctor-diagram extension.
4
- Asciidoctor 0.1.4 does not support loading extensions via the command line.
5
- In order to process the examples correctly you should use the `build-example.rb` script.
6
- This wraps the regular `asciidoctor` command line tool and automatically loads the asciidoctor-diagram extension.
4
+
5
+ In order to build the examples correctly the asciidoctor-diagram extension should be loaded.
6
+ This can be done using bundler by running
7
+
8
+ ----
9
+ bundle exec asciidoctor -r asciidoctor-diagram <asciidoc file>
10
+ ----
11
+
12
+ If you do not want to use bundler you can alternatively run
13
+
14
+ ----
15
+ asciidoctor -r asciidoctor-diagram -I ../lib <asciidoc file>
16
+ ----
17
+
18
+ This variant requires you to explicitly specify the load path from which asciidoctor-diagram can be loaded.
@@ -1,5 +1,3 @@
1
- require 'asciidoctor-diagram/blockdiag'
2
1
  require 'asciidoctor-diagram/ditaa'
3
2
  require 'asciidoctor-diagram/graphviz'
4
- require 'asciidoctor-diagram/plantuml'
5
- require 'asciidoctor-diagram/shaape'
3
+ require 'asciidoctor-diagram/plantuml'
@@ -3,6 +3,6 @@ require_relative 'version'
3
3
 
4
4
  Asciidoctor::Extensions.register do
5
5
  require_relative 'ditaa/extension'
6
- block :ditaa, Asciidoctor::Diagram::DitaaBlock
7
- block_macro :ditaa, Asciidoctor::Diagram::DitaaBlockMacro
6
+ block Asciidoctor::Diagram::DitaaBlock, :ditaa
7
+ block_macro Asciidoctor::Diagram::DitaaBlockMacro, :ditaa
8
8
  end
@@ -1,35 +1,37 @@
1
1
  require_relative '../util/diagram'
2
- require_relative '../util/java'
2
+ require_relative 'generator'
3
3
 
4
4
  module Asciidoctor
5
5
  module Diagram
6
- module DitaaGenerator
7
- DITAA_JAR_PATH = File.expand_path File.join('../..', 'ditaamini0_9.jar'), File.dirname(__FILE__)
8
- Java.classpath << DITAA_JAR_PATH
6
+ module DitaaBase
7
+ include DitaaGenerator
9
8
 
10
- def self.ditaa(code)
11
- Java.load
9
+ private
12
10
 
13
- args = ['-e', 'UTF-8']
14
-
15
- bytes = code.encode(Encoding::UTF_8).bytes.to_a
16
- bis = Java.new_object(Java.java.io.ByteArrayInputStream, '[B', Java.array_to_java_array(bytes, :byte))
17
- bos = Java.new_object(Java.java.io.ByteArrayOutputStream)
18
- result_code = Java.org.stathissideris.ascii2image.core.CommandLineConverter.convert(Java.array_to_java_array(args, :string), bis, bos)
19
- bis.close
20
- bos.close
21
-
22
- result = Java.string_from_java_bytes(bos.toByteArray)
11
+ def register_formats
12
+ register_format(:png, :image) do |c|
13
+ ditaa(c)
14
+ end
15
+ end
16
+ end
23
17
 
24
- raise "Ditaa image generation failed: #{result}" unless result_code == 0
18
+ class DitaaBlock < Asciidoctor::Extensions::BlockProcessor
19
+ include DiagramProcessorBase
20
+ include DitaaBase
25
21
 
26
- result
22
+ def initialize name = nil, config = {}
23
+ super
24
+ register_formats()
27
25
  end
28
26
  end
29
27
 
30
- DiagramProcessor.define_processors('Ditaa') do
31
- register_format(:png, :image) do |c|
32
- DitaaGenerator.ditaa(c)
28
+ class DitaaBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor
29
+ include DiagramProcessorBase
30
+ include DitaaBase
31
+
32
+ def initialize name = nil, config = {}
33
+ super
34
+ register_formats()
33
35
  end
34
36
  end
35
37
  end
@@ -0,0 +1,31 @@
1
+ require_relative '../util/java'
2
+
3
+ module Asciidoctor
4
+ module Diagram
5
+ module DitaaGenerator
6
+ private
7
+
8
+ DITAA_JAR_PATH = File.expand_path File.join('../..', 'ditaamini0_9.jar'), File.dirname(__FILE__)
9
+ Java.classpath << DITAA_JAR_PATH
10
+
11
+ def ditaa(code)
12
+ Java.load
13
+
14
+ args = ['-e', 'UTF-8']
15
+
16
+ bytes = code.encode(Encoding::UTF_8).bytes.to_a
17
+ bis = Java.java.io.ByteArrayInputStream.new(Java.array_to_java_array(bytes, :byte))
18
+ bos = Java.java.io.ByteArrayOutputStream.new
19
+ result_code = Java.org.stathissideris.ascii2image.core.CommandLineConverter.convert(Java.array_to_java_array(args, :string), bis, bos)
20
+ bis.close
21
+ bos.close
22
+
23
+ result = Java.string_from_java_bytes(bos.toByteArray)
24
+
25
+ raise "Ditaa image generation failed: #{result}" unless result_code == 0
26
+
27
+ result
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,6 +3,6 @@ require_relative 'version'
3
3
 
4
4
  Asciidoctor::Extensions.register do
5
5
  require_relative 'graphviz/extension'
6
- block :graphviz, Asciidoctor::Diagram::GraphvizBlock
7
- block_macro :graphviz, Asciidoctor::Diagram::GraphvizBlockMacro
6
+ block Asciidoctor::Diagram::GraphvizBlock, :graphviz
7
+ block_macro Asciidoctor::Diagram::GraphvizBlockMacro, :graphviz
8
8
  end
@@ -1,18 +1,41 @@
1
- require_relative '../util/cli_generator'
2
1
  require_relative '../util/diagram'
2
+ require_relative '../plantuml/generator'
3
3
 
4
4
  module Asciidoctor
5
5
  module Diagram
6
- module Diagram
7
- DiagramProcessor.define_processors('Graphviz') do
8
- [:png, :svg].each do |f|
9
- register_format(f, :image) do |c, p|
10
- CliGenerator.generate('dot', p, c) do |tool_path, output_path|
11
- [tool_path, "-o#{output_path}", "-T#{f.to_s}"]
12
- end
13
- end
6
+ module GraphvizBase
7
+ include PlantUmlGenerator
8
+
9
+ private
10
+
11
+ def register_formats
12
+ register_format(:png, :image) do |c, p|
13
+ plantuml(p, c, 'dot')
14
+ end
15
+ register_format(:svg, :image) do |c, p|
16
+ plantuml(p, c, 'dot', '-tsvg')
14
17
  end
15
18
  end
16
19
  end
20
+
21
+ class GraphvizBlock < Asciidoctor::Extensions::BlockProcessor
22
+ include DiagramProcessorBase
23
+ include GraphvizBase
24
+
25
+ def initialize name = nil, config = {}
26
+ super
27
+ register_formats()
28
+ end
29
+ end
30
+
31
+ class GraphvizBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor
32
+ include DiagramProcessorBase
33
+ include GraphvizBase
34
+
35
+ def initialize name = nil, config = {}
36
+ super
37
+ register_formats()
38
+ end
39
+ end
17
40
  end
18
41
  end
@@ -3,6 +3,7 @@ require_relative 'version'
3
3
 
4
4
  Asciidoctor::Extensions.register do
5
5
  require_relative 'plantuml/extension'
6
- block :plantuml, Asciidoctor::Diagram::PlantUmlBlock
7
- block_macro :plantuml, Asciidoctor::Diagram::PlantUmlBlockMacro
6
+
7
+ block Asciidoctor::Diagram::PlantUmlBlock, :plantuml
8
+ block_macro Asciidoctor::Diagram::PlantUmlBlockMacro, :plantuml
8
9
  end
@@ -3,25 +3,41 @@ require_relative 'generator'
3
3
 
4
4
  module Asciidoctor
5
5
  module Diagram
6
- DiagramProcessor.define_processors('PlantUml') do
7
- def config_args(parent)
8
- config_args = []
9
- config = parent.document.attributes['plantumlconfig']
10
- if config
11
- config_args += ['-config', File.expand_path(config, parent.document.attributes['docdir'])]
12
- end
6
+ module PlantUmlBase
7
+ include PlantUmlGenerator
13
8
 
14
- config_args
15
- end
9
+ private
16
10
 
17
- register_format(:png, :image) do |c, p|
18
- PlantUmlGenerator.plantuml(p, c, 'uml', *config_args(p))
11
+ def register_formats()
12
+ register_format(:png, :image) do |c, p|
13
+ plantuml(p, c, 'uml')
14
+ end
15
+ register_format(:svg, :image) do |c, p|
16
+ plantuml(p, c, 'uml', '-tsvg')
17
+ end
18
+ register_format(:txt, :literal) do |c, p|
19
+ plantuml(p, c, 'uml', '-tutxt')
20
+ end
19
21
  end
20
- register_format(:svg, :image) do |c, p|
21
- PlantUmlGenerator.plantuml(p, c, 'uml', '-tsvg', *config_args(p))
22
+ end
23
+
24
+ class PlantUmlBlock < Asciidoctor::Extensions::BlockProcessor
25
+ include DiagramProcessorBase
26
+ include PlantUmlBase
27
+
28
+ def initialize name = nil, config = {}
29
+ super
30
+ register_formats()
22
31
  end
23
- register_format(:txt, :literal) do |c, p|
24
- PlantUmlGenerator.plantuml(p, c, 'uml', '-tutxt', *config_args(p))
32
+ end
33
+
34
+ class PlantUmlBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor
35
+ include DiagramProcessorBase
36
+ include PlantUmlBase
37
+
38
+ def initialize name = nil, config = {}
39
+ super
40
+ register_formats()
25
41
  end
26
42
  end
27
43
  end
@@ -1,5 +1,4 @@
1
1
  require_relative '../util/java'
2
- require_relative '../util/which'
3
2
 
4
3
  module Asciidoctor
5
4
  module Diagram
@@ -9,10 +8,10 @@ module Asciidoctor
9
8
  PLANTUML_JAR_PATH = File.expand_path File.join('../..', 'plantuml.jar'), File.dirname(__FILE__)
10
9
  Java.classpath << PLANTUML_JAR_PATH
11
10
 
12
- def self.plantuml(parent, code, tag, *flags)
11
+ def plantuml(parent, code, tag, *flags)
13
12
  unless @graphvizdot
14
13
  @graphvizdot = parent.document.attributes['graphvizdot']
15
- @graphvizdot = ::Asciidoctor::Diagram.which('dot') unless @graphvizdot && File.executable?(@graphvizdot)
14
+ @graphvizdot = which('dot') unless @graphvizdot && File.executable?(@graphvizdot)
16
15
  raise "Could not find the Graphviz 'dot' executable in PATH; add it to the PATH or specify its location using the 'graphvizdot' document attribute" unless @graphvizdot
17
16
  end
18
17
 
@@ -22,20 +21,35 @@ module Asciidoctor
22
21
 
23
22
  flags += ['-charset', 'UTF-8', '-failonerror', '-graphvizdot', @graphvizdot]
24
23
 
25
- option = Java.new_object( Java.net.sourceforge.plantuml.Option, '[Ljava.lang.String;', Java.array_to_java_array(flags, :string) )
26
- source_reader = Java.new_object( Java.net.sourceforge.plantuml.SourceStringReader,
27
- 'Lnet.sourceforge.plantuml.preproc.Defines;Ljava.lang.String;Ljava.util.List;',
28
- Java.new_object( Java.net.sourceforge.plantuml.preproc.Defines ),
29
- code,
30
- option.getConfig()
24
+ config_file = parent.document.attributes['plantumlconfig']
25
+ if config_file
26
+ flags += ['-config', File.expand_path(config_file, parent.document.attributes['docdir'])]
27
+ end
28
+
29
+ option = Java.net.sourceforge.plantuml.Option.new(Java.array_to_java_array(flags, :string))
30
+ source_reader = Java.net.sourceforge.plantuml.SourceStringReader.new(
31
+ Java.net.sourceforge.plantuml.preproc.Defines.new(),
32
+ code,
33
+ option.getConfig()
31
34
  )
32
35
 
33
- bos = Java.new_object( Java.java.io.ByteArrayOutputStream )
34
- ps = Java.new_object( Java.java.io.PrintStream, 'Ljava.io.OutputStream;', bos )
36
+ bos = Java.java.io.ByteArrayOutputStream.new
37
+ ps = Java.java.io.PrintStream.new(bos)
35
38
  source_reader.generateImage(ps, 0, option.getFileFormatOption())
36
39
  ps.close
37
40
  Java.string_from_java_bytes(bos.toByteArray)
38
41
  end
42
+
43
+ def which(cmd)
44
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
45
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
46
+ exts.each { |ext|
47
+ exe = File.join(path, "#{cmd}#{ext}")
48
+ return exe if File.executable? exe
49
+ }
50
+ end
51
+ nil
52
+ end
39
53
  end
40
54
  end
41
55
  end
@@ -1,14 +1,13 @@
1
1
  require 'asciidoctor/extensions'
2
2
  require 'digest'
3
3
  require 'json'
4
- require 'fileutils'
5
4
  require_relative 'java'
6
5
  require_relative 'png'
7
6
  require_relative 'svg'
8
7
 
9
8
  module Asciidoctor
10
9
  module Diagram
11
- module DiagramProcessor
10
+ module DiagramProcessorBase
12
11
  IMAGE_PARAMS = {
13
12
  :svg => {
14
13
  :encoding => Encoding::UTF_8,
@@ -20,81 +19,42 @@ module Asciidoctor
20
19
  }
21
20
  }
22
21
 
23
- module ClassMethods
24
- #
25
- # Registers a supported format. The first registered format becomes the default format for the block processor.
26
- #
27
- # +format+ is a symbol with the format name
28
- # +type+ is a symbol and should be either :image or :literal
29
- # +block+ is a block that produces the diagrams from code. The block receives the parent asciidoc block and the diagram code as arguments
30
- #
31
- def register_format(format, type, &block)
32
- unless @default_format
33
- @default_format = format
34
- end
22
+ def self.included(base)
23
+ base.option :pos_attrs, ['target', 'format']
35
24
 
36
- formats[format] = {
37
- :type => type,
38
- :generator => block
39
- }
40
- end
25
+ if base.ancestors.include?(Asciidoctor::Extensions::BlockProcessor)
26
+ base.option :contexts, [:listing, :literal, :open]
27
+ base.option :content_model, :simple
41
28
 
42
- def formats
43
- @formats ||= {}
44
- end
45
-
46
- def default_format
47
- @default_format
48
- end
49
- end
50
-
51
- def self.included base
52
- base.extend ClassMethods
53
- end
54
-
55
- def self.define_processors(name, &init)
56
- block = Class.new(Asciidoctor::Extensions::BlockProcessor) do
57
- include DiagramProcessor
58
-
59
- option :pos_attrs, ['target', 'format']
60
- option :contexts, [:listing, :literal, :open]
61
- option :content_model, :simple
62
-
63
- def process(parent, reader, attributes)
64
- generate_block(parent, ReaderSource.new(reader), attributes)
29
+ base.instance_eval do
30
+ alias_method :process, :process_block
31
+ end
32
+ else
33
+ base.instance_eval do
34
+ alias_method :process, :process_macro
65
35
  end
66
-
67
- self.instance_eval &init
68
36
  end
69
37
 
70
- block_macro = Class.new(Asciidoctor::Extensions::BlockMacroProcessor) do
71
- include DiagramProcessor
72
-
73
- option :pos_attrs, ['target', 'format']
74
-
75
- def process(parent, target, attributes)
76
- source = FileSource.new(File.expand_path(target, parent.document.attributes['docdir']))
77
- attributes['target'] ||= File.basename(target, File.extname(target))
78
-
79
- generate_block(parent, source, attributes)
80
- end
38
+ end
81
39
 
82
- self.instance_eval &init
83
- end
40
+ def process_macro(parent, target, attributes)
41
+ source = FileSource.new(File.expand_path(target, parent.document.attributes['docdir']))
42
+ attributes['target'] = File.basename(target, File.extname(target))
84
43
 
85
- Asciidoctor::Diagram.const_set("#{name}Block", block)
86
- Asciidoctor::Diagram.const_set("#{name}BlockMacro", block_macro)
44
+ generate_block(parent, source, attributes)
87
45
  end
88
46
 
89
- private
47
+ def process_block(parent, reader, attributes)
48
+ generate_block(parent, ReaderSource.new(reader), attributes)
49
+ end
90
50
 
91
51
  def generate_block(parent, source, attributes)
92
- format = attributes.delete('format') || self.class.default_format
52
+ format = attributes.delete('format') || @default_format
93
53
  format = format.to_sym if format.respond_to?(:to_sym)
94
54
 
95
55
  raise "Format undefined" unless format
96
56
 
97
- generator_info = self.class.formats[format]
57
+ generator_info = formats[format]
98
58
 
99
59
  raise "#{self.class.name} does not support output format #{format}" unless generator_info
100
60
 
@@ -108,41 +68,65 @@ module Asciidoctor
108
68
  end
109
69
  end
110
70
 
71
+ private
72
+
73
+ #
74
+ # Registers a supported format. The first registered format becomes the default format for the block processor.
75
+ #
76
+ # +format+ is a symbol with the format name
77
+ # +type+ is a symbol and should be either :image or :literal
78
+ # +block+ is a block that produces the diagrams from code. The block receives the parent asciidoc block and the diagram code as arguments
79
+ #
80
+ def register_format(format, type, &block)
81
+ unless @default_format
82
+ @default_format = format
83
+ end
84
+
85
+ formats[format] = {
86
+ :type => type,
87
+ :generator => block
88
+ }
89
+ end
90
+
91
+ def formats
92
+ @formats ||= {}
93
+ end
94
+
111
95
  def create_image_block(parent, source, attributes, format, generator_info)
112
96
  target = attributes.delete('target')
113
97
 
114
98
  image_name = "#{target || ('diag-' + source.checksum)}.#{format}"
115
- image_dir = File.expand_path(parent.document.attributes['imagesdir'] || '', parent.document.attributes['outdir'] || parent.document.attributes['docdir'])
99
+ image_dir = File.expand_path(parent.document.attributes['imagesdir'] || '', parent.document.attributes['docdir'])
116
100
  image_file = File.expand_path(image_name, image_dir)
117
- metadata_file = File.expand_path("#{image_name}.cache", image_dir)
118
101
 
119
- if File.exists? metadata_file
120
- metadata = File.open(metadata_file, 'r') { |f| JSON.load f }
121
- else
122
- metadata = {}
123
- end
102
+ if source.newer_than?(image_file)
103
+ cache_file = File.expand_path("#{image_name}.cache", image_dir)
104
+
105
+ if File.exists? cache_file
106
+ metadata = File.open(cache_file, 'r') { |f| JSON.load f }
107
+ else
108
+ metadata = nil
109
+ end
124
110
 
125
- if source.should_process?(image_file, metadata['checksum'])
126
- params = IMAGE_PARAMS[format]
111
+ unless File.exists?(image_file) && metadata && metadata['checksum'] == source.checksum
112
+ params = IMAGE_PARAMS[format]
127
113
 
128
- result = generator_info[:generator].call(source.code, parent)
114
+ result = generator_info[:generator].call(source.code, parent)
129
115
 
130
- result.force_encoding(params[:encoding])
116
+ result.force_encoding(params[:encoding])
131
117
 
132
- metadata = {'checksum' => source.checksum}
133
- metadata['width'], metadata['height'] = params[:decoder].get_image_size(result)
118
+ metadata = {'checksum' => source.checksum}
119
+ metadata['width'], metadata['height'] = params[:decoder].get_image_size(result)
134
120
 
135
- FileUtils.mkdir_p(image_dir) unless Dir.exists?(image_dir)
136
- File.open(image_file, 'wb') { |f| f.write result }
137
- File.open(metadata_file, 'w') { |f| JSON.dump(metadata, f) }
121
+ File.open(image_file, 'w') { |f| f.write result }
122
+ File.open(cache_file, 'w') { |f| JSON.dump(metadata, f) }
123
+ end
138
124
  end
139
125
 
140
126
  attributes['target'] = image_name
141
- if /html/i =~ parent.document.attributes['backend']
142
- attributes['width'] ||= metadata['width'] if metadata['width']
143
- attributes['height'] ||= metadata['height'] if metadata['height']
144
- end
145
- attributes['alt'] ||= if title_text = attributes['title']
127
+ attributes['width'] ||= metadata['width'] if metadata['width']
128
+ attributes['height'] ||= metadata['height'] if metadata['height']
129
+ attributes['alt'] ||= if (title_text = attributes['title'])
146
130
  title_text
147
131
  elsif target
148
132
  (File.basename target, (File.extname target) || '').tr '_-', ' '
@@ -170,12 +154,12 @@ module Asciidoctor
170
154
  end
171
155
 
172
156
  class Source
173
- def checksum
174
- @checksum ||= compute_checksum(code)
157
+ def newer_than?(image)
158
+ true
175
159
  end
176
160
 
177
- def should_process?(image_file, old_checksum)
178
- !File.exists?(image_file) || (newer_than?(image_file) && old_checksum != checksum)
161
+ def checksum
162
+ @checksum ||= compute_checksum(code)
179
163
  end
180
164
 
181
165
  private
@@ -192,12 +176,8 @@ module Asciidoctor
192
176
  @reader = reader
193
177
  end
194
178
 
195
- def newer_than?(image_file)
196
- true
197
- end
198
-
199
179
  def code
200
- @code ||= @reader.lines.join
180
+ @code ||= @reader.lines.join("\n")
201
181
  end
202
182
  end
203
183
 
@@ -206,13 +186,13 @@ module Asciidoctor
206
186
  @file_name = file_name
207
187
  end
208
188
 
209
- def newer_than?(image_file)
210
- File.mtime(@file_name) > File.mtime(image_file)
211
- end
212
-
213
189
  def code
214
190
  @code ||= File.read(@file_name)
215
191
  end
192
+
193
+ def newer_than?(image)
194
+ !File.exists?(image) || File.mtime(@file_name) > File.mtime(image)
195
+ end
216
196
  end
217
197
  end
218
198
  end