提交 4c5f1bc9 编写于 作者: X Xavier Noria 提交者: GitHub

Merge pull request #27396 from bianjp/fix-kindlerb

Fix rake guides:generate:kindle error
......@@ -44,7 +44,7 @@ group :doc do
gem "sdoc", "1.0.0.beta2"
gem "redcarpet", "~> 3.2.3", platforms: :ruby
gem "w3c_validators"
gem "kindlerb", ">= 1.0.1"
gem "kindlerb", "~> 1.2.0"
end
# Active Support.
......
......@@ -213,7 +213,7 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.0.2)
kindlerb (1.0.1)
kindlerb (1.2.0)
mustache
nokogiri
libxml-ruby (2.9.0)
......@@ -396,7 +396,7 @@ DEPENDENCIES
hiredis
jquery-rails
json (>= 2.0.0)
kindlerb (>= 1.0.1)
kindlerb (~> 1.2.0)
libxml-ruby
listen (>= 3.0.5, < 3.2)
minitest (< 5.3.4)
......
......@@ -13,8 +13,9 @@ namespace :guides do
desc "Generate .mobi file. The kindlegen executable must be in your PATH. You can get it for free from http://www.amazon.com/gp/feature.html?docId=1000765211"
task :kindle do
unless `kindlerb -v 2> /dev/null` =~ /kindlerb 1.0.1/
abort "Please `gem install kindlerb` and make sure you have `kindlegen` in your PATH"
require 'kindlerb'
unless Kindlerb.kindlegen_available?
abort "Please run `setupkindlerb` to install kindlegen"
end
unless `convert` =~ /convert/
abort "Please install ImageMagick`"
......
#!/usr/bin/env ruby
unless `which kindlerb`
abort "Please gem install kindlerb"
end
require 'kindlerb'
require "nokogiri"
require "fileutils"
require "yaml"
......@@ -28,10 +25,9 @@ def generate(output_dir, mobi_outfile, logfile)
generate_document_metadata(mobi_outfile)
puts "Creating MOBI document with kindlegen. This may take a while."
cmd = "kindlerb . > #{File.absolute_path logfile} 2>&1"
puts cmd
system(cmd)
puts "MOBI document generated at #{File.expand_path(mobi_outfile, output_dir)}"
if Kindlerb.run(output_dir)
puts "MOBI document generated at #{File.expand_path(mobi_outfile, output_dir)}"
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册