diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a967f19..c9c9ab3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: needs: activate strategy: matrix: - ruby: [jruby, '2.3', '2.4', '2.5', '2.6', '2.7', '3.0'] + ruby: ['jruby', '2.4', '2.5', '2.6', '2.7', '3.0'] os: [ubuntu-latest, windows-latest] asciidoctor: [''] include: diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index d2e8d85..8bc8dfd 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -11,6 +11,8 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[ * use CSS for image size scaling instead of `width` attribute. #382 * use pygments.rb 2.0.0 in CI * add support for `:back-cover-image:` document attribute (#396) +* reenable Kindlegen support (#363) +* drop support for Ruby older than 2.4 == 1.5.0.alpha.19 (2020-10-21) - @slonopotamus diff --git a/Gemfile b/Gemfile index 1d2d335..8d1e636 100644 --- a/Gemfile +++ b/Gemfile @@ -14,4 +14,5 @@ end group :optional do # epubcheck-ruby might be safe to be converted into runtime dependency, but could have issues when packaged into asciidoctorj-epub3 gem 'epubcheck-ruby', '~> 4.2.5.0' + gem 'kindlegen', '~> 3.1.0' end diff --git a/asciidoctor-epub3.gemspec b/asciidoctor-epub3.gemspec index d1d70ca..e32ad46 100644 --- a/asciidoctor-epub3.gemspec +++ b/asciidoctor-epub3.gemspec @@ -17,7 +17,7 @@ An extension for Asciidoctor that converts AsciiDoc documents to EPUB3 and KF8/M s.homepage = 'https://github.com/asciidoctor/asciidoctor-epub3' s.license = 'MIT' - s.required_ruby_version = '>= 2.3.0' + s.required_ruby_version = '>= 2.4.0' files = begin (result = Open3.popen3('git ls-files -z') {|_, out| out.read }.split %(\0)).empty? ? Dir['**/*'] : result diff --git a/lib/asciidoctor-epub3/converter.rb b/lib/asciidoctor-epub3/converter.rb index 4ab339b..03b955b 100644 --- a/lib/asciidoctor-epub3/converter.rb +++ b/lib/asciidoctor-epub3/converter.rb @@ -1658,8 +1658,15 @@ def get_kindlegen_command return [result] end - logger.debug 'Using KindleGen from PATH' - [%(kindlegen#{::Gem.win_platform? ? '.exe' : ''})] + begin + require 'kindlegen' unless defined? ::Kindlegen + result = ::Kindlegen.command.to_s + logger.debug %(Using KindleGen from gem: #{result}) + [result] + rescue LoadError => e + logger.debug %(#{e}; Using KindleGen from PATH) + [%(kindlegen#{::Gem.win_platform? ? '.exe' : ''})] + end end def distill_epub_to_mobi epub_file, target, compress diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0caa558..8cc113c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -69,8 +69,13 @@ def skip_unless_has_logger skip 'Logger is unavailable on Asciidoctor < 1.5.7' unless has_logger? end + def darwin_platform? + RbConfig::CONFIG['host_os'] =~ /darwin/ + end + def skip_unless_has_kindlegen - skip 'KindleGen is gone: https://github.com/asciidoctor/asciidoctor-epub3/issues/363' + # TODO: https://github.com/asciidoctor/asciidoctor-epub3/issues/236 + skip '#236: Kindlegen is unavailable for 64-bit MacOS' if darwin_platform? end def convert input, opts = {}