Permalink
Browse files

install executable to gem's bin directory (works now on heroku, too)

  • Loading branch information...
1 parent 97af0ac commit 41f4f45333efd4a5efe5ded8c7b8559d07571848 Kai Schlichting committed with Nov 8, 2012
Showing with 15 additions and 16 deletions.
  1. +7 −9 ext/kindlegen/extconf.rb
  2. +8 −7 lib/kindlegen.rb
View
@@ -16,17 +16,13 @@
exit(1)
end
- config = RbConfig::CONFIG.merge( {
+ config = RbConfig::CONFIG.merge({
"unzip" => unzip,
"tarball" => tarball
- } )
-
- bindir = '../../../../bin'
- if Dir::pwd.include?( 'gems' ) && FileTest.directory?( bindir )
- w.puts RbConfig.expand(DATA.read, config.merge('bindir' => bindir) )
- else
- w.puts RbConfig.expand(DATA.read, config)
- end
+ })
+
+ bindir = File.join(File.expand_path('../../..', __FILE__), "bin")
+ w.puts RbConfig.expand(DATA.read, config.merge('bindir' => bindir))
end
@@ -38,6 +34,7 @@
CURL = curl
UNZIP = $(unzip)
CP = cp -a
+MKDIR = mkdir -p
all:
@@ -50,4 +47,5 @@
$(CURL) $(AMAZON)/$(TARBALL) -o $(TARBALL)
install: $(TARGET)
+ $(MKDIR) $(BINDIR)
$(CP) $(TARGET) $(BINDIR)
View
@@ -3,17 +3,18 @@
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.
- # If it required under gem, returning path in the extension.
- # Not if, it return simply 'kindlegen' so you have to copy the command into $PATH.
#
def self.command
- if __FILE__.include? 'gems'
- (Pathname( __FILE__ ).parent + '../ext/kindlegen/kindlegen').to_s
- else
- 'kindlegen'
- end
+ Executables[:kindlegen]
end
#

0 comments on commit 41f4f45

Please sign in to comment.