Sha256: 41f531dfe9cd62a537af6b8012840a02e3a24d88ea7f169b04bc6b7162b98bb1

Contents?: true

Size: 625 Bytes

Versions: 2

Compression:

Stored size: 625 Bytes

Contents

require "kindlegen/version"
require 'pathname'
require 'open3'

module Kindlegen
  Root = Pathname.new(File.expand_path('../..', __FILE__))
  Bin  = Root.join('bin')

  #
  # Getting command path of kindlegen.
  #
  def self.command
    Bin.join('kindlegen')
  end

  #
  # Run kindlegen command with spacified parameters
  #
  # _params_:: array of command parameters.
  #
  def self.run( *params )
    clean_env do
      Open3.capture3("#{command} #{params.join(' ')}")
    end
  end

private
  def self.clean_env
    env_backup = ENV.to_h
    ENV.clear
    ret = yield
    ENV.replace(env_backup)
    return ret
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kindlegen-2.9.7 lib/kindlegen.rb
kindlegen-2.9.6 lib/kindlegen.rb