Sha256: 2927b951a3a4a2e8d120c6b6b688c3b0eebc40de1bd0ccc9add5e371c21fb229

Contents?: true

Size: 902 Bytes

Versions: 12

Compression:

Stored size: 902 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

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

12 entries across 12 versions & 1 rubygems

Version Path
asciidoctor-epub3-1.5.1 bin/adb-push-ebook
asciidoctor-epub3-1.5.0 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.19 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.18 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.17 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.16 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.15 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.14 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.13 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.12 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.11 bin/adb-push-ebook
asciidoctor-epub3-1.5.0.alpha.10 bin/adb-push-ebook