Skip to content

Commit

Permalink
resolve asciidoctor#363: reenable dependency on kindlegen gem
Browse files Browse the repository at this point in the history
This commit also drops support for Ruby < 2.4

This reverts commit 33e27ee.
  • Loading branch information
slonopotamus committed Apr 27, 2021
1 parent 2c6263f commit bcbdb7b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion asciidoctor-epub3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions lib/asciidoctor-epub3/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit bcbdb7b

Please sign in to comment.