asciidoctor-epub3 1.5.0.alpha.9 → 1.5.0.alpha.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,88 +1,90 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Asciidoctor
2
- module Epub3
3
- class SpineItemProcessor < Extensions::IncludeProcessor
4
- def initialize document
5
- @document = document
6
- end
4
+ module Epub3
5
+ class SpineItemProcessor < Extensions::IncludeProcessor
6
+ def initialize document
7
+ @document = document
8
+ end
7
9
 
8
- # NOTE only fires for includes in spine document if registered directly on the instance of the spine document
9
- def process doc, reader, target, attributes
10
- spine_doc = doc
11
- # TODO allow URI value
12
- unless ::File.file?(include_file = (spine_doc.normalize_system_path target, reader.dir, nil, target_name: 'include file'))
13
- warn %(asciidoctor: WARNING: #{reader.line_info}: include file not found: #{include_file})
14
- return
15
- end
16
- inherited_attrs = spine_doc.attributes.dup
17
- # QUESTION should we keep backend-epub3 for convenience?
18
- %w(backend-epub3 backend-epub3-doctype-book docdir docfile docname doctitle outfilesuffix spine).each {|key| inherited_attrs.delete key }
19
- if (leveloffset = inherited_attrs['leveloffset'])
20
- leveloffset = inherited_attrs['leveloffset'] = %(#{leveloffset}@) unless leveloffset.end_with? '@'
21
- end
10
+ # NOTE only fires for includes in spine document if registered directly on the instance of the spine document
11
+ def process doc, reader, target, _attributes
12
+ spine_doc = doc
13
+ # TODO: allow URI value
14
+ unless ::File.file? (include_file = (spine_doc.normalize_system_path target, reader.dir, nil, target_name: 'include file'))
15
+ warn %(asciidoctor: WARNING: #{reader.line_info}: include file not found: #{include_file})
16
+ return
17
+ end
18
+ inherited_attrs = spine_doc.attributes.dup
19
+ # QUESTION should we keep backend-epub3 for convenience?
20
+ %w(backend-epub3 backend-epub3-doctype-book docdir docfile docname doctitle outfilesuffix spine).each {|key| inherited_attrs.delete key }
21
+ if (leveloffset = inherited_attrs['leveloffset'])
22
+ leveloffset = inherited_attrs['leveloffset'] = %(#{leveloffset}@) unless leveloffset.end_with? '@'
23
+ end
22
24
 
23
- # parse header to get author information
24
- spine_item_doc_meta = ::Asciidoctor.load_file include_file,
25
- safe: spine_doc.safe,
26
- backend: 'epub3-xhtml5',
27
- doctype: :article,
28
- parse_header_only: true,
29
- attributes: leveloffset ? { 'leveloffset' => leveloffset } : nil
25
+ # parse header to get author information
26
+ spine_item_doc_meta = ::Asciidoctor.load_file include_file,
27
+ safe: spine_doc.safe,
28
+ backend: 'epub3-xhtml5',
29
+ doctype: :article,
30
+ parse_header_only: true,
31
+ attributes: leveloffset ? { 'leveloffset' => leveloffset } : nil
30
32
 
31
- # blank out author information if present in sub-document
32
- # FIXME this is a huge hack...we need a cleaner way to do this; perhaps an API method that retrieves all the author attribute names
33
- if spine_item_doc_meta.attr? 'author'
34
- %w(author firstname lastname email authorinitials authors authorcount).each {|key| inherited_attrs.delete key }
35
- idx = 1
36
- while inherited_attrs.key? %(author_#{idx})
37
- %W(author_#{idx} firstname_#{idx} lastname_#{idx} email_#{idx} authorinitials_#{idx}).each {|key| inherited_attrs.delete key }
38
- idx += 1
39
- end
40
- end
33
+ # blank out author information if present in sub-document
34
+ # FIXME this is a huge hack...we need a cleaner way to do this; perhaps an API method that retrieves all the author attribute names
35
+ if spine_item_doc_meta.attr? 'author'
36
+ %w(author firstname lastname email authorinitials authors authorcount).each {|key| inherited_attrs.delete key }
37
+ idx = 1
38
+ while inherited_attrs.key? %(author_#{idx})
39
+ %W[author_#{idx} firstname_#{idx} lastname_#{idx} email_#{idx} authorinitials_#{idx}].each {|key| inherited_attrs.delete key }
40
+ idx += 1
41
+ end
42
+ end
41
43
 
42
- # REVIEW reaching into converter to resolve document id feels like a hack; should happen in Asciidoctor parser
43
- # also, strange that "id" doesn't work here
44
- idprefix = (spine_doc.attr 'idprefix') || (spine_item_doc_meta.attr 'idprefix')
45
- idseparator = (spine_doc.attr 'idseparator') || (spine_item_doc_meta.attr 'idseparator')
46
- inherited_attrs['css-signature'] = DocumentIdGenerator.generate_id spine_item_doc_meta, idprefix, idseparator
47
- inherited_attrs['docreldir'] = ::File.dirname target
44
+ # REVIEW: reaching into converter to resolve document id feels like a hack; should happen in Asciidoctor parser
45
+ # also, strange that "id" doesn't work here
46
+ idprefix = (spine_doc.attr 'idprefix') || (spine_item_doc_meta.attr 'idprefix')
47
+ idseparator = (spine_doc.attr 'idseparator') || (spine_item_doc_meta.attr 'idseparator')
48
+ inherited_attrs['css-signature'] = DocumentIdGenerator.generate_id spine_item_doc_meta, idprefix, idseparator
49
+ inherited_attrs['docreldir'] = ::File.dirname target
48
50
 
49
- # NOTE can't assign spine document as parent since there's too many assumptions in the Asciidoctor processor
50
- spine_item_doc = ::Asciidoctor.load_file include_file,
51
- # setting base_dir breaks if outdir is not a subdirectory of spine_doc.base_dir
52
- #base_dir: spine_doc.base_dir,
53
- # NOTE won't write to correct directory if safe mode is :secure
54
- safe: spine_doc.safe,
55
- backend: 'epub3-xhtml5',
56
- doctype: :article,
57
- header_footer: true,
58
- catalog_assets: true,
59
- attributes: inherited_attrs
51
+ # NOTE can't assign spine document as parent since there's too many assumptions in the Asciidoctor processor
52
+ spine_item_doc = ::Asciidoctor.load_file include_file,
53
+ # setting base_dir breaks if outdir is not a subdirectory of spine_doc.base_dir
54
+ #base_dir: spine_doc.base_dir,
55
+ # NOTE won't write to correct directory if safe mode is :secure
56
+ safe: spine_doc.safe,
57
+ backend: 'epub3-xhtml5',
58
+ doctype: :article,
59
+ header_footer: true,
60
+ catalog_assets: true,
61
+ attributes: inherited_attrs
60
62
 
61
- # restore attributes to those defined in the document header
62
- spine_item_doc.restore_attributes
63
+ # restore attributes to those defined in the document header
64
+ spine_item_doc.restore_attributes
63
65
 
64
- # FIXME core should register document ID if specified
65
- unless (refs = spine_item_doc.references)[:ids].include? spine_item_doc.id
66
- spine_item_doc.register :ids, [spine_item_doc.id, (spine_item_doc.attr 'docreftext') || spine_item_doc.doctitle]
67
- end
66
+ # FIXME: core should register document ID if specified
67
+ unless (refs = spine_item_doc.references)[:ids].include? spine_item_doc.id
68
+ spine_item_doc.register :ids, [spine_item_doc.id, (spine_item_doc.attr 'docreftext') || spine_item_doc.doctitle]
69
+ end
68
70
 
69
- refs[:spine] = spine_doc
70
- refs[:spine_items] = ((spine_doc.references[:spine_items] ||= []) << spine_item_doc)
71
- # NOTE if there are attribute assignments between the include directives,
72
- # then this ordered list is not continguous, so bailing on the idea
73
- #reader.replace_line %(. link:#{::File.basename(spine_item_doc.attr 'outfile')}[#{spine_item_doc.doctitle}])
74
- nil
75
- end
71
+ refs[:spine] = spine_doc
72
+ refs[:spine_items] = ((spine_doc.references[:spine_items] ||= []) << spine_item_doc)
73
+ # NOTE if there are attribute assignments between the include directives,
74
+ # then this ordered list is not continguous, so bailing on the idea
75
+ #reader.replace_line %(. link:#{::File.basename(spine_item_doc.attr 'outfile')}[#{spine_item_doc.doctitle}])
76
+ nil
77
+ end
76
78
 
77
- # handles? should get the attributes on include directive as the second argument
78
- def handles? target
79
- (@document.attr? 'spine') && (ASCIIDOC_EXTENSIONS.include? ::File.extname(target))
80
- end
79
+ # handles? should get the attributes on include directive as the second argument
80
+ def handles? target
81
+ (@document.attr? 'spine') && (ASCIIDOC_EXTENSIONS.include? ::File.extname(target))
82
+ end
81
83
 
82
- # FIXME this method shouldn't be required
83
- def update_config config
84
- (@config ||= {}).update config
84
+ # FIXME: this method shouldn't be required
85
+ def update_config config
86
+ (@config ||= {}).update config
87
+ end
88
+ end
85
89
  end
86
90
  end
87
- end
88
- end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Asciidoctor
2
- module Epub3
3
- VERSION = '1.5.0.alpha.9'
4
- end
4
+ module Epub3
5
+ VERSION = '1.5.0.alpha.10'
6
+ end
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-epub3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.alpha.9
4
+ version: 1.5.0.alpha.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-04 00:00:00.000000000 Z
12
+ date: 2020-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -17,14 +17,56 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 12.3.2
20
+ version: 12.3.0
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 12.3.2
27
+ version: 12.3.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 3.9.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 3.9.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: rubocop
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 0.78.0
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 0.78.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubocop-rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 1.37.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 1.37.0
28
70
  - !ruby/object:Gem::Dependency
29
71
  name: asciidoctor
30
72
  requirement: !ruby/object:Gem::Requirement
@@ -46,47 +88,47 @@ dependencies:
46
88
  - !ruby/object:Gem::Version
47
89
  version: 3.0.0
48
90
  - !ruby/object:Gem::Dependency
49
- name: gepub
91
+ name: concurrent-ruby
50
92
  requirement: !ruby/object:Gem::Requirement
51
93
  requirements:
52
94
  - - "~>"
53
95
  - !ruby/object:Gem::Version
54
- version: 1.0.2
96
+ version: 1.1.0
55
97
  type: :runtime
56
98
  prerelease: false
57
99
  version_requirements: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - "~>"
60
102
  - !ruby/object:Gem::Version
61
- version: 1.0.2
103
+ version: 1.1.0
62
104
  - !ruby/object:Gem::Dependency
63
- name: thread_safe
105
+ name: gepub
64
106
  requirement: !ruby/object:Gem::Requirement
65
107
  requirements:
66
108
  - - "~>"
67
109
  - !ruby/object:Gem::Version
68
- version: 0.3.6
110
+ version: 1.0.0
69
111
  type: :runtime
70
112
  prerelease: false
71
113
  version_requirements: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - "~>"
74
116
  - !ruby/object:Gem::Version
75
- version: 0.3.6
117
+ version: 1.0.0
76
118
  - !ruby/object:Gem::Dependency
77
- name: concurrent-ruby
119
+ name: thread_safe
78
120
  requirement: !ruby/object:Gem::Requirement
79
121
  requirements:
80
122
  - - "~>"
81
123
  - !ruby/object:Gem::Version
82
- version: 1.1.5
124
+ version: 0.3.0
83
125
  type: :runtime
84
126
  prerelease: false
85
127
  version_requirements: !ruby/object:Gem::Requirement
86
128
  requirements:
87
129
  - - "~>"
88
130
  - !ruby/object:Gem::Version
89
- version: 1.1.5
131
+ version: 0.3.0
90
132
  description: 'An extension for Asciidoctor that converts AsciiDoc documents to EPUB3
91
133
  and KF8/MOBI (Kindle) e-book archives.
92
134
 
@@ -180,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
222
  - !ruby/object:Gem::Version
181
223
  version: 1.3.1
182
224
  requirements: []
183
- rubygems_version: 3.0.3
225
+ rubygems_version: 3.1.2
184
226
  signing_key:
185
227
  specification_version: 4
186
228
  summary: Converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book formats