asciidoctor-diagram 1.1.4 → 1.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: d0f22feab9b140a44c8beff1324a9c6c80a44c2d
4
- data.tar.gz: 2923f841a55ed9ca7f1cc965a0dcc1299a951ff0
3
+ metadata.gz: 58d14ba5e18dc4427eb55a9a9472939de9f0fc31
4
+ data.tar.gz: 3af41c9149de5a88e06e8eacafe16f55a5580dc8
5
5
  SHA512:
6
- metadata.gz: 4031f6c3fd7a115b699c55dfd8b030230ad390f576e251417dccbceb85c08d9356e0977e205b81c6e84ed4bc5318ed430d0a54225e03afa17a09521eff3c07b4
7
- data.tar.gz: 9ac14361407421bc48155c5f79a581480a54616c235e02ffb0b85cfc97db3507c9c283c6e9f9407e96067b6c933603def1b5a60f2a27f93a86bf7a8c0b387de2
6
+ metadata.gz: 0a1e03a029afb9ee6c81e550f541b03e3d9d4d28fd82a3700daf9d0009c77a2ee4bd42f810ed70e5473e26a7b98704a9b1742dddb43e25b1d8e82824b8b8b086
7
+ data.tar.gz: 2d244e715c478627049baf87f7f8adb581213a0759df56c0a3dac9f7f24fc036e575117551cfd3be427e7439206b7c81d31411aad93764ad90690eda2efd6205
@@ -1,5 +1,13 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 1.1.5
4
+
5
+ Enhancements::
6
+
7
+ * Use the output directory (outdir attribute) as base directory if it's specified.
8
+ * Do not auto-generate width/height attributes when outputting to a non-HTML backend. This resolves issues with
9
+ oversized images in docbook output.
10
+
3
11
  == 1.1.4
4
12
 
5
13
  Bug Fixes::
@@ -1,6 +1,7 @@
1
1
  require 'asciidoctor/extensions'
2
2
  require 'digest'
3
3
  require 'json'
4
+ require 'fileutils'
4
5
  require_relative 'java'
5
6
  require_relative 'png'
6
7
  require_relative 'svg'
@@ -96,7 +97,7 @@ module Asciidoctor
96
97
  target = attributes.delete('target')
97
98
 
98
99
  image_name = "#{target || ('diag-' + source.checksum)}.#{format}"
99
- image_dir = File.expand_path(parent.document.attributes['imagesdir'] || '', parent.document.attributes['docdir'])
100
+ image_dir = File.expand_path(parent.document.attributes['imagesdir'] || '', parent.document.attributes['outdir'] || parent.document.attributes['docdir'])
100
101
  image_file = File.expand_path(image_name, image_dir)
101
102
  metadata_file = File.expand_path("#{image_name}.cache", image_dir)
102
103
 
@@ -116,14 +117,17 @@ module Asciidoctor
116
117
  metadata = {'checksum' => source.checksum}
117
118
  metadata['width'], metadata['height'] = params[:decoder].get_image_size(result)
118
119
 
120
+ FileUtils.mkdir_p(image_dir) unless Dir.exists?(image_dir)
119
121
  File.open(image_file, 'wb') { |f| f.write result }
120
122
  File.open(metadata_file, 'w') { |f| JSON.dump(metadata, f) }
121
123
  end
122
124
 
123
125
  attributes['target'] = image_name
124
- attributes['width'] ||= metadata['width'] if metadata['width']
125
- attributes['height'] ||= metadata['height'] if metadata['height']
126
- attributes['alt'] ||= if (title_text = attributes['title'])
126
+ if /html/i =~ parent.document.attributes['backend']
127
+ attributes['width'] ||= metadata['width'] if metadata['width']
128
+ attributes['height'] ||= metadata['height'] if metadata['height']
129
+ end
130
+ attributes['alt'] ||= if title_text = attributes['title']
127
131
  title_text
128
132
  elsif target
129
133
  (File.basename target, (File.extname target) || '').tr '_-', ' '
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "1.1.4"
3
+ VERSION = "1.1.5"
4
4
  end
5
5
  end
@@ -271,4 +271,55 @@ plantuml::plantuml.txt["foobaz"]
271
271
  expect(File.exists?('foobaz.png')).to be_true
272
272
  expect(File.exists?('plantuml.png')).to be_false
273
273
  end
274
- end
274
+
275
+
276
+ it "should write files to outdir if set" do
277
+ doc = <<-eos
278
+ = Hello, PlantUML!
279
+ Doc Writer <doc@example.com>
280
+
281
+ == First Section
282
+
283
+ [plantuml, format="svg"]
284
+ ----
285
+ actor Foo1
286
+ boundary Foo2
287
+ Foo1 -> Foo2 : To boundary
288
+ ----
289
+ eos
290
+
291
+ d = Asciidoctor.load StringIO.new(doc), {:attributes => {'outdir' => 'foo'}}
292
+ b = d.find { |b| b.context == :image }
293
+
294
+ target = b.attributes['target']
295
+ expect(target).to_not be_nil
296
+ expect(File.exists?(target)).to be_false
297
+ expect(File.exists?(File.expand_path(target, 'foo'))).to be_true
298
+ end
299
+
300
+ it "should omit width/height attributes when generating docbook" do
301
+ doc = <<-eos
302
+ = Hello, PlantUML!
303
+ Doc Writer <doc@example.com>
304
+
305
+ == First Section
306
+
307
+ [plantuml, format="png"]
308
+ ----
309
+ User -> (Start)
310
+ ----
311
+ eos
312
+
313
+ d = Asciidoctor.load StringIO.new(doc), :attributes => {'backend' => 'docbook5' }
314
+ expect(d).to_not be_nil
315
+
316
+ b = d.find { |b| b.context == :image }
317
+ expect(b).to_not be_nil
318
+
319
+ target = b.attributes['target']
320
+ expect(File.exists?(target)).to be_true
321
+
322
+ expect(b.attributes['width']).to be_nil
323
+ expect(b.attributes['height']).to be_nil
324
+ end
325
+ end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pepijn Van Eeckhoudt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: asciidoctor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.1.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.1.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rjb
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.4.8
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.4.8
83
83
  description: Asciidoctor diagramming extension
@@ -129,17 +129,17 @@ require_paths:
129
129
  - lib
130
130
  required_ruby_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - '>='
132
+ - - ">="
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - '>='
137
+ - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.0.3
142
+ rubygems_version: 2.2.2
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: An extension for asciidoctor that adds support for UML diagram generation