Sha256: dd3416a35da3f02c1163938b17eb1fe1be575a5b34cfe6541c1560809002822b

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

require "kindlegen/version"
require 'pathname'
require 'systemu'

module Kindlegen
  Root = Pathname.new(File.expand_path('../..', __FILE__))
  Bin  = Root.join('bin')
  Executables = Bin.children.inject({}) { |h, p|
    h[p.basename.to_s.to_sym] = p.to_s
    h
  }

  #
  # Getting command path of kindlegen.
  #
  def self.command
    Executables[:kindlegen]
  end

  #
  # Run kindlegen command with spacified parameters
  #
  # _params_:: array of command parameters.
  #
  def self.run( *params )
    clean_env do
      systemu(command + ' ' + params.join(' '))
    end
  end

private
  def self.clean_env
    env_backup = {}.tap{|e|ENV.each{|k,v| e[k] = v}}
    ENV.keys.each{|key| ENV.delete(key)}
    ret = yield
    env_backup.each{|k,v| ENV[k] = v}
    return ret
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kindlegen-2.9.2 lib/kindlegen.rb