Sha256: f31f2857035c43c4bd2499d8dd6aa94bc89d5dcf2a458e1feb1730e204fad519

Contents?: true

Size: 868 Bytes

Versions: 3

Compression:

Stored size: 868 Bytes

Contents

#!/usr/bin/env ruby

ADB = ENV['ADB'] || 'adb'
TARGETS = {
  '.epub' => '/sdcard/',
  '.mobi' => '/sdcard/Android/data/com.amazon.kindle/files/'
}

unless ::File.executable? ADB
  warn %(adb-push-ebook: `adb` not found.\nPlease set the ADB environment variable or add `adb` to your PATH.)
  exit 1
end

require 'open3'
require 'shellwords'

payload_file = ARGV[0] || '_output/sample-book'

if (payload_file_ext = File.extname payload_file).empty?
  transfers = TARGETS.map do |(ext, target_dir)|
    {
      src: %(#{payload_file}#{ext}),
      dest: target_dir
    }
  end
else
  transfers = [{ src: payload_file, dest: TARGETS[payload_file_ext] }]
end

transfers.each do |transfer|
  Open3.popen2e(Shellwords.join [ADB, 'push', transfer[:src], transfer[:dest]]) do |input, output, wait_thr|
    output.each {|line| puts line }
  end if File.file? transfer[:src]
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asciidoctor-epub3-1.5.0.alpha.9 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.8 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.7 bin/adb-push-ebook